fix performance issue in processHistogramLabels() (#25813)

pull/24175/head
Bruce Sherrod 5 years ago committed by GitHub
parent 7f587b209f
commit af0c73720e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      public/app/plugins/datasource/prometheus/language_utils.ts

@ -4,17 +4,16 @@ import { addLabelToQuery } from './add_label_to_query';
export const RATE_RANGES = ['1m', '5m', '10m', '30m', '1h'];
export const processHistogramLabels = (labels: string[]) => {
const result = [];
const resultSet: Set<string> = new Set();
const regexp = new RegExp('_bucket($|:)');
for (let index = 0; index < labels.length; index++) {
const label = labels[index];
const isHistogramValue = regexp.test(label);
if (isHistogramValue) {
if (result.indexOf(label) === -1) {
result.push(label);
}
resultSet.add(label);
}
}
const result = [...resultSet];
return { values: { __name__: result } };
};

Loading…
Cancel
Save