mirror of
https://github.com/grafana/grafana.git
synced 2025-01-10 08:03:58 -06:00
Merge pull request #4296 from knowroozi/opentsdb_annotations
add annotations for opentsdb
This commit is contained in:
commit
ac439d83fe
@ -69,6 +69,40 @@ function (angular, _, dateMath) {
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
this.annotationQuery = function(options) {
|
||||
var start = convertToTSDBTime(options.rangeRaw.from, false);
|
||||
var end = convertToTSDBTime(options.rangeRaw.to, true);
|
||||
var qs = [];
|
||||
var eventList = [];
|
||||
|
||||
qs.push({ aggregator:"sum", metric:options.annotation.target });
|
||||
|
||||
var queries = _.compact(qs);
|
||||
|
||||
return this.performTimeSeriesQuery(queries, start, end).then(function(results) {
|
||||
if(results.data[0]) {
|
||||
var annotationObject = results.data[0].annotations;
|
||||
if(options.annotation.isGlobal){
|
||||
annotationObject = results.data[0].globalAnnotations;
|
||||
}
|
||||
if(annotationObject) {
|
||||
_.each(annotationObject, function(annotation) {
|
||||
var event = {
|
||||
title: annotation.description,
|
||||
time: Math.floor(annotation.startTime) * 1000,
|
||||
text: annotation.notes,
|
||||
annotation: options.annotation
|
||||
};
|
||||
|
||||
eventList.push(event);
|
||||
});
|
||||
}
|
||||
}
|
||||
return eventList;
|
||||
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
this.performTimeSeriesQuery = function(queries, start, end) {
|
||||
var msResolution = false;
|
||||
if (this.tsdbResolution === 2) {
|
||||
@ -77,7 +111,8 @@ function (angular, _, dateMath) {
|
||||
var reqBody = {
|
||||
start: start,
|
||||
queries: queries,
|
||||
msResolution: msResolution
|
||||
msResolution: msResolution,
|
||||
globalAnnotations: true
|
||||
};
|
||||
|
||||
// Relative queries (e.g. last hour) don't include an end time
|
||||
|
@ -2,9 +2,13 @@ import {OpenTsDatasource} from './datasource';
|
||||
import {OpenTsQueryCtrl} from './query_ctrl';
|
||||
import {OpenTsConfigCtrl} from './config_ctrl';
|
||||
|
||||
class AnnotationsQueryCtrl {
|
||||
static templateUrl = 'partials/annotations.editor.html';
|
||||
}
|
||||
|
||||
export {
|
||||
OpenTsDatasource as Datasource,
|
||||
OpenTsQueryCtrl as QueryCtrl,
|
||||
OpenTsConfigCtrl as ConfigCtrl,
|
||||
AnnotationsQueryCtrl as AnnotationsQueryCtrl
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
<div class="gf-form-group">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-13">OpenTSDB metrics query</span>
|
||||
<input type="text" class="gf-form-input" ng-model='ctrl.annotation.target' placeholder="events.eventname"></input>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-13">Show Global Annotations?</span>
|
||||
<editor-checkbox text="" model="ctrl.annotation.isGlobal"></editor-checkbox>
|
||||
</div>
|
||||
</div>
|
@ -4,5 +4,6 @@
|
||||
"id": "opentsdb",
|
||||
|
||||
"metrics": true,
|
||||
"defaultMatchFormat": "pipe"
|
||||
"defaultMatchFormat": "pipe",
|
||||
"annotations": true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user