docs(datasource): add request objects to docs

This commit is contained in:
bergquist 2016-03-04 08:45:46 +01:00
parent 1d8222ef6a
commit c21a210198
2 changed files with 72 additions and 2 deletions

View File

@ -24,7 +24,7 @@ There are two datasource specific settings for the plugin.json
"metrics": true,
"annotations": false,
```
These settings idicates what kind of data the plugin can deliver. Atleast one of them have to be true
These settings indicates what kind of data the plugin can deliver. At least one of them have to be true
## Datasource
The javascript object that communicates with the database and transforms data to times series.
@ -37,6 +37,75 @@ annotationsQuery(options) // used dashboards to get annotations
metricFindQuery(options) // used by query editor to get metric suggestions.
```
### Query
Request object passed to datasource.query function
```json
{
range: { from: '2015-12-22T03:06:13.851Z',to: '2015-12-22T06:48:24.137Z' },
interval: '5s',
targets:
[ { refId: 'B', target: 'upper_75' },
{ refId: 'A', target: 'upper_90' } ],
format: 'json',
maxDataPoints: 2495 //decided by the panel
}
```
Expected response from datasource.query
An array of
```json
[
{
"target":"upper_75",
"datapoints":[
[622,1450754160000],
[365,1450754220000]
]
},
{
"target":"upper_90",
"datapoints":[
[861,1450754160000],
[767,1450754220000]
]
}
]
```
### Annotation Query
Request object passed to datasource.annotationsQuery function
```json
{
range: { from: '2016-03-04T04:07:55.144Z', to: '2016-03-04T07:07:55.144Z' },
rangeRaw: { from: 'now-3h', to: 'now' },
annotation: {
datasource: 'generic datasource',
enable: true,
name: 'annotation name'
}
}
```
Expected result from datasource.annotationQuery
```json
[
{
"annotation": {
"name": "annotation name", //should match the annotation name in grafana
"enabled": true,
"datasource": "generic datasource",
},
"title": "Cluster outage",
"time": 1457075272576,
"text": "Joe causes brain split",
"tags": "joe, cluster, failure"
}
]
```
## QueryCtrl
A javascript class that will be instantiated and treated as an Angular controller when the user edits metrics in a panel. This class have to inherit from the app/plugins/sdk.QueryCtrl class.

View File

@ -40,7 +40,8 @@ export class GenericDatasource {
annotationQuery(options) {
return this.backendSrv.datasourceRequest({
url: this.url + '/annotations',
method: 'GET'
method: 'POST',
data: options
}).then(result => {
return result.data;
});