Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prometheus: Fix exemplars not respecting corresponding series display…
… status. (#59743) * Exemplar filtering when series are toggled in legend UI (cherry picked from commit 22f8283)
- Loading branch information
1 parent
9f3a952
commit 99400da
Showing
5 changed files
with
188 additions
and
9 deletions.
There are no files selected for viewing
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
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
97 changes: 97 additions & 0 deletions
97
public/app/plugins/panel/timeseries/plugins/ExemplarsPlugin.test.tsx
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { Field, Labels, MutableDataFrame } from '@grafana/data/src'; | ||
import { UPlotConfigBuilder } from '@grafana/ui/src'; | ||
|
||
import { getVisibleLabels } from './ExemplarsPlugin'; | ||
|
||
describe('getVisibleLabels()', () => { | ||
const dataFrameSeries1 = new MutableDataFrame({ | ||
name: 'tns/app', | ||
fields: [ | ||
{ | ||
name: 'Time', | ||
values: [1670418750000, 1670418765000, 1670418780000, 1670418795000], | ||
entities: {}, | ||
}, | ||
{ | ||
name: 'Value', | ||
labels: { | ||
job: 'tns/app', | ||
}, | ||
values: [0.018963114754098367, 0.019140624999999974, 0.019718309859154928, 0.020064189189189167], | ||
}, | ||
] as unknown as Field[], | ||
length: 4, | ||
}); | ||
const dataFrameSeries2 = new MutableDataFrame({ | ||
name: 'tns/db', | ||
fields: [ | ||
{ | ||
name: 'Time', | ||
values: [1670418750000, 1670418765000, 1670418780000, 1670418795000], | ||
entities: {}, | ||
}, | ||
{ | ||
name: 'Value', | ||
labels: { | ||
job: 'tns/db', | ||
}, | ||
values: [0.028963114754098367, 0.029140624999999974, 0.029718309859154928, 0.030064189189189167], | ||
}, | ||
] as unknown as Field[], | ||
length: 4, | ||
}); | ||
const dataFrameSeries3 = new MutableDataFrame({ | ||
name: 'tns/loadgen', | ||
fields: [ | ||
{ | ||
name: 'Time', | ||
values: [1670418750000, 1670418765000, 1670418780000, 1670418795000], | ||
entities: {}, | ||
}, | ||
{ | ||
name: 'Value', | ||
labels: { | ||
job: 'tns/loadgen', | ||
}, | ||
values: [0.028963114754098367, 0.029140624999999974, 0.029718309859154928, 0.030064189189189167], | ||
}, | ||
] as unknown as Field[], | ||
length: 4, | ||
}); | ||
const frames = [dataFrameSeries1, dataFrameSeries2, dataFrameSeries3]; | ||
const config: UPlotConfigBuilder = { | ||
addHook: (type, hook) => {}, | ||
series: [ | ||
{ | ||
props: { | ||
dataFrameFieldIndex: { frameIndex: 0, fieldIndex: 1 }, | ||
show: true, | ||
}, | ||
}, | ||
{ | ||
props: { | ||
dataFrameFieldIndex: { frameIndex: 1, fieldIndex: 1 }, | ||
show: true, | ||
}, | ||
}, | ||
{ | ||
props: { | ||
dataFrameFieldIndex: { frameIndex: 2, fieldIndex: 1 }, | ||
show: false, | ||
}, | ||
}, | ||
], | ||
} as UPlotConfigBuilder; | ||
|
||
it('function should only return labels associated with actively visible series', () => { | ||
const expected: { labels: Labels[]; totalSeriesCount: number } = { | ||
totalSeriesCount: 3, | ||
labels: [{ job: 'tns/app' }, { job: 'tns/db' }], | ||
}; | ||
|
||
// Base case | ||
expect(getVisibleLabels(config, [])).toEqual({ totalSeriesCount: 3, labels: [] }); | ||
|
||
expect(getVisibleLabels(config, frames)).toEqual(expected); | ||
}); | ||
}); |
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