-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow templated legend via attribute keys and values from query resul…
…ts (#57) A few changes were made to the Time Series Value fields: - Labels are appended to the field it self. This will use default formatting and removes the need for our createFieldName function. - Name is changed to use the TIME_SERIES_VALUE_FIELD which has logic to remove the name if there is no displayNameFromDS set and use default label formatting. - Query Name allows for variable names in simple mustache like syntax {{var1}} which is similar to the Prometheus / Loki datasource - If an attribute value doesn't exist in the results set, then the value will be set to <undefined>
- Loading branch information
1 parent
7219563
commit d6b5ede
Showing
6 changed files
with
301 additions
and
158 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,118 @@ | ||
import { preprocessData } from './index'; | ||
|
||
test('preprocesses logs successfully', () => { | ||
const logsDataFrame = preprocessData( | ||
{ | ||
data: { | ||
attributes: { | ||
logs: [ | ||
[ | ||
1691409972788, | ||
{ | ||
event: 'one', | ||
severity: 'ErrorSeverity', | ||
tags: { | ||
'http.status_code': 200, | ||
large_batch: true, | ||
trace_id: 'd29a3fa8fb446ec65eb691a3259a541e', | ||
describe('logs', () => { | ||
it('preprocesses successfully', () => { | ||
const logsDataFrame = preprocessData( | ||
{ | ||
data: { | ||
attributes: { | ||
logs: [ | ||
[ | ||
1691409972788, | ||
{ | ||
event: 'one', | ||
severity: 'ErrorSeverity', | ||
tags: { | ||
'http.status_code': 200, | ||
large_batch: true, | ||
trace_id: 'd29a3fa8fb446ec65eb691a3259a541e', | ||
}, | ||
}, | ||
}, | ||
], | ||
[ | ||
1691409971908, | ||
{ | ||
event: 'two', | ||
severity: 'InfoSeverity', | ||
tags: { | ||
customer: 'hipcore', | ||
large_batch: false, | ||
trace_id: 'd0fa420269652931236c94bc54d2233e', | ||
], | ||
[ | ||
1691409971908, | ||
{ | ||
event: 'two', | ||
severity: 'InfoSeverity', | ||
tags: { | ||
customer: 'hipcore', | ||
large_batch: false, | ||
trace_id: 'd0fa420269652931236c94bc54d2233e', | ||
}, | ||
k8s_environment: 'production', | ||
k8s_namespace: 'default', | ||
k8s_pod: 'hipcore-pod', | ||
}, | ||
k8s_environment: 'production', | ||
k8s_namespace: 'default', | ||
k8s_pod: 'hipcore-pod', | ||
}, | ||
], | ||
], | ||
}, | ||
}, | ||
}, | ||
{ refId: 'a' }, | ||
'' | ||
); | ||
|
||
expect(logsDataFrame.toJSON()).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('preprocesses Timeseries successfully', () => { | ||
it('should set displayNameDS with legend formatter', () => { | ||
const res = { | ||
data: { | ||
attributes: { | ||
series: [ | ||
{ | ||
'group-labels': ['operation=/get'], | ||
points: [ | ||
[0, 1], | ||
[1, 7], | ||
[2, 1], | ||
], | ||
}, | ||
{ | ||
'group-labels': ['operation=/load'], | ||
points: [ | ||
[0, 6], | ||
[1, 5], | ||
[2, 9], | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
{ refId: 'a' }, | ||
'' | ||
); | ||
}; | ||
const query = { projectName: 'demo', format: '{{operation}}' }; | ||
expect(preprocessData(res, query, 'https://notebooks')).toMatchSnapshot(); | ||
}); | ||
|
||
expect(logsDataFrame.toJSON()).toMatchSnapshot(); | ||
it('should work if there are no labels', () => { | ||
const res = { | ||
data: { | ||
attributes: { | ||
series: [ | ||
{ | ||
points: [ | ||
[0, 1], | ||
[1, 7], | ||
[2, 1], | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
const query = { projectName: 'demo', format: '{{operation}}' }; | ||
expect(preprocessData(res, query, 'https://notebooks')).toMatchSnapshot(); | ||
}); | ||
|
||
it('should work if there are no labels and no legend', () => { | ||
const res = { | ||
data: { | ||
attributes: { | ||
series: [ | ||
{ | ||
points: [ | ||
[0, 1], | ||
[1, 7], | ||
[2, 1], | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
const query = { projectName: 'demo', format: undefined }; | ||
expect(preprocessData(res, query, 'https://notebooks')).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.