Skip to content

Commit

Permalink
[Metrics UI] Fix ignoreLookback behavior for Snapshot API (elastic#91169
Browse files Browse the repository at this point in the history
) (elastic#91708)

* [Metrics UI] Fix ignore lookback behavoir for Snapshot API

* Removing unused dependancies

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
simianhacker and kibanamachine authored Feb 17, 2021
1 parent b8908af commit f9785ec
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { uniq } from 'lodash';
import { InfraTimerangeInput } from '../../../../common/http_api';
import { ESSearchClient } from '../../../lib/metrics/types';
import { getIntervalInSeconds } from '../../../utils/get_interval_in_seconds';
import { calculateMetricInterval } from '../../../utils/calculate_metric_interval';
import { getMetricsAggregations, InfraSnapshotRequestOptions } from './get_metrics_aggregations';
import {
Expand All @@ -19,9 +18,6 @@ import { getDatasetForField } from '../../metrics_explorer/lib/get_dataset_for_f

const createInterval = async (client: ESSearchClient, options: InfraSnapshotRequestOptions) => {
const { timerange } = options;
if (timerange.forceInterval && timerange.interval) {
return getIntervalInSeconds(timerange.interval);
}
const aggregations = getMetricsAggregations(options);
const modules = await aggregationsToModules(client, aggregations, options);
return Math.max(
Expand All @@ -44,14 +40,21 @@ export const createTimeRangeWithInterval = async (
options: InfraSnapshotRequestOptions
): Promise<InfraTimerangeInput> => {
const { timerange } = options;
const calculatedInterval = await createInterval(client, options);
if (timerange.forceInterval) {
return {
interval: timerange.interval,
from: timerange.from,
to: timerange.to,
};
}
if (timerange.ignoreLookback) {
return {
interval: `${calculatedInterval}s`,
interval: 'modules',
from: timerange.from,
to: timerange.to,
};
}
const calculatedInterval = await createInterval(client, options);
const lookbackSize = Math.max(timerange.lookbackSize || 5, 5);
return {
interval: `${calculatedInterval}s`,
Expand Down

0 comments on commit f9785ec

Please sign in to comment.