mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
Elasticsearch: use application/x-ndjson content type for multisearch requests (#32282)
This commit is contained in:
parent
56159a1c43
commit
f7b408f99f
@ -184,7 +184,7 @@ func (c *baseClientImpl) executeRequest(method, uriPath, uriQuery string, body [
|
||||
}
|
||||
|
||||
req.Header.Set("User-Agent", "Grafana")
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Content-Type", "application/x-ndjson")
|
||||
|
||||
if c.ds.BasicAuth {
|
||||
clientLog.Debug("Request configured to use basic authentication")
|
||||
|
@ -366,7 +366,7 @@ func httpClientScenario(t *testing.T, desc string, ds *models.DataSource, fn sce
|
||||
|
||||
sc.requestBody = bytes.NewBuffer(buf)
|
||||
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
rw.Header().Set("Content-Type", "application/x-ndjson")
|
||||
_, err = rw.Write([]byte(sc.responseBody))
|
||||
require.NoError(t, err)
|
||||
rw.WriteHeader(sc.responseStatus)
|
||||
|
@ -23,7 +23,7 @@ import { ElasticResponse } from './elastic_response';
|
||||
import { IndexPattern } from './index_pattern';
|
||||
import { ElasticQueryBuilder } from './query_builder';
|
||||
import { defaultBucketAgg, hasMetricOfType } from './query_def';
|
||||
import { getBackendSrv, getDataSourceSrv } from '@grafana/runtime';
|
||||
import { BackendSrvRequest, getBackendSrv, getDataSourceSrv } from '@grafana/runtime';
|
||||
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
||||
import { DataLinkConfig, ElasticsearchOptions, ElasticsearchQuery } from './types';
|
||||
import { RowContextOptions } from '@grafana/ui/src/components/Logs/LogRowContextProvider';
|
||||
@ -104,11 +104,17 @@ export class ElasticDatasource extends DataSourceApi<ElasticsearchQuery, Elastic
|
||||
this.languageProvider = new LanguageProvider(this);
|
||||
}
|
||||
|
||||
private request(method: string, url: string, data?: undefined): Observable<any> {
|
||||
const options: any = {
|
||||
private request(
|
||||
method: string,
|
||||
url: string,
|
||||
data?: undefined,
|
||||
headers?: BackendSrvRequest['headers']
|
||||
): Observable<any> {
|
||||
const options: BackendSrvRequest = {
|
||||
url: this.url + '/' + url,
|
||||
method: method,
|
||||
data: data,
|
||||
method,
|
||||
data,
|
||||
headers,
|
||||
};
|
||||
|
||||
if (this.basicAuth || this.withCredentials) {
|
||||
@ -192,7 +198,7 @@ export class ElasticDatasource extends DataSourceApi<ElasticsearchQuery, Elastic
|
||||
}
|
||||
|
||||
private post(url: string, data: any): Observable<any> {
|
||||
return this.request('POST', url, data);
|
||||
return this.request('POST', url, data, { 'Content-Type': 'application/x-ndjson' });
|
||||
}
|
||||
|
||||
annotationQuery(options: any): Promise<any> {
|
||||
|
Loading…
Reference in New Issue
Block a user