Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Commit 4f80d2a

Browse files
authored
Merge branch 'master' into master
2 parents df58369 + ec6166e commit 4f80d2a

File tree

8 files changed

+218
-14
lines changed

8 files changed

+218
-14
lines changed

README.md

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Your backend needs to implement 4 urls:
1010
* `/search` used by the find metric options on the query tab in panels.
1111
* `/query` should return metrics based on input.
1212
* `/annotations` should return annotations.
13+
* `/tag-keys` should return tag keys for ad hoc filters.
14+
* `/tag-values` should return tag values for ad hoc filters.
1315

1416
## Installation
1517

@@ -25,6 +27,7 @@ information.
2527
- https://github.com/bergquist/fake-simple-json-datasource
2628
- https://github.com/smcquay/jsonds
2729
- https://github.com/ContextLogic/eventmaster
30+
- https://gist.github.com/linar-jether/95ff412f9d19fdf5e51293eb0c09b850 (Python/pandas backend)
2831

2932
### Query API
3033

@@ -50,6 +53,11 @@ Example `timeserie` request
5053
{ "target": "upper_50", "refId": "A", "type": "timeserie" },
5154
{ "target": "upper_75", "refId": "B", "type": "timeserie" }
5255
],
56+
"adhocFilters": [
57+
"key": "City"
58+
"operator": "=",
59+
"value": "Berlin"
60+
]
5361
"format": "json",
5462
"maxDataPoints": 550
5563
}
@@ -76,7 +84,7 @@ Example `timeserie` response
7684
```
7785

7886
If the metric selected is `"type": "table"`, an example `table` response:
79-
```json
87+
``` json
8088
[
8189
{
8290
"columns":[
@@ -97,7 +105,7 @@ If the metric selected is `"type": "table"`, an example `table` response:
97105
### Annotation API
98106

99107
The annotation request from the Simple JSON Datasource is a POST request to
100-
the /annotations endpoint in your datasource. The JSON request body looks like this:
108+
the `/annotations` endpoint in your datasource. The JSON request body looks like this:
101109
``` javascript
102110
{
103111
"range": {
@@ -134,7 +142,7 @@ following format:
134142
```
135143

136144
Note: If the datasource is configured to connect directly to the backend, you
137-
also need to implement an OPTIONS endpoint at /annotations that responds
145+
also need to implement an OPTIONS endpoint at `/annotations` that responds
138146
with the correct CORS headers:
139147

140148
```
@@ -162,22 +170,61 @@ Example map response
162170
[ { "text" :"upper_25", "value": 1}, { "text" :"upper_75", "value": 2} ]
163171
```
164172

173+
### Tag Keys API
174+
175+
Example request
176+
``` javascript
177+
{ }
178+
```
179+
180+
The tag keys api returns:
181+
```javascript
182+
[
183+
{"type":"string","text":"City"},
184+
{"type":"string","text":"Country"}
185+
]
186+
```
187+
188+
### Tag Values API
189+
190+
Example request
191+
``` javascript
192+
{"key": "City"}
193+
```
194+
195+
The tag values api returns:
196+
```javascript
197+
[
198+
{'text': 'Eins!'},
199+
{'text': 'Zwei'},
200+
{'text': 'Drei!'}
201+
]
202+
```
203+
165204
### Dev setup
166205

167206
This plugin requires node 6.10.0
168207

169-
`npm install -g yarn`
170-
`yarn install`
171-
`npm run build`
208+
```
209+
npm install -g yarn
210+
yarn install
211+
npm run build
212+
```
172213

173214
### Changelog
174215

216+
1.4.0
217+
218+
- Support for adhoc filters:
219+
- added tag-keys + tag-values api
220+
- added adHocFilters parameter to query body
221+
175222
1.3.5
176223
- Fix for dropdowns in query editor to allow writing template variables (broke due to change in Grafana).
177224

178225
1.3.4
179226
- Adds support for With Credentials (sends grafana cookies with request) when using Direct mode
180-
- Fix for the typeahead component for metrics dropdown (/search endpoint).
227+
- Fix for the typeahead component for metrics dropdown (`/search` endpoint).
181228

182229
1.3.3
183230
- Adds support for basic authentication
@@ -197,4 +244,4 @@ This plugin requires node 6.10.0
197244
NOTE!
198245
for grafana 2.6 please use [this version](https://github.com/grafana/simple-json-datasource/commit/b78720f6e00c115203d8f4c0e81ccd3c16001f94)
199246

200-
Copy the data source you want to /public/app/plugins/datasource/. Then restart grafana-server. The new data source should now be available in the data source type dropdown in the Add Data Source View.
247+
Copy the data source you want to `/public/app/plugins/datasource/`. Then restart grafana-server. The new data source should now be available in the data source type dropdown in the Add Data Source View.

dist/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Your backend needs to implement 4 urls:
1010
* `/search` used by the find metric options on the query tab in panels.
1111
* `/query` should return metrics based on input.
1212
* `/annotations` should return annotations.
13+
* `/tag-keys` should return tag keys for ad hoc filters.
14+
* `/tag-values` should return tag values for ad hoc filters.
1315

1416
## Installation
1517

@@ -23,6 +25,7 @@ information.
2325

2426
### Example backend implementations
2527
- https://github.com/bergquist/fake-simple-json-datasource
28+
- https://github.com/smcquay/jsonds
2629

2730
### Query API
2831

@@ -48,6 +51,11 @@ Example `timeserie` request
4851
{ "target": "upper_50", "refId": "A", "type": "timeserie" },
4952
{ "target": "upper_75", "refId": "B", "type": "timeserie" }
5053
],
54+
"adhocFilters": [
55+
"key": "City"
56+
"operator": "=",
57+
"value": "Berlin"
58+
]
5159
"format": "json",
5260
"maxDataPoints": 550
5361
}
@@ -160,6 +168,37 @@ Example map response
160168
[ { "text" :"upper_25", "value": 1}, { "text" :"upper_75", "value": 2} ]
161169
```
162170

171+
### Tag Keys API
172+
173+
Example request
174+
``` javascript
175+
{ }
176+
```
177+
178+
The tag keys api returns:
179+
```javascript
180+
[
181+
{"type":"string","text":"City"},
182+
{"type":"string","text":"Country"}
183+
]
184+
```
185+
186+
### Tag Values API
187+
188+
Example request
189+
``` javascript
190+
{"key": "City"}
191+
```
192+
193+
The tag values api returns:
194+
```javascript
195+
[
196+
{'text': 'Eins!'},
197+
{'text': 'Zwei'},
198+
{'text': 'Drei!'}
199+
]
200+
```
201+
163202
### Dev setup
164203

165204
This plugin requires node 6.10.0
@@ -170,6 +209,12 @@ This plugin requires node 6.10.0
170209

171210
### Changelog
172211

212+
1.4.0
213+
214+
- Support for adhoc filters:
215+
- added tag-keys + tag-values api
216+
- added adHocFilters parameter to query body
217+
173218
1.3.5
174219
- Fix for dropdowns in query editor to allow writing template variables (broke due to change in Grafana).
175220

dist/datasource.js

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)