mirror of
https://github.com/grafana/grafana.git
synced 2024-12-02 05:29:42 -06:00
prometheus: fix regression after adding support for tracing headers (#16829)
This fixes a regression introduced by #16724 when datasource is configured to use HTTP method POST and testing the datasource which results in an 'options.headers is undefined'. Same error probably happens if datasource is configured to use basic auth and testing datasource.
This commit is contained in:
parent
157f330cf2
commit
9d01b216f9
@ -72,6 +72,7 @@ export class PrometheusDatasource implements DataSourceApi<PromQuery> {
|
||||
options = _.defaults(options || {}, {
|
||||
url: this.url + url,
|
||||
method: this.httpMethod,
|
||||
headers: {},
|
||||
});
|
||||
|
||||
if (options.method === 'GET') {
|
||||
|
@ -57,6 +57,7 @@ describe('PrometheusMetricFindQuery', () => {
|
||||
method: 'GET',
|
||||
url: 'proxied/api/v1/labels',
|
||||
silent: true,
|
||||
headers: {},
|
||||
});
|
||||
});
|
||||
|
||||
@ -75,6 +76,7 @@ describe('PrometheusMetricFindQuery', () => {
|
||||
method: 'GET',
|
||||
url: 'proxied/api/v1/label/resource/values',
|
||||
silent: true,
|
||||
headers: {},
|
||||
});
|
||||
});
|
||||
|
||||
@ -97,6 +99,7 @@ describe('PrometheusMetricFindQuery', () => {
|
||||
method: 'GET',
|
||||
url: `proxied/api/v1/series?match[]=metric&start=${raw.from.unix()}&end=${raw.to.unix()}`,
|
||||
silent: true,
|
||||
headers: {},
|
||||
});
|
||||
});
|
||||
|
||||
@ -121,6 +124,7 @@ describe('PrometheusMetricFindQuery', () => {
|
||||
'metric{label1="foo", label2="bar", label3="baz"}'
|
||||
)}&start=${raw.from.unix()}&end=${raw.to.unix()}`,
|
||||
silent: true,
|
||||
headers: {},
|
||||
});
|
||||
});
|
||||
|
||||
@ -145,6 +149,7 @@ describe('PrometheusMetricFindQuery', () => {
|
||||
method: 'GET',
|
||||
url: `proxied/api/v1/series?match[]=metric&start=${raw.from.unix()}&end=${raw.to.unix()}`,
|
||||
silent: true,
|
||||
headers: {},
|
||||
});
|
||||
});
|
||||
|
||||
@ -163,6 +168,7 @@ describe('PrometheusMetricFindQuery', () => {
|
||||
method: 'GET',
|
||||
url: 'proxied/api/v1/label/__name__/values',
|
||||
silent: true,
|
||||
headers: {},
|
||||
});
|
||||
});
|
||||
|
||||
@ -190,6 +196,7 @@ describe('PrometheusMetricFindQuery', () => {
|
||||
method: 'GET',
|
||||
url: `proxied/api/v1/query?query=metric&time=${raw.to.unix()}`,
|
||||
requestId: undefined,
|
||||
headers: {},
|
||||
});
|
||||
});
|
||||
|
||||
@ -217,6 +224,7 @@ describe('PrometheusMetricFindQuery', () => {
|
||||
'up{job="job1"}'
|
||||
)}&start=${raw.from.unix()}&end=${raw.to.unix()}`,
|
||||
silent: true,
|
||||
headers: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user