mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudWatch: remove usage of TimeSrv (#79096)
This commit is contained in:
parent
c995e5e839
commit
508fbc8f5b
@ -9,7 +9,6 @@ import {
|
|||||||
VariableHide,
|
VariableHide,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { getBackendSrv, setBackendSrv, DataSourceWithBackend } from '@grafana/runtime';
|
import { getBackendSrv, setBackendSrv, DataSourceWithBackend } from '@grafana/runtime';
|
||||||
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
|
||||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
import { initialCustomVariableModelState } from 'app/features/variables/custom/reducer';
|
import { initialCustomVariableModelState } from 'app/features/variables/custom/reducer';
|
||||||
|
|
||||||
@ -80,8 +79,7 @@ export function setupMockedDataSource({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeSrv = getTimeSrv();
|
const datasource = new CloudWatchDatasource(customInstanceSettings, templateService);
|
||||||
const datasource = new CloudWatchDatasource(customInstanceSettings, templateService, timeSrv);
|
|
||||||
datasource.getVariables = () => ['test'];
|
datasource.getVariables = () => ['test'];
|
||||||
datasource.resources.getNamespaces = jest.fn().mockResolvedValue([]);
|
datasource.resources.getNamespaces = jest.fn().mockResolvedValue([]);
|
||||||
datasource.resources.getRegions = jest.fn().mockResolvedValue([]);
|
datasource.resources.getRegions = jest.fn().mockResolvedValue([]);
|
||||||
@ -96,7 +94,7 @@ export function setupMockedDataSource({
|
|||||||
get: getMock,
|
get: getMock,
|
||||||
});
|
});
|
||||||
|
|
||||||
return { datasource, fetchMock, queryMock, templateService, timeSrv };
|
return { datasource, fetchMock, queryMock, templateService };
|
||||||
}
|
}
|
||||||
|
|
||||||
export const metricVariable: CustomVariableModel = {
|
export const metricVariable: CustomVariableModel = {
|
||||||
|
@ -2,7 +2,6 @@ import { of } from 'rxjs';
|
|||||||
|
|
||||||
import { CustomVariableModel, DataFrame, DataSourceInstanceSettings } from '@grafana/data';
|
import { CustomVariableModel, DataFrame, DataSourceInstanceSettings } from '@grafana/data';
|
||||||
import { BackendDataSourceResponse, toDataQueryResponse } from '@grafana/runtime';
|
import { BackendDataSourceResponse, toDataQueryResponse } from '@grafana/runtime';
|
||||||
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
|
||||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
|
|
||||||
import { CloudWatchLogsQueryRunner } from '../query-runner/CloudWatchLogsQueryRunner';
|
import { CloudWatchLogsQueryRunner } from '../query-runner/CloudWatchLogsQueryRunner';
|
||||||
@ -17,13 +16,11 @@ export function setupMockedLogsQueryRunner({
|
|||||||
variables,
|
variables,
|
||||||
mockGetVariableName = true,
|
mockGetVariableName = true,
|
||||||
settings = CloudWatchSettings,
|
settings = CloudWatchSettings,
|
||||||
timeSrv = getTimeSrv(),
|
|
||||||
}: {
|
}: {
|
||||||
data?: BackendDataSourceResponse;
|
data?: BackendDataSourceResponse;
|
||||||
variables?: CustomVariableModel[];
|
variables?: CustomVariableModel[];
|
||||||
mockGetVariableName?: boolean;
|
mockGetVariableName?: boolean;
|
||||||
settings?: DataSourceInstanceSettings<CloudWatchJsonData>;
|
settings?: DataSourceInstanceSettings<CloudWatchJsonData>;
|
||||||
timeSrv?: TimeSrv;
|
|
||||||
} = {}) {
|
} = {}) {
|
||||||
let templateService = new TemplateSrv();
|
let templateService = new TemplateSrv();
|
||||||
if (variables) {
|
if (variables) {
|
||||||
@ -34,7 +31,7 @@ export function setupMockedLogsQueryRunner({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const queryMock = jest.fn().mockReturnValue(of(toDataQueryResponse({ data })));
|
const queryMock = jest.fn().mockReturnValue(of(toDataQueryResponse({ data })));
|
||||||
const runner = new CloudWatchLogsQueryRunner(settings, templateService, timeSrv, queryMock);
|
const runner = new CloudWatchLogsQueryRunner(settings, templateService, queryMock);
|
||||||
|
|
||||||
return { runner, queryMock, templateService };
|
return { runner, queryMock, templateService };
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { getBackendSrv, setBackendSrv } from '@grafana/runtime';
|
import { getBackendSrv, setBackendSrv } from '@grafana/runtime';
|
||||||
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
|
||||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
import { CustomVariableModel } from 'app/features/variables/types';
|
import { CustomVariableModel } from 'app/features/variables/types';
|
||||||
|
|
||||||
@ -19,7 +18,6 @@ export function setupMockedResourcesAPI({
|
|||||||
} = {}) {
|
} = {}) {
|
||||||
let templateService = variables ? setupMockedTemplateService(variables) : new TemplateSrv();
|
let templateService = variables ? setupMockedTemplateService(variables) : new TemplateSrv();
|
||||||
|
|
||||||
const timeSrv = getTimeSrv();
|
|
||||||
const api = new ResourcesAPI(CloudWatchSettings, templateService);
|
const api = new ResourcesAPI(CloudWatchSettings, templateService);
|
||||||
let resourceRequestMock = getMock ? getMock : jest.fn().mockReturnValue(response);
|
let resourceRequestMock = getMock ? getMock : jest.fn().mockReturnValue(response);
|
||||||
setBackendSrv({
|
setBackendSrv({
|
||||||
@ -27,5 +25,5 @@ export function setupMockedResourcesAPI({
|
|||||||
get: resourceRequestMock,
|
get: resourceRequestMock,
|
||||||
});
|
});
|
||||||
|
|
||||||
return { api, resourceRequestMock, templateService, timeSrv };
|
return { api, resourceRequestMock, templateService };
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ export function setupForLogs() {
|
|||||||
return toDataQueryResponse({ data: { results: { a: { refId: 'a', frames: [dataFrameToJSON(frame)] } } } });
|
return toDataQueryResponse({ data: { results: { a: { refId: 'a', frames: [dataFrameToJSON(frame)] } } } });
|
||||||
}
|
}
|
||||||
|
|
||||||
const { datasource, queryMock, timeSrv } = setupMockedDataSource();
|
const { datasource, queryMock } = setupMockedDataSource();
|
||||||
|
|
||||||
const startQueryFrame: DataFrame = createDataFrame({ fields: [{ name: 'queryId', values: ['queryid'] }] });
|
const startQueryFrame: DataFrame = createDataFrame({ fields: [{ name: 'queryId', values: ['queryid'] }] });
|
||||||
queryMock.mockReturnValueOnce(of(envelope(startQueryFrame)));
|
queryMock.mockReturnValueOnce(of(envelope(startQueryFrame)));
|
||||||
@ -89,5 +89,5 @@ export function setupForLogs() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return { datasource, queryMock, timeSrv };
|
return { datasource, queryMock };
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import selectEvent from 'react-select-event';
|
|||||||
|
|
||||||
import { DataSourceInstanceSettings } from '@grafana/data';
|
import { DataSourceInstanceSettings } from '@grafana/data';
|
||||||
import * as ui from '@grafana/ui';
|
import * as ui from '@grafana/ui';
|
||||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
|
||||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
|
|
||||||
import { CustomVariableModel, initialVariableModelState } from '../../../../../../features/variables/types';
|
import { CustomVariableModel, initialVariableModelState } from '../../../../../../features/variables/types';
|
||||||
@ -44,7 +43,7 @@ const setup = () => {
|
|||||||
};
|
};
|
||||||
templateSrv.init([variable]);
|
templateSrv.init([variable]);
|
||||||
|
|
||||||
const datasource = new CloudWatchDatasource(instanceSettings, templateSrv, {} as TimeSrv);
|
const datasource = new CloudWatchDatasource(instanceSettings, templateSrv);
|
||||||
datasource.metricFindQuery = async () => [{ value: 'test', label: 'test', text: 'test' }];
|
datasource.metricFindQuery = async () => [{ value: 'test', label: 'test', text: 'test' }];
|
||||||
datasource.resources.getNamespaces = jest.fn().mockResolvedValue([]);
|
datasource.resources.getNamespaces = jest.fn().mockResolvedValue([]);
|
||||||
datasource.resources.getMetrics = jest.fn().mockResolvedValue([]);
|
datasource.resources.getMetrics = jest.fn().mockResolvedValue([]);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
import { toArray } from 'rxjs/operators';
|
import { toArray } from 'rxjs/operators';
|
||||||
|
|
||||||
import { CoreApp, dateTime, Field } from '@grafana/data';
|
import { CoreApp, Field } from '@grafana/data';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CloudWatchSettings,
|
CloudWatchSettings,
|
||||||
@ -212,19 +212,7 @@ describe('datasource', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should add links to log queries', async () => {
|
it('should add links to log queries', async () => {
|
||||||
const { datasource, timeSrv } = setupForLogs();
|
const { datasource } = setupForLogs();
|
||||||
timeSrv.timeRange = () => {
|
|
||||||
const time = dateTime('2021-01-01T01:00:00Z');
|
|
||||||
const range = {
|
|
||||||
from: time.subtract(6, 'hour'),
|
|
||||||
to: time,
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
...range,
|
|
||||||
raw: range,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const observable = datasource.query({
|
const observable = datasource.query({
|
||||||
targets: [
|
targets: [
|
||||||
@ -264,7 +252,7 @@ describe('datasource', () => {
|
|||||||
expect(emits[0].data[0].fields.find((f: Field) => f.name === '@message').config.links).toMatchObject([
|
expect(emits[0].data[0].fields.find((f: Field) => f.name === '@message').config.links).toMatchObject([
|
||||||
{
|
{
|
||||||
title: 'View in CloudWatch console',
|
title: 'View in CloudWatch console',
|
||||||
url: "https://us-west-1.console.aws.amazon.com/cloudwatch/home?region=us-west-1#logs-insights:queryDetail=~(end~'2020-12-31T19*3a00*3a00.000Z~start~'2020-12-31T19*3a00*3a00.000Z~timeType~'ABSOLUTE~tz~'UTC~editorString~'some*20query~isLiveTail~false~source~(~'test))",
|
url: "https://us-west-1.console.aws.amazon.com/cloudwatch/home?region=us-west-1#logs-insights:queryDetail=~(end~'2016-12-31T16*3a00*3a00.000Z~start~'2016-12-31T15*3a00*3a00.000Z~timeType~'ABSOLUTE~tz~'UTC~editorString~'some*20query~isLiveTail~false~source~(~'test))",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,6 @@ import {
|
|||||||
ScopedVars,
|
ScopedVars,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { DataSourceWithBackend } from '@grafana/runtime';
|
import { DataSourceWithBackend } from '@grafana/runtime';
|
||||||
import { getTimeSrv, TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
|
||||||
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
import { getTemplateSrv, TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
|
|
||||||
import { CloudWatchAnnotationSupport } from './annotationSupport';
|
import { CloudWatchAnnotationSupport } from './annotationSupport';
|
||||||
@ -61,8 +60,7 @@ export class CloudWatchDatasource
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private instanceSettings: DataSourceInstanceSettings<CloudWatchJsonData>,
|
private instanceSettings: DataSourceInstanceSettings<CloudWatchJsonData>,
|
||||||
readonly templateSrv: TemplateSrv = getTemplateSrv(),
|
readonly templateSrv: TemplateSrv = getTemplateSrv()
|
||||||
timeSrv: TimeSrv = getTimeSrv()
|
|
||||||
) {
|
) {
|
||||||
super(instanceSettings);
|
super(instanceSettings);
|
||||||
this.defaultRegion = instanceSettings.jsonData.defaultRegion;
|
this.defaultRegion = instanceSettings.jsonData.defaultRegion;
|
||||||
@ -72,12 +70,7 @@ export class CloudWatchDatasource
|
|||||||
this.metricMathCompletionItemProvider = new MetricMathCompletionItemProvider(this.resources, this.templateSrv);
|
this.metricMathCompletionItemProvider = new MetricMathCompletionItemProvider(this.resources, this.templateSrv);
|
||||||
this.metricsQueryRunner = new CloudWatchMetricsQueryRunner(instanceSettings, templateSrv, super.query.bind(this));
|
this.metricsQueryRunner = new CloudWatchMetricsQueryRunner(instanceSettings, templateSrv, super.query.bind(this));
|
||||||
this.logsCompletionItemProviderFunc = LogsCompletionItemProviderFunc(this.resources, this.templateSrv);
|
this.logsCompletionItemProviderFunc = LogsCompletionItemProviderFunc(this.resources, this.templateSrv);
|
||||||
this.logsQueryRunner = new CloudWatchLogsQueryRunner(
|
this.logsQueryRunner = new CloudWatchLogsQueryRunner(instanceSettings, templateSrv, super.query.bind(this));
|
||||||
instanceSettings,
|
|
||||||
templateSrv,
|
|
||||||
timeSrv,
|
|
||||||
super.query.bind(this)
|
|
||||||
);
|
|
||||||
this.annotationQueryRunner = new CloudWatchAnnotationQueryRunner(
|
this.annotationQueryRunner = new CloudWatchAnnotationQueryRunner(
|
||||||
instanceSettings,
|
instanceSettings,
|
||||||
templateSrv,
|
templateSrv,
|
||||||
|
@ -10,7 +10,6 @@ import {
|
|||||||
DataQueryRequest,
|
DataQueryRequest,
|
||||||
LogRowContextQueryDirection,
|
LogRowContextQueryDirection,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CloudWatchSettings,
|
CloudWatchSettings,
|
||||||
@ -26,6 +25,15 @@ import * as rxjsUtils from '../utils/rxjs/increasingInterval';
|
|||||||
|
|
||||||
import { LOG_IDENTIFIER_INTERNAL, LOGSTREAM_IDENTIFIER_INTERNAL } from './CloudWatchLogsQueryRunner';
|
import { LOG_IDENTIFIER_INTERNAL, LOGSTREAM_IDENTIFIER_INTERNAL } from './CloudWatchLogsQueryRunner';
|
||||||
|
|
||||||
|
jest.mock('@grafana/data', () => ({
|
||||||
|
...jest.requireActual('@grafana/data'),
|
||||||
|
getDefaultTimeRange: jest.fn().mockImplementation(() => {
|
||||||
|
const from = dateTime(1111);
|
||||||
|
const to = dateTime(2222);
|
||||||
|
return { from, to, raw: { from, to } };
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
describe('CloudWatchLogsQueryRunner', () => {
|
describe('CloudWatchLogsQueryRunner', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
@ -304,16 +312,10 @@ describe('CloudWatchLogsQueryRunner', () => {
|
|||||||
expect(queryMock.mock.calls[0][0]).toEqual(expect.objectContaining({ range: { from, to, raw: { from, to } } }));
|
expect(queryMock.mock.calls[0][0]).toEqual(expect.objectContaining({ range: { from, to, raw: { from, to } } }));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use the time range from the timeSrv if the time range in the options is not available', async () => {
|
it('should use the default time range if the time range in the options is not available', async () => {
|
||||||
const timeSrv = getTimeSrv();
|
|
||||||
const from = dateTime(1111);
|
const from = dateTime(1111);
|
||||||
const to = dateTime(2222);
|
const to = dateTime(2222);
|
||||||
timeSrv.timeRange = jest.fn().mockReturnValue({
|
const { runner, queryMock } = setupMockedLogsQueryRunner();
|
||||||
from,
|
|
||||||
to,
|
|
||||||
raw: { from, to },
|
|
||||||
});
|
|
||||||
const { runner, queryMock } = setupMockedLogsQueryRunner({ timeSrv });
|
|
||||||
await lastValueFrom(runner.makeLogActionRequest('StartQuery', [genMockCloudWatchLogsRequest()]));
|
await lastValueFrom(runner.makeLogActionRequest('StartQuery', [genMockCloudWatchLogsRequest()]));
|
||||||
|
|
||||||
expect(queryMock.mock.calls[0][0].skipQueryCache).toBe(true);
|
expect(queryMock.mock.calls[0][0].skipQueryCache).toBe(true);
|
||||||
|
@ -28,10 +28,10 @@ import {
|
|||||||
LogRowContextOptions,
|
LogRowContextOptions,
|
||||||
LogRowContextQueryDirection,
|
LogRowContextQueryDirection,
|
||||||
LogRowModel,
|
LogRowModel,
|
||||||
|
getDefaultTimeRange,
|
||||||
rangeUtil,
|
rangeUtil,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { config, FetchError } from '@grafana/runtime';
|
import { config, FetchError } from '@grafana/runtime';
|
||||||
import { TimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
|
||||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -64,7 +64,6 @@ export class CloudWatchLogsQueryRunner extends CloudWatchRequest {
|
|||||||
constructor(
|
constructor(
|
||||||
instanceSettings: DataSourceInstanceSettings<CloudWatchJsonData>,
|
instanceSettings: DataSourceInstanceSettings<CloudWatchJsonData>,
|
||||||
templateSrv: TemplateSrv,
|
templateSrv: TemplateSrv,
|
||||||
private readonly timeSrv: TimeSrv,
|
|
||||||
queryFn: (request: DataQueryRequest<CloudWatchQuery>) => Observable<DataQueryResponse>
|
queryFn: (request: DataQueryRequest<CloudWatchQuery>) => Observable<DataQueryResponse>
|
||||||
) {
|
) {
|
||||||
super(instanceSettings, templateSrv, queryFn);
|
super(instanceSettings, templateSrv, queryFn);
|
||||||
@ -186,7 +185,6 @@ export class CloudWatchLogsQueryRunner extends CloudWatchRequest {
|
|||||||
await addDataLinksToLogsResponse(
|
await addDataLinksToLogsResponse(
|
||||||
dataQueryResponse,
|
dataQueryResponse,
|
||||||
options,
|
options,
|
||||||
this.timeSrv.timeRange(),
|
|
||||||
this.replaceVariableAndDisplayWarningIfMulti.bind(this),
|
this.replaceVariableAndDisplayWarningIfMulti.bind(this),
|
||||||
this.expandVariableToArray.bind(this),
|
this.expandVariableToArray.bind(this),
|
||||||
this.getActualRegion.bind(this),
|
this.getActualRegion.bind(this),
|
||||||
@ -312,7 +310,7 @@ export class CloudWatchLogsQueryRunner extends CloudWatchRequest {
|
|||||||
queryParams: CloudWatchLogsRequest[],
|
queryParams: CloudWatchLogsRequest[],
|
||||||
options?: DataQueryRequest<CloudWatchQuery>
|
options?: DataQueryRequest<CloudWatchQuery>
|
||||||
): Observable<DataFrame[]> {
|
): Observable<DataFrame[]> {
|
||||||
const range = options?.range || this.timeSrv.timeRange();
|
const range = options?.range || getDefaultTimeRange();
|
||||||
|
|
||||||
const requestParams: DataQueryRequest<CloudWatchLogsQuery> = {
|
const requestParams: DataQueryRequest<CloudWatchLogsQuery> = {
|
||||||
...options,
|
...options,
|
||||||
|
@ -40,6 +40,7 @@ describe('addDataLinksToLogsResponse', () => {
|
|||||||
region: 'us-east-1',
|
region: 'us-east-1',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
range: { ...time, raw: time },
|
||||||
} as DataQueryRequest<CloudWatchQuery>;
|
} as DataQueryRequest<CloudWatchQuery>;
|
||||||
|
|
||||||
setDataSourceSrv({
|
setDataSourceSrv({
|
||||||
@ -53,7 +54,6 @@ describe('addDataLinksToLogsResponse', () => {
|
|||||||
await addDataLinksToLogsResponse(
|
await addDataLinksToLogsResponse(
|
||||||
mockResponse,
|
mockResponse,
|
||||||
mockOptions,
|
mockOptions,
|
||||||
{ ...time, raw: time },
|
|
||||||
(s) => s ?? '',
|
(s) => s ?? '',
|
||||||
(v) => [v] ?? [],
|
(v) => [v] ?? [],
|
||||||
(r) => r,
|
(r) => r,
|
||||||
@ -125,12 +125,12 @@ describe('addDataLinksToLogsResponse', () => {
|
|||||||
region: 'us-east-1',
|
region: 'us-east-1',
|
||||||
} as CloudWatchQuery,
|
} as CloudWatchQuery,
|
||||||
],
|
],
|
||||||
|
range: { ...time, raw: time },
|
||||||
} as DataQueryRequest<CloudWatchQuery>;
|
} as DataQueryRequest<CloudWatchQuery>;
|
||||||
|
|
||||||
await addDataLinksToLogsResponse(
|
await addDataLinksToLogsResponse(
|
||||||
mockResponse,
|
mockResponse,
|
||||||
mockOptions,
|
mockOptions,
|
||||||
{ ...time, raw: time },
|
|
||||||
(s) => s ?? '',
|
(s) => s ?? '',
|
||||||
(v) => [v] ?? [],
|
(v) => [v] ?? [],
|
||||||
(r) => r
|
(r) => r
|
||||||
@ -182,12 +182,12 @@ describe('addDataLinksToLogsResponse', () => {
|
|||||||
region: 'us-east-1',
|
region: 'us-east-1',
|
||||||
} as CloudWatchQuery,
|
} as CloudWatchQuery,
|
||||||
],
|
],
|
||||||
|
range: { ...time, raw: time },
|
||||||
} as DataQueryRequest<CloudWatchQuery>;
|
} as DataQueryRequest<CloudWatchQuery>;
|
||||||
|
|
||||||
await addDataLinksToLogsResponse(
|
await addDataLinksToLogsResponse(
|
||||||
mockResponse,
|
mockResponse,
|
||||||
mockOptions,
|
mockOptions,
|
||||||
{ ...time, raw: time },
|
|
||||||
(s) => s ?? '',
|
(s) => s ?? '',
|
||||||
(v) => [v] ?? [],
|
(v) => [v] ?? [],
|
||||||
(r) => r
|
(r) => r
|
||||||
|
@ -14,7 +14,6 @@ type ReplaceFn = (
|
|||||||
export async function addDataLinksToLogsResponse(
|
export async function addDataLinksToLogsResponse(
|
||||||
response: DataQueryResponse,
|
response: DataQueryResponse,
|
||||||
request: DataQueryRequest<CloudWatchQuery>,
|
request: DataQueryRequest<CloudWatchQuery>,
|
||||||
range: TimeRange,
|
|
||||||
replaceFn: ReplaceFn,
|
replaceFn: ReplaceFn,
|
||||||
getVariableValueFn: (value: string, scopedVars: ScopedVars) => string[],
|
getVariableValueFn: (value: string, scopedVars: ScopedVars) => string[],
|
||||||
getRegion: (region: string) => string,
|
getRegion: (region: string) => string,
|
||||||
@ -37,7 +36,9 @@ export async function addDataLinksToLogsResponse(
|
|||||||
} else {
|
} else {
|
||||||
// Right now we add generic link to open the query in xray console to every field so it shows in the logs row
|
// Right now we add generic link to open the query in xray console to every field so it shows in the logs row
|
||||||
// details. Unfortunately this also creates link for all values inside table which look weird.
|
// details. Unfortunately this also creates link for all values inside table which look weird.
|
||||||
field.config.links = [createAwsConsoleLink(curTarget, range, interpolatedRegion, replace, getVariableValue)];
|
field.config.links = [
|
||||||
|
createAwsConsoleLink(curTarget, request.range, interpolatedRegion, replace, getVariableValue),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user