Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export async function getAnnotationRequestParams(
capabilities,
uiSettings,
cachedIndexPatternFetcher,
buildSeriesMetaParams,
}: AnnotationServices
): Promise<EsSearchRequest> {
const annotationIndex = await cachedIndexPatternFetcher(annotation.index_pattern);
Expand All @@ -43,6 +44,7 @@ export async function getAnnotationRequestParams(
annotationIndex,
capabilities,
uiSettings,
getMetaParams: () => buildSeriesMetaParams(annotationIndex, Boolean(panel.use_kibana_indexes)),
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
6 changes: 0 additions & 6 deletions test/functional/apps/visualize/_tsvb_time_series.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down Expand Up @@ -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 = [
{
Expand Down