mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix for elasticsearch annotations when timestamp is a field and not in source, Fixes #777
This commit is contained in:
parent
4798aa4789
commit
0f88b470e8
@ -16,6 +16,9 @@
|
||||
<div class="dashboard-editor-body">
|
||||
<div class="editor-row row" ng-if="editor.index == 0">
|
||||
<div class="span6">
|
||||
<div ng-if="variables.length === 0">
|
||||
<em>No annotations defined</em>
|
||||
</div>
|
||||
<table class="grafana-options-table">
|
||||
<tr ng-repeat="annotation in annotations">
|
||||
<td style="width:90%">
|
||||
|
@ -76,7 +76,11 @@ function (angular, _, $, config, kbn, moment) {
|
||||
var queryInterpolated = templateSrv.replace(queryString);
|
||||
var filter = { "bool": { "must": [{ "range": range }] } };
|
||||
var query = { "bool": { "should": [{ "query_string": { "query": queryInterpolated } }] } };
|
||||
var data = { "query" : { "filtered": { "query" : query, "filter": filter } }, "size": 100 };
|
||||
var data = {
|
||||
"fields": [timeField, "_source"],
|
||||
"query" : { "filtered": { "query" : query, "filter": filter } },
|
||||
"size": 100
|
||||
};
|
||||
|
||||
return this._request('POST', '/_search', annotation.index, data).then(function(results) {
|
||||
var list = [];
|
||||
@ -84,9 +88,16 @@ function (angular, _, $, config, kbn, moment) {
|
||||
|
||||
for (var i = 0; i < hits.length; i++) {
|
||||
var source = hits[i]._source;
|
||||
var fields = hits[i].fields;
|
||||
var time = source[timeField];
|
||||
|
||||
if (_.isString(fields[timeField]) || _.isNumber(fields[timeField])) {
|
||||
time = fields[timeField];
|
||||
}
|
||||
|
||||
var event = {
|
||||
annotation: annotation,
|
||||
time: moment.utc(source[timeField]).valueOf(),
|
||||
time: moment.utc(time).valueOf(),
|
||||
title: source[titleField],
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user