Skip to content

Commit

Permalink
Revert timestamp changes in the /api/infra/metrics_explorer API (elas…
Browse files Browse the repository at this point in the history
…tic#178125)

Closes elastic#171742

## Summary

- Revert timestamp changes related to
https://github.com/elastic/kibana/pull/162542/files#r1275851279
- Removed unused files related to previous preview charts

## 🧪 How to test
Please check this PR carefully!
- Create a custom threshold rule as described
[here](https://github.com/elastic/kibana/blob/main/x-pack/plugins/observability_solution/observability/dev_docs/custom_threshold.md)
and verify:
    - The preview chart in the rule flyout is working as expected
    -  On the alert details page, charts are shown correctly
- In the infra plugin, make sure
    - Metric explorer page works as before
- If you know of any other usage for `/api/infra/metrics_explorer`
please check those as well
  • Loading branch information
maryam-saeidi authored Mar 8, 2024
1 parent f980668 commit 3521732
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 902 deletions.
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 '@kbn/metrics-data-access-plugin/common';
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

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3521732

Please sign in to comment.