Prometheus: Only use the series endpoint in the metrics browser (#81419)

* only use the series endpoint in the metrics browser

* Update public/app/plugins/datasource/prometheus/components/PrometheusMetricsBrowser.test.tsx

Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>

---------

Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>
This commit is contained in:
Brendan O'Handley 2024-01-29 07:56:45 -06:00 committed by GitHub
parent 329440cb1e
commit b625d60aa9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -114,7 +114,13 @@ describe('PrometheusMetricsBrowser', () => {
}
return [];
},
fetchLabelsWithMatch: (selector: string) => {
// This must always call the series endpoint
// until we refactor all of the metrics browser
// to never use the series endpoint.
// The metrics browser expects both label names and label values.
// The labels endpoint with match does not supply label values
// and so using it breaks the metrics browser.
fetchSeriesLabels: (selector: string) => {
switch (selector) {
case '{label1="value1-1"}':
return { label1: ['value1-1'], label2: ['value2-1'], label3: ['value3-1'] };

View File

@ -415,7 +415,7 @@ export class UnthemedPrometheusMetricsBrowser extends React.Component<BrowserPro
this.updateLabelState(lastFacetted, { loading: true }, `Facetting labels for ${selector}`);
}
try {
const possibleLabels = await languageProvider.fetchLabelsWithMatch(selector, true);
const possibleLabels = await languageProvider.fetchSeriesLabels(selector, true);
// If selector changed, clear loading state and discard result by returning early
if (selector !== buildSelector(this.state.labels)) {
if (lastFacetted) {