mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
Elasticsearch: Handle multiple annotation structures (#66762)
elastic: fix annotation handling
This commit is contained in:
parent
3edc246ca3
commit
82ac2bae5f
@ -23,9 +23,15 @@ export function ElasticsearchAnnotationsQueryEditor(props: Props) {
|
|||||||
<ElasticSearchQueryField
|
<ElasticSearchQueryField
|
||||||
value={annotation.target?.query}
|
value={annotation.target?.query}
|
||||||
onChange={(query) => {
|
onChange={(query) => {
|
||||||
|
const currentTarget = annotation.target ?? { refId: 'annotation_query' };
|
||||||
|
const newTarget = {
|
||||||
|
...currentTarget,
|
||||||
|
query,
|
||||||
|
};
|
||||||
|
|
||||||
onAnnotationChange({
|
onAnnotationChange({
|
||||||
...annotation,
|
...annotation,
|
||||||
query,
|
target: newTarget,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -257,7 +257,17 @@ export class ElasticDatasource
|
|||||||
const annotation = options.annotation;
|
const annotation = options.annotation;
|
||||||
const timeField = annotation.timeField || '@timestamp';
|
const timeField = annotation.timeField || '@timestamp';
|
||||||
const timeEndField = annotation.timeEndField || null;
|
const timeEndField = annotation.timeEndField || null;
|
||||||
const queryString = annotation.query;
|
|
||||||
|
// the `target.query` is the "new" location for the query.
|
||||||
|
// normally we would write this code as
|
||||||
|
// try-the-new-place-then-try-the-old-place,
|
||||||
|
// but we had the bug at
|
||||||
|
// https://github.com/grafana/grafana/issues/61107
|
||||||
|
// that may have stored annotations where
|
||||||
|
// both the old and the new place are set,
|
||||||
|
// and in that scenario the old place needs
|
||||||
|
// to have priority.
|
||||||
|
const queryString = annotation.query ?? annotation.target?.query;
|
||||||
const tagsField = annotation.tagsField || 'tags';
|
const tagsField = annotation.tagsField || 'tags';
|
||||||
const textField = annotation.textField || null;
|
const textField = annotation.textField || null;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user