Skip to content

Commit 8bdd03e

Browse files
authored
Logs: Don't add console link to every field in the logs response and prepare 12.2.0 (#238)
1 parent 4c49f09 commit 8bdd03e

File tree

6 files changed

+122
-21
lines changed

6 files changed

+122
-21
lines changed

CHANGELOG.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,71 @@
11
# Changelog
22

3+
## 12.2.0
4+
5+
- Logs: Don't add console link to every field in the logs response in [#238](https://github.com/grafana/grafana-cloudwatch-datasource/pull/238)
6+
- Add issue workflows and templates in [#108](https://github.com/grafana/grafana-cloudwatch-datasource/pull/108)
7+
- Update dependabot groups in [#186](https://github.com/grafana/grafana-cloudwatch-datasource/pull/186)
8+
- Add syntax highlighting and autocomplete for logs diff command in [#185](https://github.com/grafana/grafana-cloudwatch-datasource/pull/185)
9+
- Refactor logs language tests in [#184](https://github.com/grafana/grafana-cloudwatch-datasource/pull/184)
10+
- Upgrade yarn to v4.10.3 in [#203](https://github.com/grafana/grafana-cloudwatch-datasource/pull/203)
11+
- Update gitignore for yarn files in [#215](https://github.com/grafana/grafana-cloudwatch-datasource/pull/215)
12+
- CD: Publish Github release directly, skipping draft in [#179](https://github.com/grafana/grafana-cloudwatch-datasource/pull/179)
13+
- Use the correct metric name for errors per function panel in the AWS Lambda sample dashboard in [#160](https://github.com/grafana/grafana-cloudwatch-datasource/pull/160)
14+
15+
- Chore: bump github.com/aws/smithy-go from 1.23.0 to 1.23.1 in [#246](https://github.com/grafana/grafana-cloudwatch-datasource/pull/246)
16+
- Chore: bump github.com/grafana/grafana-plugin-sdk-go from 0.280.0 to 0.281.0 in [#236](https://github.com/grafana/grafana-cloudwatch-datasource/pull/236)
17+
- Chore: bump @types/node from 22.18.9 to 22.18.10 in [#231](https://github.com/grafana/grafana-cloudwatch-datasource/pull/231)
18+
- Chore: bump @types/node from 22.18.8 to 22.18.9 in [#228](https://github.com/grafana/grafana-cloudwatch-datasource/pull/228)
19+
- Chore: bump @typescript-eslint/eslint-plugin from 8.37.0 to 8.45.0 in [#226](https://github.com/grafana/grafana-cloudwatch-datasource/pull/226)
20+
- Chore: bump the npm-patch-dev-dependencies group with 3 updates in [#224](https://github.com/grafana/grafana-cloudwatch-datasource/pull/224)
21+
- Chore: bump typescript from 5.8.3 to 5.9.2 in [#222](https://github.com/grafana/grafana-cloudwatch-datasource/pull/222)
22+
- Chore: bump @typescript-eslint/parser from 8.42.0 to 8.44.1 in [#221](https://github.com/grafana/grafana-cloudwatch-datasource/pull/221)
23+
- Chore: bump @grafana/plugin-ui from 0.10.9 to 0.10.10 in [#218](https://github.com/grafana/grafana-cloudwatch-datasource/pull/218)
24+
- Chore: bump eslint from 9.31.0 to 9.36.0 in [#217](https://github.com/grafana/grafana-cloudwatch-datasource/pull/217)
25+
- Chore: bump eslint-plugin-jsdoc from 51.4.1 to 54.5.0 in [#214](https://github.com/grafana/grafana-cloudwatch-datasource/pull/214)
26+
- Chore: bump @eslint/js from 9.34.0 to 9.36.0 in [#212](https://github.com/grafana/grafana-cloudwatch-datasource/pull/212)
27+
- Chore: bump the npm-patch-dev-dependencies group with 3 updates in [#211](https://github.com/grafana/grafana-cloudwatch-datasource/pull/211)
28+
- Chore: bump @playwright/test from 1.54.2 to 1.55.1 in [#210](https://github.com/grafana/grafana-cloudwatch-datasource/pull/210)
29+
- Chore: bump github.com/grafana/grafana-aws-sdk from 1.2.0 to 1.3.0 in [#208](https://github.com/grafana/grafana-cloudwatch-datasource/pull/208)
30+
- Chore: bump github.com/grafana/grafana-plugin-sdk-go from 0.279.0 to 0.280.0 in [#206](https://github.com/grafana/grafana-cloudwatch-datasource/pull/206)
31+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/cloudwatch from 1.50.0 to 1.50.1 in [#201](https://github.com/grafana/grafana-cloudwatch-datasource/pull/201)
32+
- Chore: bump actions/checkout from 4 to 5 in [#200](https://github.com/grafana/grafana-cloudwatch-datasource/pull/200)
33+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/cloudwatch from 1.49.3 to 1.50.0 in [#199](https://github.com/grafana/grafana-cloudwatch-datasource/pull/199)
34+
- Chore: bump @typescript-eslint/parser from 8.37.0 to 8.42.0 in [#196](https://github.com/grafana/grafana-cloudwatch-datasource/pull/196)
35+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.251.0 to 1.251.2 in [#195](https://github.com/grafana/grafana-cloudwatch-datasource/pull/195)
36+
- Chore: bump actions/checkout from 4 to 5 in [#126](https://github.com/grafana/grafana-cloudwatch-datasource/pull/126)
37+
- Chore: bump actions/setup-node from 4 to 5 in [#171](https://github.com/grafana/grafana-cloudwatch-datasource/pull/171)
38+
- Chore: bump @swc/core from 1.13.3 to 1.13.5 in [#194](https://github.com/grafana/grafana-cloudwatch-datasource/pull/194)
39+
- Chore: bump @eslint/js from 9.32.0 to 9.34.0 in [#193](https://github.com/grafana/grafana-cloudwatch-datasource/pull/193)
40+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi from 1.30.3 to 1.30.4 in [#192](https://github.com/grafana/grafana-cloudwatch-datasource/pull/192)
41+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.250.0 to 1.251.0 in [#191](https://github.com/grafana/grafana-cloudwatch-datasource/pull/191)
42+
- Chore: bump @grafana/eslint-config from 8.1.0 to 8.2.0 in [#137](https://github.com/grafana/grafana-cloudwatch-datasource/pull/137)
43+
- Chore: bump @types/node from 22.17.0 to 22.18.1 in [#190](https://github.com/grafana/grafana-cloudwatch-datasource/pull/190)
44+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/oam from 1.22.2 to 1.22.3 in [#189](https://github.com/grafana/grafana-cloudwatch-datasource/pull/189)
45+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs from 1.57.3 to 1.57.4 in [#188](https://github.com/grafana/grafana-cloudwatch-datasource/pull/188)
46+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.249.0 to 1.250.0 in [#187](https://github.com/grafana/grafana-cloudwatch-datasource/pull/187)
47+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/oam from 1.22.1 to 1.22.2 in [#183](https://github.com/grafana/grafana-cloudwatch-datasource/pull/183)
48+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs from 1.57.1 to 1.57.3 in [#182](https://github.com/grafana/grafana-cloudwatch-datasource/pull/182)
49+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi from 1.30.2 to 1.30.3 in [#181](https://github.com/grafana/grafana-cloudwatch-datasource/pull/181)
50+
- Chore: bump github.com/prometheus/client_golang from 1.23.0 to 1.23.2 in [#176](https://github.com/grafana/grafana-cloudwatch-datasource/pull/176)
51+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.248.0 to 1.249.0 in [#178](https://github.com/grafana/grafana-cloudwatch-datasource/pull/178)
52+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/cloudwatch from 1.49.1 to 1.49.3 in [#180](https://github.com/grafana/grafana-cloudwatch-datasource/pull/180)
53+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/oam from 1.21.3 to 1.22.1 in [#175](https://github.com/grafana/grafana-cloudwatch-datasource/pull/175)
54+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi from 1.30.1 to 1.30.2 in [#173](https://github.com/grafana/grafana-cloudwatch-datasource/pull/173)
55+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/cloudwatch from 1.48.2 to 1.49.1 in [#174](https://github.com/grafana/grafana-cloudwatch-datasource/pull/174)
56+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.247.1 to 1.248.0 in [#172](https://github.com/grafana/grafana-cloudwatch-datasource/pull/172)
57+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.245.2 to 1.247.1 in [#169](https://github.com/grafana/grafana-cloudwatch-datasource/pull/169)
58+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi from 1.29.2 to 1.30.1 in [#170](https://github.com/grafana/grafana-cloudwatch-datasource/pull/170)
59+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs from 1.56.2 to 1.57.1 in [#168](https://github.com/grafana/grafana-cloudwatch-datasource/pull/168)
60+
- Chore: bump github.com/aws/aws-sdk-go-v2 from 1.38.2 to 1.38.3 in [#161](https://github.com/grafana/grafana-cloudwatch-datasource/pull/161)
61+
- Chore: bump golang.org/x/sync from 0.16.0 to 0.17.0 in [#162](https://github.com/grafana/grafana-cloudwatch-datasource/pull/162)
62+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/cloudwatch from 1.48.0 to 1.48.2 in [#156](https://github.com/grafana/grafana-cloudwatch-datasource/pull/156)
63+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/oam from 1.21.2 to 1.21.3 in [#157](https://github.com/grafana/grafana-cloudwatch-datasource/pull/157)
64+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/ec2 from 1.243.0 to 1.245.1 in [#155](https://github.com/grafana/grafana-cloudwatch-datasource/pull/155)
65+
- Chore: bump github.com/stretchr/testify from 1.10.0 to 1.11.0 in [#153](https://github.com/grafana/grafana-cloudwatch-datasource/pull/153)
66+
- Chore: bump github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs from 1.56.0 to 1.56.2 in [#152](https://github.com/grafana/grafana-cloudwatch-datasource/pull/152)
67+
68+
369
## 12.1.3
470

571
- Add clusterId to dimension list for AWS/ElastiCache namespace [#151](https://github.com/grafana/grafana-cloudwatch-datasource/pull/151)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "grafana-cloudwatch-datasource",
3-
"version": "12.1.3",
3+
"version": "12.2.0",
44
"scripts": {
55
"build": "webpack -c ./webpack.config.ts --env production",
66
"dev": "webpack -w -c ./webpack.config.ts --env development",

src/components/QueryEditor/LogsQueryEditor/code-editors/PPLQueryEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const PPLQueryEditor = (props: LogsCodeEditorProps) => {
9696
);
9797
};
9898
return (
99+
<>
99100
<CodeEditor
100101
{...codeEditorCommonProps}
101102
language={language.id}
@@ -111,5 +112,6 @@ export const PPLQueryEditor = (props: LogsCodeEditorProps) => {
111112
onEditorDidMount={onEditorMount}
112113
onEditorWillUnmount={() => disposalRef.current?.dispose()}
113114
/>
115+
</>
114116
);
115117
};

src/datasource.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import * as templateUtils from './utils/templateVariableUtils';
2828
jest.mock('./utils/templateVariableUtils', () => {
2929
return {
3030
__esModule: true, // getting 'cannot redefine getVariableName' otherwise
31-
...jest.requireActual('./utils/templateVariableUtils')
31+
...jest.requireActual('./utils/templateVariableUtils'),
3232
};
3333
});
3434

@@ -313,7 +313,7 @@ describe('datasource', () => {
313313
});
314314
});
315315

316-
it('should add links to log queries', async () => {
316+
it('should add a data link field to log queries', async () => {
317317
const { datasource } = setupForLogs();
318318

319319
const observable = datasource.query({
@@ -351,7 +351,7 @@ describe('datasource', () => {
351351
},
352352
]);
353353

354-
expect(emits[0].data[0].fields.find((f: Field) => f.name === '@message').config.links).toMatchObject([
354+
expect(emits[0].data[0].fields.find((f: Field) => f.name === '').config.links).toMatchObject([
355355
{
356356
title: 'View in CloudWatch console',
357357
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))",

src/utils/datalinks.test.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DataQueryRequest, DataQueryResponse, dateMath } from '@grafana/data';
1+
import { DataQueryRequest, DataQueryResponse, dateMath, FieldType } from '@grafana/data';
22
import { DataSourceSrv, setDataSourceSrv } from '@grafana/runtime';
33

44
import { CloudWatchQuery } from '../types';
@@ -18,10 +18,12 @@ describe('addDataLinksToLogsResponse', () => {
1818
{
1919
name: '@message',
2020
config: {},
21+
values: ['log message one', 'log message two'],
2122
},
2223
{
2324
name: '@xrayTraceId',
2425
config: {},
26+
values: ['id1', 'id2'],
2527
},
2628
],
2729
refId: 'A',
@@ -64,14 +66,6 @@ describe('addDataLinksToLogsResponse', () => {
6466
fields: [
6567
{
6668
name: '@message',
67-
config: {
68-
links: [
69-
{
70-
url: "https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1#logs-insights:queryDetail=~(end~'2016-12-31T16*3a00*3a00.000Z~start~'2016-12-31T15*3a00*3a00.000Z~timeType~'ABSOLUTE~tz~'UTC~editorString~'stats*20count*28*40message*29*20by*20bin*281h*29~isLiveTail~false~source~(~'fake-log-group-one~'fake-log-group-two))",
71-
title: 'View in CloudWatch console',
72-
},
73-
],
74-
},
7569
},
7670
{
7771
name: '@xrayTraceId',
@@ -89,14 +83,27 @@ describe('addDataLinksToLogsResponse', () => {
8983
],
9084
},
9185
},
86+
{
87+
name: '',
88+
type: FieldType.string,
89+
values: ['View this query in CloudWatch console', 'View this query in CloudWatch console'],
90+
config: {
91+
links: [
92+
{
93+
url: "https://us-east-1.console.aws.amazon.com/cloudwatch/home?region=us-east-1#logs-insights:queryDetail=~(end~'2016-12-31T16*3a00*3a00.000Z~start~'2016-12-31T15*3a00*3a00.000Z~timeType~'ABSOLUTE~tz~'UTC~editorString~'stats*20count*28*40message*29*20by*20bin*281h*29~isLiveTail~false~source~(~'fake-log-group-one~'fake-log-group-two))",
94+
title: 'View in CloudWatch console',
95+
},
96+
],
97+
},
98+
},
9299
],
93100
refId: 'A',
94101
},
95102
],
96103
});
97104
});
98105

99-
it('should add data links to response from log groups, trimming :*', async () => {
106+
it('should add a data link field to response from log groups, trimming :*', async () => {
100107
const mockResponse: DataQueryResponse = {
101108
data: [
102109
{
@@ -140,6 +147,11 @@ describe('addDataLinksToLogsResponse', () => {
140147
fields: [
141148
{
142149
name: '@message',
150+
},
151+
{
152+
name: '',
153+
type: FieldType.string,
154+
values: [],
143155
config: {
144156
links: [
145157
{
@@ -197,6 +209,11 @@ describe('addDataLinksToLogsResponse', () => {
197209
fields: [
198210
{
199211
name: '@message',
212+
},
213+
{
214+
name: '',
215+
type: FieldType.string,
216+
values: [],
200217
config: {
201218
links: [
202219
{

src/utils/datalinks.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
import { DataFrame, DataLink, DataQueryRequest, DataQueryResponse, ScopedVars, TimeRange } from '@grafana/data';
1+
import {
2+
DataFrame,
3+
DataLink,
4+
DataQueryRequest,
5+
DataQueryResponse,
6+
FieldType,
7+
ScopedVars,
8+
TimeRange,
9+
} from '@grafana/data';
210
import { getDataSourceSrv } from '@grafana/runtime';
311

412
import { AwsUrl, encodeUrl } from '../aws_url';
@@ -33,14 +41,22 @@ export async function addDataLinksToLogsResponse(
3341
if (xrayLink) {
3442
field.config.links = [xrayLink];
3543
}
36-
} else {
37-
// Right now we add generic link to open the query in xray console to every field so it shows in the logs row
38-
// details. Unfortunately this also creates link for all values inside table which look weird.
39-
field.config.links = [
40-
createAwsConsoleLink(curTarget, request.range, interpolatedRegion, replace, getVariableValue),
41-
];
4244
}
4345
}
46+
47+
// add a link to the cloudwatch console as a separate field that will be displayed as a link
48+
if (dataFrame.fields.length) {
49+
dataFrame.fields.push({
50+
name: '',
51+
type: FieldType.string,
52+
values: dataFrame.fields[0]?.values?.length
53+
? new Array(dataFrame.fields[0].values.length).fill('View this query in CloudWatch console')
54+
: [],
55+
config: {
56+
links: [createAwsConsoleLink(curTarget, request.range, interpolatedRegion, replace, getVariableValue)],
57+
},
58+
});
59+
}
4460
}
4561
}
4662

0 commit comments

Comments
 (0)