Skip to content

fix prometheus response parsing issue #1757

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
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
17 changes: 13 additions & 4 deletions public/components/custom_panels/helpers/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@
setVisualizationMetaData: React.Dispatch<React.SetStateAction<undefined>>;
setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
setIsError: React.Dispatch<React.SetStateAction<VizContainerError>>;
visualization: any;

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

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
setToast: (
title: string,
color?: string,
Expand Down Expand Up @@ -526,7 +526,7 @@
setVisualizationType(visualizationType);
setVisualizationTitle(source.name);

const dataBinsPromises = source.buckets.map(async (bucket: any) => {

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

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
try {
const formattedStartTime = convertDateTime(startTime, false, false, OTEL_METRIC_SUBTYPE);
const formattedEndTime = convertDateTime(endTime, false, false, OTEL_METRIC_SUBTYPE);
Expand Down Expand Up @@ -659,7 +659,7 @@
return true;
};

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

Check warning on line 662 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 @@ -670,10 +670,10 @@
return {};
};

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

Check warning on line 673 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 674 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 675 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 676 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 @@ -691,8 +691,8 @@
};

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

Check warning on line 694 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 695 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: '' });
Expand All @@ -704,16 +704,25 @@
};
};

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 720 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