[release-12.2.4] ElasticSearch: Update annotation time-range properties (#115565)
ElasticSearch: Update annotation time-range properties (#115500)
Update time-range properties
(cherry picked from commit f1b19dd9fa)
Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
This commit is contained in:
co-authored by
Andreas Christou
parent
a9d4b09872
commit
f99c81bf9a
@@ -1000,7 +1000,7 @@ describe('ElasticDatasource', () => {
|
||||
});
|
||||
expect(postResourceRequestMock).toHaveBeenCalledWith(
|
||||
'_msearch',
|
||||
'{"search_type":"query_then_fetch","ignore_unavailable":true,"index":"[test-]YYYY.MM.DD"}\n{"query":{"bool":{"filter":[{"bool":{"should":[{"range":{"@test_time":{"from":1683291160012,"to":1683291460012,"format":"epoch_millis"}}},{"range":{"@time_end_field":{"from":1683291160012,"to":1683291460012,"format":"epoch_millis"}}}],"minimum_should_match":1}},{"query_string":{"query":"abc"}}]}},"size":10000}\n'
|
||||
'{"search_type":"query_then_fetch","ignore_unavailable":true,"index":"[test-]YYYY.MM.DD"}\n{"query":{"bool":{"filter":[{"bool":{"should":[{"range":{"@test_time":{"gte":1683291160012,"lte":1683291460012,"format":"epoch_millis"}}},{"range":{"@time_end_field":{"gte":1683291160012,"lte":1683291460012,"format":"epoch_millis"}}}],"minimum_should_match":1}},{"query_string":{"query":"abc"}}]}},"size":10000}\n'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1030,7 +1030,7 @@ describe('ElasticDatasource', () => {
|
||||
});
|
||||
expect(postResourceRequestMock).toHaveBeenCalledWith(
|
||||
'_msearch',
|
||||
'{"search_type":"query_then_fetch","ignore_unavailable":true,"index":"[test-]YYYY.MM.DD"}\n{"query":{"bool":{"filter":[{"bool":{"should":[{"range":{"@timestamp":{"from":1683291160012,"to":1683291460012,"format":"epoch_millis"}}}],"minimum_should_match":1}}]}},"size":10000}\n'
|
||||
'{"search_type":"query_then_fetch","ignore_unavailable":true,"index":"[test-]YYYY.MM.DD"}\n{"query":{"bool":{"filter":[{"bool":{"should":[{"range":{"@timestamp":{"gte":1683291160012,"lte":1683291460012,"format":"epoch_millis"}}}],"minimum_should_match":1}}]}},"size":10000}\n'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1087,7 +1087,7 @@ describe('ElasticDatasource', () => {
|
||||
});
|
||||
expect(postResourceRequestMock).toHaveBeenCalledWith(
|
||||
'_msearch',
|
||||
'{"search_type":"query_then_fetch","ignore_unavailable":true,"index":"[test-]YYYY.MM.DD"}\n{"query":{"bool":{"filter":[{"bool":{"should":[{"range":{"@test_time":{"from":1683291160012,"to":1683291460012,"format":"epoch_millis"}}},{"range":{"@time_end_field":{"from":1683291160012,"to":1683291460012,"format":"epoch_millis"}}}],"minimum_should_match":1}},{"query_string":{"query":"abc AND abc_key:\\"abc_value\\""}}]}},"size":10000}\n'
|
||||
'{"search_type":"query_then_fetch","ignore_unavailable":true,"index":"[test-]YYYY.MM.DD"}\n{"query":{"bool":{"filter":[{"bool":{"should":[{"range":{"@test_time":{"gte":1683291160012,"lte":1683291460012,"format":"epoch_millis"}}},{"range":{"@time_end_field":{"gte":1683291160012,"lte":1683291460012,"format":"epoch_millis"}}}],"minimum_should_match":1}},{"query_string":{"query":"abc AND abc_key:\\"abc_value\\""}}]}},"size":10000}\n'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -291,8 +291,8 @@ export class ElasticDatasource
|
||||
const dateRanges = [];
|
||||
const rangeStart: RangeMap = {};
|
||||
rangeStart[timeField] = {
|
||||
from: options.range.from.valueOf(),
|
||||
to: options.range.to.valueOf(),
|
||||
gte: options.range.from.valueOf(),
|
||||
lte: options.range.to.valueOf(),
|
||||
format: 'epoch_millis',
|
||||
};
|
||||
dateRanges.push({ range: rangeStart });
|
||||
@@ -300,8 +300,8 @@ export class ElasticDatasource
|
||||
if (timeEndField) {
|
||||
const rangeEnd: RangeMap = {};
|
||||
rangeEnd[timeEndField] = {
|
||||
from: options.range.from.valueOf(),
|
||||
to: options.range.to.valueOf(),
|
||||
gte: options.range.from.valueOf(),
|
||||
lte: options.range.to.valueOf(),
|
||||
format: 'epoch_millis',
|
||||
};
|
||||
dateRanges.push({ range: rangeEnd });
|
||||
|
||||
@@ -135,7 +135,7 @@ export interface ElasticsearchAnnotationQuery {
|
||||
index?: string;
|
||||
}
|
||||
|
||||
export type RangeMap = Record<string, { from: number; to: number; format: string }>;
|
||||
export type RangeMap = Record<string, { gte: number; lte: number; format: string }>;
|
||||
|
||||
export type ElasticsearchResponse = ElasticsearchResponseWithHits | ElasticsearchResponseWithAggregations;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user