Skip to content

Commit

Permalink
Revert timestamp changes for /api/infra/metrics_explorer API in metri…
Browse files Browse the repository at this point in the history
…c_data_access plugin (#178290)

Closes #178283

Not sure how to test this change, any help for testing is appreciated!

Co-authored-by: Kevin Lacabane <[email protected]>
  • Loading branch information
maryam-saeidi and klacabane authored Mar 11, 2024
1 parent 24808a9 commit 111a627
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
17 changes: 3 additions & 14 deletions x-pack/plugins/metrics_data_access/common/http_api/metrics_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,7 @@
import { createLiteralValueFromUndefinedRT } from '@kbn/io-ts-utils';
import * as rt from 'io-ts';
import { MetricsUIAggregationRT } from '../inventory_models/types';
import { afterKeyObjectRT } from './metrics_explorer';

export const MetricsAPITimerangeRT = rt.intersection([
rt.type({
from: rt.number,
to: rt.number,
interval: rt.string,
}),
rt.partial({
timeFieldName: rt.string,
}),
]);
import { afterKeyObjectRT, timeRangeRT } from './metrics_explorer';

const groupByRT = rt.union([rt.string, rt.null, rt.undefined]);

Expand All @@ -30,7 +19,7 @@ export const MetricsAPIMetricRT = rt.type({

export const MetricsAPIRequestRT = rt.intersection([
rt.type({
timerange: MetricsAPITimerangeRT,
timerange: timeRangeRT,
indexPattern: rt.string,
metrics: rt.array(MetricsAPIMetricRT),
includeTimeseries: rt.union([rt.boolean, createLiteralValueFromUndefinedRT(true)]),
Expand Down Expand Up @@ -95,7 +84,7 @@ export const MetricsAPIResponseRT = rt.type({
info: MetricsAPIPageInfoRT,
});

export type MetricsAPITimerange = rt.TypeOf<typeof MetricsAPITimerangeRT>;
export type MetricsAPITimerange = rt.TypeOf<typeof timeRangeRT>;

export type MetricsAPIColumnType = rt.TypeOf<typeof MetricsAPIColumnTypeRT>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,11 @@ export const metricsExplorerMetricRT = rt.intersection([
metricsExplorerMetricOptionalFieldsRT,
]);

export const timeRangeRT = rt.intersection([
rt.type({
from: rt.number,
to: rt.number,
interval: rt.string,
}),
rt.partial({
timeFieldName: rt.string,
}),
]);
export const timeRangeRT = rt.type({
from: rt.number,
to: rt.number,
interval: rt.string,
});

export const metricsExplorerRequestBodyRequiredFieldsRT = rt.type({
timerange: timeRangeRT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const query = async (
const filter: Array<Record<string, any>> = [
{
range: {
[options.timerange.timeFieldName || TIMESTAMP_FIELD]: {
[TIMESTAMP_FIELD]: {
gte: options.timerange.from,
lte: options.timerange.to,
format: 'epoch_millis',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const createMetricHistogramAggs = (options: MetricsAPIRequest): HistogramAggrega
return {
histogram: {
date_histogram: {
field: options.timerange.timeFieldName || TIMESTAMP_FIELD,
field: TIMESTAMP_FIELD,
fixed_interval: intervalString,
offset: options.alignDataToEnd ? calculateDateHistogramOffset(options.timerange) : '0s',
extended_bounds: {
Expand Down

0 comments on commit 111a627

Please sign in to comment.