[FEATURE] prometheus & timeserieschart: Add annotation support#642
[FEATURE] prometheus & timeserieschart: Add annotation support#642Gladorme wants to merge 11 commits into
Conversation
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
Signed-off-by: Guillaume LADORME <Gladorme@users.noreply.github.com>
| "@perses-dev/components": "^0.53.1", | ||
| "@perses-dev/core": "^0.53.0", | ||
| "@perses-dev/plugin-system": "^0.53.1", | ||
| "@perses-dev/plugin-system": "file:../../shared/plugin-system", |
There was a problem hiding this comment.
"file:../../shared/plugin-system ?
| @@ -0,0 +1,97 @@ | |||
| import { AnnotationData } from '@perses-dev/spec'; | |||
| import { AnnotationContext, datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system'; | |||
| import { DatasourceSpec, parseDurationString } from '@perses-dev/core'; | |||
There was a problem hiding this comment.
Please avoid using core.
All types have been placed either in spec or in shared packages.
| import { ReactElement } from 'react'; | ||
| import { useId } from '@perses-dev/components'; | ||
| import { produce } from 'immer'; | ||
| import { Autocomplete, Chip, FormControl, Stack, TextField } from '@mui/material'; |
There was a problem hiding this comment.
'Chip' is declared but its value is never read.ts(6133)
| const formatDate = (timeMs: number): { date: string; time: string } => { | ||
| const d = new Date(timeMs); | ||
| return { | ||
| date: formatWithUserTimeZone(d, 'MMM dd, yyyy'), | ||
| time: formatWithUserTimeZone(d, 'HH:mm:ss'), | ||
| }; | ||
| }; |
There was a problem hiding this comment.
The exact same method was added to the /shared/plugin-system
We should have this as a util once.
https://github.com/perses/shared/pull/120/changes#r3309644486
| * markLine (vertical dashed lines) and markPoint (triangle markers under the X-axis). | ||
| */ | ||
| export function buildAnnotationSeries(annotations: TimeSeriesAnnotation[] | undefined): LineSeriesOption[] { | ||
| if (!annotations || annotations.length === 0) return []; |
There was a problem hiding this comment.
if (!annotations?.length) return [];| const markPointData: any[] = []; | ||
|
|
||
| annotations.forEach((annotation, index) => { | ||
| const color = annotation.color ?? '#FF6B6B'; |
There was a problem hiding this comment.
It seems you have already defined this color-code in plugin-system\src\components\Annotations\AnnotationEditorForm\AnnotationEditorForm.tsx
To avoid duplication the definition could be kept in plugin-system only and exposed so the plugin itself can use it as the default one.
export const DEFAULT_ANNOTATION_COLOR = '#FF6B6B';| // Add start marker | ||
| markPointData.push({ | ||
| coord: [annotation.start, 0], | ||
| symbol: 'triangle', | ||
| symbolSize: [12, 12], | ||
| symbolRotate: 0, | ||
| symbolOffset: [0, 4], // Position below X-axis | ||
| itemStyle: { color }, | ||
| annotationIndex: index, | ||
| emphasis: { | ||
| disabled: true, | ||
| }, | ||
| isStart: true, | ||
| }); | ||
|
|
||
| // Add end marker | ||
| markPointData.push({ | ||
| coord: [annotation.end, 0], | ||
| symbol: 'triangle', | ||
| symbolSize: [12, 12], | ||
| symbolRotate: 0, | ||
| symbolOffset: [0, 4], // Position below X-axis | ||
| itemStyle: { color }, | ||
| annotationIndex: index, | ||
| emphasis: { | ||
| disabled: true, | ||
| }, | ||
| isEnd: true, | ||
| }); |
There was a problem hiding this comment.
This looks cumbersome and could be simplified.
for (const type of ['Start', 'End']) {
const isStart = type === 'Start';
markPointData.push({
coord: [isStart ? annotation.start : annotation.end, 0],
symbol: 'triangle',
symbolSize: [12, 12],
symbolRotate: 0,
symbolOffset: [0, 4],
itemStyle: { color },
annotationIndex: index,
emphasis: { disabled: true },
isStart,
isEnd: !isStart,
});
}
Description
Add annotation generation for Prometheus datasource and add display on TimeSeriesChart.
Idea: add option to ignore "end" to only keep a point
PR related to:
Screenshots
Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes