mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: Default support labels value endpoint with match param when prom type and version not set (#84778)
* default to support labels match endpoint * add test and fix tests
This commit is contained in:
committed by
GitHub
parent
e233c963a3
commit
c4645c81da
@@ -24,7 +24,7 @@ import {
|
||||
prometheusSpecialRegexEscape,
|
||||
} from './datasource';
|
||||
import PromQlLanguageProvider from './language_provider';
|
||||
import { PrometheusCacheLevel, PromOptions, PromQuery, PromQueryRequest } from './types';
|
||||
import { PromApplication, PrometheusCacheLevel, PromOptions, PromQuery, PromQueryRequest } from './types';
|
||||
|
||||
const fetchMock = jest.fn().mockReturnValue(of(createDefaultPromResponse()));
|
||||
|
||||
@@ -98,6 +98,13 @@ describe('PrometheusDatasource', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Type and version', () => {
|
||||
it('Default support labels match endpoint over series when type and version not set', () => {
|
||||
const labelsMatchSupport = ds.hasLabelsMatchAPISupport();
|
||||
expect(labelsMatchSupport).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Query', () => {
|
||||
it('throws if using direct access', async () => {
|
||||
const instanceSettings = {
|
||||
@@ -108,6 +115,8 @@ describe('PrometheusDatasource', () => {
|
||||
access: 'direct',
|
||||
jsonData: {
|
||||
customQueryParameters: '',
|
||||
prometheusVersion: '2.20.0',
|
||||
prometheusType: PromApplication.Prometheus,
|
||||
},
|
||||
} as unknown as DataSourceInstanceSettings<PromOptions>;
|
||||
const range = { from: time({ seconds: 63 }), to: time({ seconds: 183 }) };
|
||||
|
||||
@@ -189,9 +189,9 @@ export class PrometheusDatasource
|
||||
}
|
||||
|
||||
_isDatasourceVersionGreaterOrEqualTo(targetVersion: string, targetFlavor: PromApplication): boolean {
|
||||
// User hasn't configured flavor/version yet, default behavior is to not support features that require version configuration when not provided
|
||||
// User hasn't configured flavor/version yet, default behavior is to support labels match api support
|
||||
if (!this.datasourceConfigurationPrometheusVersion || !this.datasourceConfigurationPrometheusFlavor) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (targetFlavor !== this.datasourceConfigurationPrometheusFlavor) {
|
||||
|
||||
@@ -23,7 +23,11 @@ const instanceSettings = {
|
||||
uid: 'ABCDEF',
|
||||
user: 'test',
|
||||
password: 'mupp',
|
||||
jsonData: { httpMethod: 'GET' },
|
||||
jsonData: {
|
||||
httpMethod: 'GET',
|
||||
prometheusVersion: '2.20.0',
|
||||
prometheusType: PromApplication.Prometheus,
|
||||
},
|
||||
} as Partial<DataSourceInstanceSettings<PromOptions>> as DataSourceInstanceSettings<PromOptions>;
|
||||
|
||||
const raw: TimeRange = {
|
||||
|
||||
Reference in New Issue
Block a user