mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudWatch: Fix cachedQueries insights not being updated for metric queries (#65495)
This commit is contained in:
parent
a18ea77aac
commit
96453c6e69
@ -2,11 +2,12 @@ import Prism, { Grammar } from 'prismjs';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
|
||||
import { AbsoluteTimeRange, HistoryItem, LanguageProvider } from '@grafana/data';
|
||||
import { BackendDataSourceResponse, FetchResponse } from '@grafana/runtime';
|
||||
import { CompletionItemGroup, SearchFunctionType, Token, TypeaheadInput, TypeaheadOutput } from '@grafana/ui';
|
||||
import { getTemplateSrv } from 'app/features/templating/template_srv';
|
||||
|
||||
import { CloudWatchDatasource } from '../../datasource';
|
||||
import { CloudWatchQuery, LogGroup, TSDBResponse } from '../../types';
|
||||
import { CloudWatchQuery, LogGroup } from '../../types';
|
||||
import { interpolateStringArrayUsingSingleOrMultiValuedVariable } from '../../utils/templateVariableUtils';
|
||||
|
||||
import syntax, {
|
||||
@ -49,7 +50,7 @@ export class CloudWatchLogsLanguageProvider extends LanguageProvider {
|
||||
return syntax;
|
||||
}
|
||||
|
||||
request = (url: string, params?: any): Promise<TSDBResponse> => {
|
||||
request = (url: string, params?: any): Promise<FetchResponse<BackendDataSourceResponse>> => {
|
||||
return lastValueFrom(this.datasource.logsQueryRunner.awsRequest(url, params));
|
||||
};
|
||||
|
||||
|
@ -36,7 +36,7 @@ export class CloudWatchAnnotationQueryRunner extends CloudWatchRequest {
|
||||
})),
|
||||
}).pipe(
|
||||
map((r) => {
|
||||
const frames = toDataQueryResponse({ data: r }).data;
|
||||
const frames = toDataQueryResponse(r).data;
|
||||
return { data: frames };
|
||||
})
|
||||
);
|
||||
|
@ -301,7 +301,7 @@ export class CloudWatchLogsQueryRunner extends CloudWatchRequest {
|
||||
return this.awsRequest(this.dsQueryEndpoint, requestParams, {
|
||||
'X-Cache-Skip': 'true',
|
||||
}).pipe(
|
||||
map((response) => resultsToDataFrames({ data: response })),
|
||||
map((response) => resultsToDataFrames(response)),
|
||||
catchError((err: FetchError) => {
|
||||
if (config.featureToggles.datasourceQueryMultiStatus && err.status === 207) {
|
||||
throw err;
|
||||
|
@ -117,12 +117,12 @@ export class CloudWatchMetricsQueryRunner extends CloudWatchRequest {
|
||||
performTimeSeriesQuery(request: MetricRequest, { from, to }: TimeRange): Observable<DataQueryResponse> {
|
||||
return this.awsRequest(this.dsQueryEndpoint, request).pipe(
|
||||
map((res) => {
|
||||
const dataframes: DataFrame[] = toDataQueryResponse({ data: res }).data;
|
||||
const dataframes: DataFrame[] = toDataQueryResponse(res).data;
|
||||
if (!dataframes || dataframes.length <= 0) {
|
||||
return { data: [] };
|
||||
}
|
||||
|
||||
const lastError = findLast(res.results, (v) => !!v.error);
|
||||
const lastError = findLast(res.data.results, (v) => !!v.error);
|
||||
|
||||
dataframes.forEach((frame) => {
|
||||
frame.fields.forEach((field) => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Observable, map } from 'rxjs';
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import { DataSourceInstanceSettings, DataSourceRef, getDataSourceRef, ScopedVars } from '@grafana/data';
|
||||
import { getBackendSrv } from '@grafana/runtime';
|
||||
import { BackendDataSourceResponse, FetchResponse, getBackendSrv } from '@grafana/runtime';
|
||||
import { notifyApp } from 'app/core/actions';
|
||||
import { createErrorNotification } from 'app/core/copy/appNotification';
|
||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||
@ -9,7 +9,7 @@ import { store } from 'app/store/store';
|
||||
import { AppNotificationTimeout } from 'app/types';
|
||||
|
||||
import memoizedDebounce from '../memoizedDebounce';
|
||||
import { CloudWatchJsonData, Dimensions, MetricRequest, MultiFilters, TSDBResponse } from '../types';
|
||||
import { CloudWatchJsonData, Dimensions, MetricRequest, MultiFilters } from '../types';
|
||||
|
||||
export abstract class CloudWatchRequest {
|
||||
templateSrv: TemplateSrv;
|
||||
@ -25,7 +25,11 @@ export abstract class CloudWatchRequest {
|
||||
this.ref = getDataSourceRef(instanceSettings);
|
||||
}
|
||||
|
||||
awsRequest(url: string, data: MetricRequest, headers: Record<string, string> = {}): Observable<TSDBResponse> {
|
||||
awsRequest(
|
||||
url: string,
|
||||
data: MetricRequest,
|
||||
headers: Record<string, string> = {}
|
||||
): Observable<FetchResponse<BackendDataSourceResponse>> {
|
||||
const options = {
|
||||
method: 'POST',
|
||||
url,
|
||||
@ -33,9 +37,7 @@ export abstract class CloudWatchRequest {
|
||||
headers,
|
||||
};
|
||||
|
||||
return getBackendSrv()
|
||||
.fetch<TSDBResponse>(options)
|
||||
.pipe(map((result) => result.data));
|
||||
return getBackendSrv().fetch<BackendDataSourceResponse>(options);
|
||||
}
|
||||
|
||||
convertDimensionFormat(dimensions: Dimensions, scopedVars: ScopedVars): Dimensions {
|
||||
|
Loading…
Reference in New Issue
Block a user