mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[TSVB] Use panel interval for annotations (#125222)
This commit is contained in:
parent
617a602c5d
commit
5babc9f663
4 changed files with 18 additions and 7 deletions
|
@ -31,6 +31,7 @@ export async function getAnnotationRequestParams(
|
|||
capabilities,
|
||||
uiSettings,
|
||||
cachedIndexPatternFetcher,
|
||||
buildSeriesMetaParams,
|
||||
}: AnnotationServices
|
||||
): Promise<EsSearchRequest> {
|
||||
const annotationIndex = await cachedIndexPatternFetcher(annotation.index_pattern);
|
||||
|
@ -43,6 +44,7 @@ export async function getAnnotationRequestParams(
|
|||
annotationIndex,
|
||||
capabilities,
|
||||
uiSettings,
|
||||
getMetaParams: () => buildSeriesMetaParams(annotationIndex, Boolean(panel.use_kibana_indexes)),
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
@ -23,16 +23,26 @@ export const dateHistogram: AnnotationsRequestProcessorsFunction = ({
|
|||
annotationIndex,
|
||||
capabilities,
|
||||
uiSettings,
|
||||
getMetaParams,
|
||||
}) => {
|
||||
return (next) => async (doc) => {
|
||||
const maxBarsUiSettings = await uiSettings.get(UI_SETTINGS.HISTOGRAM_MAX_BARS);
|
||||
const barTargetUiSettings = await uiSettings.get(UI_SETTINGS.HISTOGRAM_BAR_TARGET);
|
||||
const timeField = annotation.time_field || annotationIndex.indexPattern?.timeFieldName || '';
|
||||
const { interval, maxBars } = await getMetaParams();
|
||||
|
||||
if (panel.use_kibana_indexes) {
|
||||
validateField(timeField, annotationIndex);
|
||||
}
|
||||
|
||||
const { bucketSize, intervalString } = getBucketSize(
|
||||
req,
|
||||
interval,
|
||||
capabilities,
|
||||
maxBars ? Math.min(maxBarsUiSettings, maxBars) : barTargetUiSettings
|
||||
);
|
||||
|
||||
const { bucketSize: autoBucketSize, intervalString: autoIntervalString } = getBucketSize(
|
||||
req,
|
||||
'auto',
|
||||
capabilities,
|
||||
|
@ -49,7 +59,7 @@ export const dateHistogram: AnnotationsRequestProcessorsFunction = ({
|
|||
min: from.valueOf(),
|
||||
max: to.valueOf() - bucketSize * 1000,
|
||||
},
|
||||
...dateHistogramInterval(intervalString),
|
||||
...dateHistogramInterval(autoBucketSize < bucketSize ? autoIntervalString : intervalString),
|
||||
});
|
||||
return next(doc);
|
||||
};
|
||||
|
|
|
@ -22,6 +22,11 @@ export interface AnnotationsRequestProcessorsParams {
|
|||
annotationIndex: FetchedIndexPattern;
|
||||
capabilities: SearchCapabilities;
|
||||
uiSettings: IUiSettingsClient;
|
||||
getMetaParams: () => Promise<{
|
||||
maxBars: number;
|
||||
timeField?: string | undefined;
|
||||
interval: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
export type AnnotationSearchRequest = Record<string, unknown>;
|
||||
|
|
|
@ -468,12 +468,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
await visualBuilder.setAnnotationFilter('geo.dest : "AW" or geo.src : "AM"');
|
||||
await visualBuilder.setAnnotationFields('extension.raw');
|
||||
await visualBuilder.setAnnotationRowTemplate('extension: {{extension.raw}}');
|
||||
|
||||
const annotationsData = await visualBuilder.getAnnotationsData();
|
||||
|
||||
expect(annotationsData).to.eql(expectedAnnotationsData);
|
||||
});
|
||||
|
||||
it('should display correct annotations data for machine.os.raw and memory fields', async () => {
|
||||
const expectedAnnotationsData = [
|
||||
{
|
||||
|
@ -512,12 +509,9 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
|
|||
await visualBuilder.setAnnotationRowTemplate(
|
||||
'OS: {{machine.os.raw}}, memory: {{memory}}'
|
||||
);
|
||||
|
||||
const annotationsData = await visualBuilder.getAnnotationsData();
|
||||
|
||||
expect(annotationsData).to.eql(expectedAnnotationsData);
|
||||
});
|
||||
|
||||
it('should display correct annotations data when using runtime field', async () => {
|
||||
const expectedAnnotationsData = [
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue