Commit d9fea07e by Sofia Papagiannaki Committed by GitHub

Graphite: use POST for /metrics/find requests (#17814)

* Add test that expects a POST request

* Change graphite /metric/find request to POST

Query parameter can become large enough
to exceed GET URI limits.

* Fix requests with time range

Initialise httpOptions.params

* Fix for supporting queries referencing template variable
parent 70d4dfe9
......@@ -245,10 +245,12 @@ export function GraphiteDatasource(this: any, instanceSettings, $q, backendSrv,
}
const httpOptions: any = {
method: 'GET',
method: 'POST',
url: '/metrics/find',
params: {
query: interpolatedQuery,
params: {},
data: `query=${interpolatedQuery}`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
// for cancellations
requestId: options.requestId,
......
......@@ -303,6 +303,18 @@ describe('graphiteDatasource', () => {
expect(requestOptions.params.expr).toEqual(['server=~backend*']);
expect(results).not.toBe(null);
});
it('/metrics/find should be POST', () => {
ctx.templateSrv.setGrafanaVariable('foo', 'bar');
ctx.ds.metricFindQuery('[[foo]]').then(data => {
results = data;
});
expect(requestOptions.url).toBe('/api/datasources/proxy/1/metrics/find');
expect(requestOptions.method).toEqual('POST');
expect(requestOptions.headers).toHaveProperty('Content-Type', 'application/x-www-form-urlencoded');
expect(requestOptions.data).toMatch(`query=bar`);
expect(requestOptions).toHaveProperty('params');
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment