Skip to content

[Backport 2.14] Backport prometheus fix to 2.x #1793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 1, 2024
Merged
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
33 changes: 28 additions & 5 deletions public/components/custom_panels/helpers/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { Moment } from 'moment-timezone';
import React from 'react';
import { Layout } from 'react-grid-layout';
import { CoreStart } from '../../../../../../src/core/public';
import { CoreStart, SavedObjectAttributes } from '../../../../../../src/core/public';
import { PPL_INDEX_REGEX, PPL_WHERE_CLAUSE_REGEX } from '../../../../common/constants/shared';
import { QueryManager } from '../../../../common/query_manager';
import {
Expand Down Expand Up @@ -307,7 +307,7 @@

// Creates a catalogVisualization for a runtime catalog based PPL query and runs getQueryResponse
export const renderCatalogVisualization = async ({
http,

Check failure on line 310 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

'http' is defined but never used. Allowed unused args must match /^_/u
pplService,
catalogSource,
startTime,
Expand All @@ -321,7 +321,7 @@
setVisualizationMetaData,
setIsLoading,
setIsError,
spanResolution,

Check failure on line 324 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

'spanResolution' is defined but never used. Allowed unused args must match /^_/u
visualization,
}: {
http: CoreStart['http'];
Expand All @@ -347,7 +347,7 @@

const visualizationType = 'line';
const visualizationTimeField = '@timestamp';
const visualizationSubType = visualization.subType;

Check failure on line 350 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

'visualizationSubType' is assigned a value but never used. Allowed unused vars must match /^_/u

const visualizationQuery = updateCatalogVisualizationQuery({
...visualization.queryMetaData,
Expand Down Expand Up @@ -482,7 +482,7 @@
return true;
};

export const processMetricsData = (schema: any, dataConfig: any) => {

Check warning on line 485 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 485 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
if (isEmpty(schema)) return {};
if (
schema.length === 3 &&
Expand All @@ -493,10 +493,10 @@
return {};
};

export const prepareMetricsData = (schema: any, dataConfig: any) => {

Check warning on line 496 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check failure on line 496 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

'dataConfig' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 496 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const metricBreakdown: any[] = [];

Check warning on line 497 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const metricSeries: any[] = [];

Check warning on line 498 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const metricDimension: any[] = [];

Check warning on line 499 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

forEach(schema, (field) => {
if (field.name === '@timestamp')
Expand All @@ -513,16 +513,39 @@
};
};

export const constructOtelMetricsMetaData = () => {
const otelMetricSeries: any[] = [];

Check warning on line 517 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
const otelMetricDimension: any[] = [];

Check warning on line 518 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

otelMetricDimension.push({ name: 'xAxis', label: 'xAxis', customLabel: '' });
otelMetricSeries.push({ name: '', label: '', aggregation: 'count', customLabel: '' });

return {
series: otelMetricSeries,
dimensions: otelMetricDimension,
span: {},
};
};

export const parseMetadataUserConfig = (
userConfigs?: string | SavedObjectAttributes
): SavedObjectAttributes => {
if (userConfigs === undefined || userConfigs === '') {
return {};
} else if (typeof userConfigs === 'string') {
return JSON.parse(userConfigs);
} else {
return userConfigs;
}
};

// Renders visualization in the vizualization container component
export const displayVisualization = (metaData: any, data: any, type: string) => {

Check warning on line 543 in public/components/custom_panels/helpers/utils.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
if (metaData === undefined || isEmpty(metaData)) {
return <></>;
}

if (metaData.userConfigs !== undefined && metaData.userConfigs !== '') {
metaData.userConfigs = JSON.parse(metaData.userConfigs);
}

metaData.userConfigs = parseMetadataUserConfig(metaData.userConfigs);
const dataConfig = { ...(metaData.userConfigs?.dataConfig || {}) };
const hasBreakdowns = !_.isEmpty(dataConfig.breakdowns);
const realTimeParsedStats = {
Expand Down
Loading