mirror of
https://github.com/grafana/grafana.git
synced 2026-09-05 04:40:13 -05:00
Use resource call query_result query (#57232)
This commit is contained in:
@@ -751,6 +751,7 @@ const time = ({ hours = 0, seconds = 0, minutes = 0 }) => dateTime(hours * HOUR
|
||||
describe('PrometheusDatasource2', () => {
|
||||
const instanceSettings = {
|
||||
url: 'proxied',
|
||||
id: 1,
|
||||
directUrl: 'direct',
|
||||
user: 'test',
|
||||
password: 'mupp',
|
||||
@@ -913,7 +914,9 @@ describe('PrometheusDatasource2', () => {
|
||||
|
||||
describe('When querying prometheus with one target and instant = true', () => {
|
||||
let results: any;
|
||||
const urlExpected = `proxied/api/v1/query?query=${encodeURIComponent('test{job="testjob"}')}&time=123`;
|
||||
const urlExpected = `/api/datasources/1/resources/api/v1/query?query=${encodeURIComponent(
|
||||
'test{job="testjob"}'
|
||||
)}&time=123`;
|
||||
const query = {
|
||||
range: { from: time({ seconds: 63 }), to: time({ seconds: 123 }) },
|
||||
targets: [{ expr: 'test{job="testjob"}', format: 'time_series', instant: true }],
|
||||
|
||||
@@ -642,10 +642,14 @@ export class PrometheusDatasource
|
||||
data['timeout'] = this.queryTimeout;
|
||||
}
|
||||
|
||||
return this._request<PromDataSuccessResponse<PromVectorData | PromScalarData>>(url, data, {
|
||||
requestId: query.requestId,
|
||||
headers: query.headers,
|
||||
}).pipe(
|
||||
return this._request<PromDataSuccessResponse<PromVectorData | PromScalarData>>(
|
||||
`/api/datasources/${this.id}/resources${url}`,
|
||||
data,
|
||||
{
|
||||
requestId: query.requestId,
|
||||
headers: query.headers,
|
||||
}
|
||||
).pipe(
|
||||
catchError((err: FetchError<PromDataErrorResponse<PromVectorData | PromScalarData>>) => {
|
||||
if (err.cancelled) {
|
||||
return of(err);
|
||||
|
||||
@@ -221,7 +221,7 @@ describe('PrometheusMetricFindQuery', () => {
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
expect(fetchMock).toHaveBeenCalledWith({
|
||||
method: 'GET',
|
||||
url: `proxied/api/v1/query?query=metric&time=${raw.to.unix()}`,
|
||||
url: `/api/datasources/1/resources/api/v1/query?query=metric&time=${raw.to.unix()}`,
|
||||
requestId: undefined,
|
||||
headers: {},
|
||||
});
|
||||
@@ -243,7 +243,7 @@ describe('PrometheusMetricFindQuery', () => {
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
expect(fetchMock).toHaveBeenCalledWith({
|
||||
method: 'GET',
|
||||
url: `proxied/api/v1/query?query=1%2B1&time=${raw.to.unix()}`,
|
||||
url: `/api/datasources/1/resources/api/v1/query?query=1%2B1&time=${raw.to.unix()}`,
|
||||
requestId: undefined,
|
||||
headers: {},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user