-
Notifications
You must be signed in to change notification settings - Fork 11.6k
/
dashboard_spec_gen.go
998 lines (792 loc) · 41.5 KB
/
dashboard_spec_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
//
// Generated by:
// kinds/gen.go
// Using jennies:
// GoResourceTypes
//
// Run 'make gen-cue' from repository root to regenerate.
package dashboard
import (
"time"
)
// Defines values for CursorSync.
const (
CursorSyncN0 CursorSync = 0
CursorSyncN1 CursorSync = 1
CursorSyncN2 CursorSync = 2
)
// Defines values for LinkType.
const (
LinkTypeDashboards LinkType = "dashboards"
LinkTypeLink LinkType = "link"
)
// Defines values for FieldColorModeId.
const (
FieldColorModeIdContinuousBlPu FieldColorModeId = "continuous-BlPu"
FieldColorModeIdContinuousBlYlRd FieldColorModeId = "continuous-BlYlRd"
FieldColorModeIdContinuousBlues FieldColorModeId = "continuous-blues"
FieldColorModeIdContinuousGrYlRd FieldColorModeId = "continuous-GrYlRd"
FieldColorModeIdContinuousGreens FieldColorModeId = "continuous-greens"
FieldColorModeIdContinuousPurples FieldColorModeId = "continuous-purples"
FieldColorModeIdContinuousRdYlGr FieldColorModeId = "continuous-RdYlGr"
FieldColorModeIdContinuousReds FieldColorModeId = "continuous-reds"
FieldColorModeIdContinuousYlBl FieldColorModeId = "continuous-YlBl"
FieldColorModeIdContinuousYlRd FieldColorModeId = "continuous-YlRd"
FieldColorModeIdFixed FieldColorModeId = "fixed"
FieldColorModeIdPaletteClassic FieldColorModeId = "palette-classic"
FieldColorModeIdPaletteClassicByName FieldColorModeId = "palette-classic-by-name"
FieldColorModeIdShades FieldColorModeId = "shades"
FieldColorModeIdThresholds FieldColorModeId = "thresholds"
)
// Defines values for FieldColorSeriesByMode.
const (
FieldColorSeriesByModeLast FieldColorSeriesByMode = "last"
FieldColorSeriesByModeMax FieldColorSeriesByMode = "max"
FieldColorSeriesByModeMin FieldColorSeriesByMode = "min"
)
// Defines values for GraphPanelType.
const (
GraphPanelTypeGraph GraphPanelType = "graph"
)
// Defines values for HeatmapPanelType.
const (
HeatmapPanelTypeHeatmap HeatmapPanelType = "heatmap"
)
// Defines values for MappingType.
const (
MappingTypeRange MappingType = "range"
MappingTypeRegex MappingType = "regex"
MappingTypeSpecial MappingType = "special"
MappingTypeValue MappingType = "value"
)
// Defines values for PanelRepeatDirection.
const (
PanelRepeatDirectionH PanelRepeatDirection = "h"
PanelRepeatDirectionV PanelRepeatDirection = "v"
)
// Defines values for RangeMapType.
const (
RangeMapTypeRange RangeMapType = "range"
RangeMapTypeRegex RangeMapType = "regex"
RangeMapTypeSpecial RangeMapType = "special"
RangeMapTypeValue RangeMapType = "value"
)
// Defines values for RegexMapType.
const (
RegexMapTypeRange RegexMapType = "range"
RegexMapTypeRegex RegexMapType = "regex"
RegexMapTypeSpecial RegexMapType = "special"
RegexMapTypeValue RegexMapType = "value"
)
// Defines values for RowPanelType.
const (
RowPanelTypeRow RowPanelType = "row"
)
// Defines values for SpecStyle.
const (
SpecStyleDark SpecStyle = "dark"
SpecStyleLight SpecStyle = "light"
)
// Defines values for SpecialValueMapType.
const (
SpecialValueMapTypeRange SpecialValueMapType = "range"
SpecialValueMapTypeRegex SpecialValueMapType = "regex"
SpecialValueMapTypeSpecial SpecialValueMapType = "special"
SpecialValueMapTypeValue SpecialValueMapType = "value"
)
// Defines values for SpecialValueMatch.
const (
SpecialValueMatchEmpty SpecialValueMatch = "empty"
SpecialValueMatchFalse SpecialValueMatch = "false"
SpecialValueMatchNan SpecialValueMatch = "nan"
SpecialValueMatchNull SpecialValueMatch = "null"
SpecialValueMatchNullNan SpecialValueMatch = "null+nan"
SpecialValueMatchTrue SpecialValueMatch = "true"
)
// Defines values for ThresholdsMode.
const (
ThresholdsModeAbsolute ThresholdsMode = "absolute"
ThresholdsModePercentage ThresholdsMode = "percentage"
)
// Defines values for ValueMapType.
const (
ValueMapTypeRange ValueMapType = "range"
ValueMapTypeRegex ValueMapType = "regex"
ValueMapTypeSpecial ValueMapType = "special"
ValueMapTypeValue ValueMapType = "value"
)
// Defines values for VariableHide.
const (
VariableHideN0 VariableHide = 0
VariableHideN1 VariableHide = 1
VariableHideN2 VariableHide = 2
)
// Defines values for VariableRefresh.
const (
VariableRefreshN0 VariableRefresh = 0
VariableRefreshN1 VariableRefresh = 1
VariableRefreshN2 VariableRefresh = 2
)
// Defines values for VariableType.
const (
VariableTypeAdhoc VariableType = "adhoc"
VariableTypeConstant VariableType = "constant"
VariableTypeCustom VariableType = "custom"
VariableTypeDatasource VariableType = "datasource"
VariableTypeInterval VariableType = "interval"
VariableTypeQuery VariableType = "query"
VariableTypeSystem VariableType = "system"
VariableTypeTextbox VariableType = "textbox"
)
// Contains the list of annotations that are associated with the dashboard.
// Annotations are used to overlay event markers and overlay event tags on graphs.
// Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
// See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
type AnnotationContainer struct {
// List of annotations
List []AnnotationQuery `json:"list,omitempty"`
}
// AnnotationPanelFilter defines model for AnnotationPanelFilter.
type AnnotationPanelFilter struct {
// Should the specified panels be included or excluded
Exclude *bool `json:"exclude,omitempty"`
// Panel IDs that should be included or excluded
Ids []int `json:"ids"`
}
// TODO docs
// FROM: AnnotationQuery in grafana-data/src/types/annotations.ts
type AnnotationQuery struct {
// Ref to a DataSource instance
Datasource DataSourceRef `json:"datasource"`
// When enabled the annotation query is issued with every dashboard refresh
Enable bool `json:"enable"`
Filter *AnnotationPanelFilter `json:"filter,omitempty"`
// Annotation queries can be toggled on or off at the top of the dashboard.
// When hide is true, the toggle is not shown in the dashboard.
Hide *bool `json:"hide,omitempty"`
// Color to use for the annotation event markers
IconColor string `json:"iconColor"`
// Name of annotation.
Name string `json:"name"`
// TODO: this should be a regular DataQuery that depends on the selected dashboard
// these match the properties of the "grafana" datasouce that is default in most dashboards
Target *AnnotationTarget `json:"target,omitempty"`
// TODO -- this should not exist here, it is based on the --grafana-- datasource
Type *string `json:"type,omitempty"`
}
// TODO: this should be a regular DataQuery that depends on the selected dashboard
// these match the properties of the "grafana" datasouce that is default in most dashboards
type AnnotationTarget struct {
// Only required/valid for the grafana datasource...
// but code+tests is already depending on it so hard to change
Limit int64 `json:"limit"`
// Only required/valid for the grafana datasource...
// but code+tests is already depending on it so hard to change
MatchAny bool `json:"matchAny"`
// Only required/valid for the grafana datasource...
// but code+tests is already depending on it so hard to change
Tags []string `json:"tags"`
// Only required/valid for the grafana datasource...
// but code+tests is already depending on it so hard to change
Type string `json:"type"`
}
// 0 for no shared crosshair or tooltip (default).
// 1 for shared crosshair.
// 2 for shared crosshair AND shared tooltip.
type CursorSync int
// Links with references to other dashboards or external resources
type Link struct {
// If true, all dashboards links will be displayed in a dropdown. If false, all dashboards links will be displayed side by side. Only valid if the type is dashboards
AsDropdown bool `json:"asDropdown"`
// Icon name to be displayed with the link
Icon string `json:"icon"`
// If true, includes current template variables values in the link as query params
IncludeVars bool `json:"includeVars"`
// If true, includes current time range in the link as query params
KeepTime bool `json:"keepTime"`
// List of tags to limit the linked dashboards. If empty, all dashboards will be displayed. Only valid if the type is dashboards
Tags []string `json:"tags"`
// If true, the link will be opened in a new tab
TargetBlank bool `json:"targetBlank"`
// Title to display with the link
Title string `json:"title"`
// Tooltip to display when the user hovers their mouse over it
Tooltip string `json:"tooltip"`
// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)
Type LinkType `json:"type"`
// Link URL. Only required/valid if the type is link
Url string `json:"url"`
}
// Dashboard Link type. Accepted values are dashboards (to refer to another dashboard) and link (to refer to an external resource)
type LinkType string
// Ref to a DataSource instance
type DataSourceRef struct {
// The plugin type-id
Type *string `json:"type,omitempty"`
// Specific datasource instance
Uid *string `json:"uid,omitempty"`
}
// Transformations allow to manipulate data returned by a query before the system applies a visualization.
// Using transformations you can: rename fields, join time series data, perform mathematical operations across queries,
// use the output of one transformation as the input to another transformation, etc.
type DataTransformerConfig struct {
// Disabled transformations are skipped
Disabled *bool `json:"disabled,omitempty"`
// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type.
Filter *MatcherConfig `json:"filter,omitempty"`
// Unique identifier of transformer
Id string `json:"id"`
// Options to be passed to the transformer
// Valid options depend on the transformer id
Options any `json:"options"`
}
// DynamicConfigValue defines model for DynamicConfigValue.
type DynamicConfigValue struct {
Id string `json:"id"`
Value *any `json:"value,omitempty"`
}
// Map a field to a color.
type FieldColor struct {
// The fixed color value for fixed or shades color modes.
FixedColor *string `json:"fixedColor,omitempty"`
// Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value.
// Continuous color interpolates a color using the percentage of a value relative to min and max.
// Accepted values are:
// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold
// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations
// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations
// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode
// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode
// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode
// `continuous-YlRd`: Continuous Yellow-Red palette mode
// `continuous-BlPu`: Continuous Blue-Purple palette mode
// `continuous-YlBl`: Continuous Yellow-Blue palette mode
// `continuous-blues`: Continuous Blue palette mode
// `continuous-reds`: Continuous Red palette mode
// `continuous-greens`: Continuous Green palette mode
// `continuous-purples`: Continuous Purple palette mode
// `shades`: Shades of a single color. Specify a single color, useful in an override rule.
// `fixed`: Fixed color mode. Specify a single color, useful in an override rule.
Mode FieldColorModeId `json:"mode"`
// Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.
SeriesBy *FieldColorSeriesByMode `json:"seriesBy,omitempty"`
}
// Color mode for a field. You can specify a single color, or select a continuous (gradient) color schemes, based on a value.
// Continuous color interpolates a color using the percentage of a value relative to min and max.
// Accepted values are:
// `thresholds`: From thresholds. Informs Grafana to take the color from the matching threshold
// `palette-classic`: Classic palette. Grafana will assign color by looking up a color in a palette by series index. Useful for Graphs and pie charts and other categorical data visualizations
// `palette-classic-by-name`: Classic palette (by name). Grafana will assign color by looking up a color in a palette by series name. Useful for Graphs and pie charts and other categorical data visualizations
// `continuous-GrYlRd`: ontinuous Green-Yellow-Red palette mode
// `continuous-RdYlGr`: Continuous Red-Yellow-Green palette mode
// `continuous-BlYlRd`: Continuous Blue-Yellow-Red palette mode
// `continuous-YlRd`: Continuous Yellow-Red palette mode
// `continuous-BlPu`: Continuous Blue-Purple palette mode
// `continuous-YlBl`: Continuous Yellow-Blue palette mode
// `continuous-blues`: Continuous Blue palette mode
// `continuous-reds`: Continuous Red palette mode
// `continuous-greens`: Continuous Green palette mode
// `continuous-purples`: Continuous Purple palette mode
// `shades`: Shades of a single color. Specify a single color, useful in an override rule.
// `fixed`: Fixed color mode. Specify a single color, useful in an override rule.
type FieldColorModeId string
// Defines how to assign a series color from "by value" color schemes. For example for an aggregated data points like a timeseries, the color can be assigned by the min, max or last value.
type FieldColorSeriesByMode string
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
// Each column within this structure is called a field. A field can represent a single time series or table column.
// Field options allow you to change how the data is displayed in your visualizations.
type FieldConfig struct {
// Map a field to a color.
Color *FieldColor `json:"color,omitempty"`
// custom is specified by the FieldConfig field
// in panel plugin schemas.
Custom map[string]any `json:"custom,omitempty"`
// Specify the number of decimals Grafana includes in the rendered value.
// If you leave this field blank, Grafana automatically truncates the number of decimals based on the value.
// For example 1.1234 will display as 1.12 and 100.456 will display as 100.
// To display all decimals, set the unit to `String`.
Decimals *float32 `json:"decimals,omitempty"`
// Human readable field metadata
Description *string `json:"description,omitempty"`
// The display value for this field. This supports template variables blank is auto
DisplayName *string `json:"displayName,omitempty"`
// This can be used by data sources that return and explicit naming structure for values and labels
// When this property is configured, this value is used rather than the default naming strategy.
DisplayNameFromDS *string `json:"displayNameFromDS,omitempty"`
// True if data source field supports ad-hoc filters
Filterable *bool `json:"filterable,omitempty"`
// The behavior when clicking on a result
Links []any `json:"links,omitempty"`
// Convert input values into a display string
Mappings []any `json:"mappings,omitempty"`
// The maximum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
Max *float32 `json:"max,omitempty"`
// The minimum value used in percentage threshold calculations. Leave blank for auto calculation based on all series and fields.
Min *float32 `json:"min,omitempty"`
// Alternative to empty string
NoValue *string `json:"noValue,omitempty"`
// An explicit path to the field in the datasource. When the frame meta includes a path,
// This will default to `${frame.meta.path}/${field.name}
//
// When defined, this value can be used as an identifier within the datasource scope, and
// may be used to update the results
Path *string `json:"path,omitempty"`
// Thresholds configuration for the panel
Thresholds *ThresholdsConfig `json:"thresholds,omitempty"`
// Unit a field should use. The unit you select is applied to all fields except time.
// You can use the units ID availables in Grafana or a custom unit.
// Available units in Grafana: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/valueFormats/categories.ts
// As custom unit, you can use the following formats:
// `suffix:<suffix>` for custom unit that should go after value.
// `prefix:<prefix>` for custom unit that should go before value.
// `time:<format>` For custom date time formats type for example `time:YYYY-MM-DD`.
// `si:<base scale><unit characters>` for custom SI units. For example: `si: mF`. This one is a bit more advanced as you can specify both a unit and the source data scale. So if your source data is represented as milli (thousands of) something prefix the unit with that SI scale character.
// `count:<unit>` for a custom count unit.
// `currency:<unit>` for custom a currency unit.
Unit *string `json:"unit,omitempty"`
// True if data source can write a value to the path. Auth/authz are supported separately
Writeable *bool `json:"writeable,omitempty"`
}
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
// Each column within this structure is called a field. A field can represent a single time series or table column.
// Field options allow you to change how the data is displayed in your visualizations.
type FieldConfigSource struct {
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
// Each column within this structure is called a field. A field can represent a single time series or table column.
// Field options allow you to change how the data is displayed in your visualizations.
Defaults FieldConfig `json:"defaults"`
// Overrides are the options applied to specific fields overriding the defaults.
Overrides []struct {
// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type.
Matcher MatcherConfig `json:"matcher"`
Properties []DynamicConfigValue `json:"properties"`
} `json:"overrides"`
}
// Support for legacy graph panel.
// @deprecated this a deprecated panel type
type GraphPanel struct {
// @deprecated this is part of deprecated graph panel
Legend *struct {
Show bool `json:"show"`
Sort *string `json:"sort,omitempty"`
SortDesc *bool `json:"sortDesc,omitempty"`
} `json:"legend,omitempty"`
Type GraphPanelType `json:"type"`
}
// GraphPanelType defines model for GraphPanel.Type.
type GraphPanelType string
// Position and dimensions of a panel in the grid
type GridPos struct {
// Panel height. The height is the number of rows from the top edge of the panel.
H int `json:"h"`
// Whether the panel is fixed within the grid. If true, the panel will not be affected by other panels' interactions
Static *bool `json:"static,omitempty"`
// Panel width. The width is the number of columns from the left edge of the panel.
W int `json:"w"`
// Panel x. The x coordinate is the number of columns from the left edge of the grid
X int `json:"x"`
// Panel y. The y coordinate is the number of rows from the top edge of the grid
Y int `json:"y"`
}
// Support for legacy heatmap panel.
// @deprecated this a deprecated panel type
type HeatmapPanel struct {
Type HeatmapPanelType `json:"type"`
}
// HeatmapPanelType defines model for HeatmapPanel.Type.
type HeatmapPanelType string
// A library panel is a reusable panel that you can use in any dashboard.
// When you make a change to a library panel, that change propagates to all instances of where the panel is used.
// Library panels streamline reuse of panels across multiple dashboards.
type LibraryPanelRef struct {
// Library panel name
Name string `json:"name"`
// Library panel uid
Uid string `json:"uid"`
}
// Supported value mapping types
// `value`: Maps text values to a color or different display text and color. For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
// `range`: Maps numerical ranges to a display text and color. For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
// `regex`: Maps regular expressions to replacement text and a color. For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
// `special`: Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color. See SpecialValueMatch to see the list of special values. For example, you can configure a special value mapping so that null values appear as N/A.
type MappingType string
// Matcher is a predicate configuration. Based on the config a set of field(s) or values is filtered in order to apply override / transformation.
// It comes with in id ( to resolve implementation from registry) and a configuration that’s specific to a particular matcher type.
type MatcherConfig struct {
// The matcher id. This is used to find the matcher implementation from registry.
Id string `json:"id"`
// The matcher options. This is specific to the matcher implementation.
Options *any `json:"options,omitempty"`
}
// Dashboard panels are the basic visualization building blocks.
type Panel struct {
// Ref to a DataSource instance
Datasource *DataSourceRef `json:"datasource,omitempty"`
// Panel description.
Description *string `json:"description,omitempty"`
// The data model used in Grafana, namely the data frame, is a columnar-oriented table structure that unifies both time series and table query results.
// Each column within this structure is called a field. A field can represent a single time series or table column.
// Field options allow you to change how the data is displayed in your visualizations.
FieldConfig FieldConfigSource `json:"fieldConfig"`
// Position and dimensions of a panel in the grid
GridPos *GridPos `json:"gridPos,omitempty"`
// Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
Id *int `json:"id,omitempty"`
// The min time interval setting defines a lower limit for the $__interval and $__interval_ms variables.
// This value must be formatted as a number followed by a valid time
// identifier like: "40s", "3d", etc.
// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
Interval *string `json:"interval,omitempty"`
// A library panel is a reusable panel that you can use in any dashboard.
// When you make a change to a library panel, that change propagates to all instances of where the panel is used.
// Library panels streamline reuse of panels across multiple dashboards.
LibraryPanel *LibraryPanelRef `json:"libraryPanel,omitempty"`
// Panel links.
Links []Link `json:"links,omitempty"`
// The maximum number of data points that the panel queries are retrieving.
MaxDataPoints *float32 `json:"maxDataPoints,omitempty"`
// It depends on the panel plugin. They are specified by the Options field in panel plugin schemas.
Options map[string]any `json:"options"`
// The version of the plugin that is used for this panel. This is used to find the plugin to display the panel and to migrate old panel configs.
PluginVersion *string `json:"pluginVersion,omitempty"`
// Name of template variable to repeat for.
Repeat *string `json:"repeat,omitempty"`
// Direction to repeat in if 'repeat' is set.
// `h` for horizontal, `v` for vertical.
RepeatDirection *PanelRepeatDirection `json:"repeatDirection,omitempty"`
// Id of the repeating panel.
RepeatPanelId *int64 `json:"repeatPanelId,omitempty"`
// Tags for the panel.
Tags []string `json:"tags,omitempty"`
// Depends on the panel plugin. See the plugin documentation for details.
Targets []Target `json:"targets,omitempty"`
// Overrides the relative time range for individual panels,
// which causes them to be different than what is selected in
// the dashboard time picker in the top-right corner of the dashboard. You can use this to show metrics from different
// time periods or days on the same dashboard.
// The value is formatted as time operation like: `now-5m` (Last 5 minutes), `now/d` (the day so far),
// `now-5d/d`(Last 5 days), `now/w` (This week so far), `now-2y/y` (Last 2 years).
// Note: Panel time overrides have no effect when the dashboard’s time range is absolute.
// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
TimeFrom *string `json:"timeFrom,omitempty"`
// Overrides the time range for individual panels by shifting its start and end relative to the time picker.
// For example, you can shift the time range for the panel to be two hours earlier than the dashboard time picker setting `2h`.
// Note: Panel time overrides have no effect when the dashboard’s time range is absolute.
// See: https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/#query-options
TimeShift *string `json:"timeShift,omitempty"`
// Panel title.
Title *string `json:"title,omitempty"`
// List of transformations that are applied to the panel data before rendering.
// When there are multiple transformations, Grafana applies them in the order they are listed.
// Each transformation creates a result set that then passes on to the next transformation in the processing pipeline.
Transformations []DataTransformerConfig `json:"transformations"`
// Whether to display the panel without a background.
Transparent bool `json:"transparent"`
// The panel plugin type id. This is used to find the plugin to display the panel.
Type string `json:"type"`
}
// Direction to repeat in if 'repeat' is set.
// `h` for horizontal, `v` for vertical.
type PanelRepeatDirection string
// Maps numerical ranges to a display text and color.
// For example, if a value is within a certain range, you can configure a range value mapping to display Low or High rather than the number.
type RangeMap struct {
// Range to match against and the result to apply when the value is within the range
Options struct {
// Min value of the range. It can be null which means -Infinity
From *float64 `json:"from"`
// Result used as replacement with text and color when the value matches
Result ValueMappingResult `json:"result"`
// Max value of the range. It can be null which means +Infinity
To *float64 `json:"to"`
} `json:"options"`
Type RangeMapType `json:"type"`
}
// RangeMapType defines model for RangeMap.Type.
type RangeMapType string
// Maps regular expressions to replacement text and a color.
// For example, if a value is www.example.com, you can configure a regex value mapping so that Grafana displays www and truncates the domain.
type RegexMap struct {
// Regular expression to match against and the result to apply when the value matches the regex
Options struct {
// Regular expression to match against
Pattern string `json:"pattern"`
// Result used as replacement with text and color when the value matches
Result ValueMappingResult `json:"result"`
} `json:"options"`
Type RegexMapType `json:"type"`
}
// RegexMapType defines model for RegexMap.Type.
type RegexMapType string
// Row panel
type RowPanel struct {
// Whether this row should be collapsed or not.
Collapsed bool `json:"collapsed"`
// Ref to a DataSource instance
Datasource *DataSourceRef `json:"datasource,omitempty"`
// Position and dimensions of a panel in the grid
GridPos *GridPos `json:"gridPos,omitempty"`
// Unique identifier of the panel. Generated by Grafana when creating a new panel. It must be unique within a dashboard, but not globally.
Id int `json:"id"`
// List of panels in the row
Panels []any `json:"panels"`
// Name of template variable to repeat for.
Repeat *string `json:"repeat,omitempty"`
// Row title
Title *string `json:"title,omitempty"`
// The panel type
Type RowPanelType `json:"type"`
}
// The panel type
type RowPanelType string
// A dashboard snapshot shares an interactive dashboard publicly.
// It is a read-only version of a dashboard, and is not editable.
// It is possible to create a snapshot of a snapshot.
// Grafana strips away all sensitive information from the dashboard.
// Sensitive information stripped: queries (metric, template,annotation) and panel links.
type Snapshot struct {
// Time when the snapshot was created
Created time.Time `json:"created"`
// Time when the snapshot expires, default is never to expire
Expires string `json:"expires"`
// Is the snapshot saved in an external grafana instance
External bool `json:"external"`
// ExternalUrl external url, if snapshot was shared in external grafana instance
ExternalUrl string `json:"externalUrl"`
// Unique identifier of the snapshot
Id int `json:"id"`
// Optional, defined the unique key of the snapshot, required if external is true
Key string `json:"key"`
// Optional, name of the snapshot
Name string `json:"name"`
// OrgId org id of the snapshot
OrgId int `json:"orgId"`
// Updated last time when the snapshot was updated
Updated time.Time `json:"updated"`
// url of the snapshot, if snapshot was shared internally
Url *string `json:"url,omitempty"`
// UserId user id of the snapshot creator
UserId int `json:"userId"`
}
// Spec defines model for Spec.
type Spec struct {
// Contains the list of annotations that are associated with the dashboard.
// Annotations are used to overlay event markers and overlay event tags on graphs.
// Grafana comes with a native annotation store and the ability to add annotation events directly from the graph panel or via the HTTP API.
// See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/
Annotations *AnnotationContainer `json:"annotations,omitempty"`
// Description of dashboard.
Description *string `json:"description,omitempty"`
// Whether a dashboard is editable or not.
Editable bool `json:"editable"`
// The month that the fiscal year starts on. 0 = January, 11 = December
FiscalYearStartMonth *int `json:"fiscalYearStartMonth,omitempty"`
// ID of a dashboard imported from the https://grafana.com/grafana/dashboards/ portal
GnetId *string `json:"gnetId,omitempty"`
// 0 for no shared crosshair or tooltip (default).
// 1 for shared crosshair.
// 2 for shared crosshair AND shared tooltip.
GraphTooltip CursorSync `json:"graphTooltip"`
// Unique numeric identifier for the dashboard.
// `id` is internal to a specific Grafana instance. `uid` should be used to identify a dashboard across Grafana instances.
Id *int64 `json:"id"`
// Links with references to other dashboards or external websites.
Links []Link `json:"links,omitempty"`
// When set to true, the dashboard will redraw panels at an interval matching the pixel width.
// This will keep data "moving left" regardless of the query refresh rate. This setting helps
// avoid dashboards presenting stale live data
LiveNow *bool `json:"liveNow,omitempty"`
// List of dashboard panels
Panels []any `json:"panels,omitempty"`
// Refresh rate of dashboard. Represented via interval string, e.g. "5s", "1m", "1h", "1d".
Refresh *any `json:"refresh,omitempty"`
// This property should only be used in dashboards defined by plugins. It is a quick check
// to see if the version has changed since the last time.
Revision *int64 `json:"revision,omitempty"`
// Version of the JSON schema, incremented each time a Grafana update brings
// changes to said schema.
SchemaVersion int `json:"schemaVersion"`
// A dashboard snapshot shares an interactive dashboard publicly.
// It is a read-only version of a dashboard, and is not editable.
// It is possible to create a snapshot of a snapshot.
// Grafana strips away all sensitive information from the dashboard.
// Sensitive information stripped: queries (metric, template,annotation) and panel links.
Snapshot *Snapshot `json:"snapshot,omitempty"`
// Theme of dashboard.
// Default value: dark.
Style SpecStyle `json:"style"`
// Tags associated with dashboard.
Tags []string `json:"tags,omitempty"`
// Configured template variables
Templating *struct {
// List of configured template variables with their saved values along with some other metadata
List []VariableModel `json:"list,omitempty"`
} `json:"templating,omitempty"`
// Time range for dashboard.
// Accepted values are relative time strings like {from: 'now-6h', to: 'now'} or absolute time strings like {from: '2020-07-10T08:00:00.000Z', to: '2020-07-10T14:00:00.000Z'}.
Time *struct {
From string `json:"from"`
To string `json:"to"`
} `json:"time,omitempty"`
// Configuration of the time picker shown at the top of a dashboard.
Timepicker *struct {
// Whether timepicker is collapsed or not. Has no effect on provisioned dashboard.
Collapse bool `json:"collapse"`
// Whether timepicker is enabled or not. Has no effect on provisioned dashboard.
Enable bool `json:"enable"`
// Whether timepicker is visible or not.
Hidden bool `json:"hidden"`
// Interval options available in the refresh picker dropdown.
RefreshIntervals []string `json:"refresh_intervals"`
// Selectable options available in the time picker dropdown. Has no effect on provisioned dashboard.
TimeOptions []string `json:"time_options"`
} `json:"timepicker,omitempty"`
// Timezone of dashboard. Accepted values are IANA TZDB zone ID or "browser" or "utc".
Timezone *string `json:"timezone,omitempty"`
// Title of dashboard.
Title *string `json:"title,omitempty"`
// Unique dashboard identifier that can be generated by anyone. string (8-40)
Uid *string `json:"uid,omitempty"`
// Version of the dashboard, incremented each time the dashboard is updated.
Version *int `json:"version,omitempty"`
// Day when the week starts. Expressed by the name of the day in lowercase, e.g. "monday".
WeekStart *string `json:"weekStart,omitempty"`
}
// Theme of dashboard.
// Default value: dark.
type SpecStyle string
// Maps special values like Null, NaN (not a number), and boolean values like true and false to a display text and color.
// See SpecialValueMatch to see the list of special values.
// For example, you can configure a special value mapping so that null values appear as N/A.
type SpecialValueMap struct {
Options struct {
// Special value types supported by the `SpecialValueMap`
Match SpecialValueMatch `json:"match"`
// Result used as replacement with text and color when the value matches
Result ValueMappingResult `json:"result"`
} `json:"options"`
Type SpecialValueMapType `json:"type"`
}
// SpecialValueMapType defines model for SpecialValueMap.Type.
type SpecialValueMapType string
// Special value types supported by the `SpecialValueMap`
type SpecialValueMatch string
// Schema for panel targets is specified by datasource
// plugins. We use a placeholder definition, which the Go
// schema loader either left open/as-is with the Base
// variant of the Dashboard and Panel families, or filled
// with types derived from plugins in the Instance variant.
// When working directly from CUE, importers can extend this
// type directly to achieve the same effect.
type Target = map[string]any
// User-defined value for a metric that triggers visual changes in a panel when this value is met or exceeded
// They are used to conditionally style and color visualizations based on query results , and can be applied to most visualizations.
type Threshold struct {
// Color represents the color of the visual change that will occur in the dashboard when the threshold value is met or exceeded.
Color string `json:"color"`
// Value represents a specified metric for the threshold, which triggers a visual change in the dashboard when this value is met or exceeded.
// Nulls currently appear here when serializing -Infinity to JSON.
Value *float32 `json:"value"`
}
// Thresholds configuration for the panel
type ThresholdsConfig struct {
// Thresholds can either be `absolute` (specific number) or `percentage` (relative to min or max, it will be values between 0 and 1).
Mode ThresholdsMode `json:"mode"`
// Must be sorted by 'value', first value is always -Infinity
Steps []Threshold `json:"steps"`
}
// Thresholds can either be `absolute` (specific number) or `percentage` (relative to min or max, it will be values between 0 and 1).
type ThresholdsMode string
// Maps text values to a color or different display text and color.
// For example, you can configure a value mapping so that all instances of the value 10 appear as Perfection! rather than the number.
type ValueMap struct {
// Map with <value_to_match>: ValueMappingResult. For example: { "10": { text: "Perfection!", color: "green" } }
Options map[string]ValueMappingResult `json:"options"`
Type ValueMapType `json:"type"`
}
// ValueMapType defines model for ValueMap.Type.
type ValueMapType string
// Result used as replacement with text and color when the value matches
type ValueMappingResult struct {
// Text to use when the value matches
Color *string `json:"color,omitempty"`
// Icon to display when the value matches. Only specific visualizations.
Icon *string `json:"icon,omitempty"`
// Position in the mapping array. Only used internally.
Index *int32 `json:"index,omitempty"`
// Text to display when the value matches
Text *string `json:"text,omitempty"`
}
// Determine if the variable shows on dashboard
// Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
type VariableHide int
// A variable is a placeholder for a value. You can use variables in metric queries and in panel titles.
type VariableModel struct {
// Format to use while fetching all values from data source, eg: wildcard, glob, regex, pipe, etc.
AllFormat *string `json:"allFormat,omitempty"`
// Option to be selected in a variable.
Current *VariableOption `json:"current,omitempty"`
// Ref to a DataSource instance
Datasource *DataSourceRef `json:"datasource,omitempty"`
// Description of variable. It can be defined but `null`.
Description *string `json:"description,omitempty"`
// Determine if the variable shows on dashboard
// Accepted values are 0 (show label and value), 1 (show value only), 2 (show nothing).
Hide VariableHide `json:"hide"`
// Unique numeric identifier for the variable.
Id string `json:"id"`
// Optional display name
Label *string `json:"label,omitempty"`
// Whether multiple values can be selected or not from variable value list
Multi *bool `json:"multi,omitempty"`
// Name of variable
Name string `json:"name"`
// Options that can be selected for a variable.
Options []VariableOption `json:"options,omitempty"`
// Query used to fetch values for a variable
Query *any `json:"query,omitempty"`
// Options to config when to refresh a variable
// `0`: Never refresh the variable
// `1`: Queries the data source every time the dashboard loads.
// `2`: Queries the data source when the dashboard time range changes.
Refresh *VariableRefresh `json:"refresh,omitempty"`
// Whether the variable value should be managed by URL query params or not
SkipUrlSync bool `json:"skipUrlSync"`
// Dashboard variable type
// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
// `constant`: Define a hidden constant.
// `datasource`: Quickly change the data source for an entire dashboard.
// `interval`: Interval variables represent time spans.
// `textbox`: Display a free text input field with an optional default value.
// `custom`: Define the variable options manually using a comma-separated list.
// `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
Type VariableType `json:"type"`
}
// Option to be selected in a variable.
type VariableOption struct {
// Whether the option is selected or not
Selected *bool `json:"selected,omitempty"`
// Text to be displayed for the option
Text any `json:"text"`
// Value of the option
Value any `json:"value"`
}
// Options to config when to refresh a variable
// `0`: Never refresh the variable
// `1`: Queries the data source every time the dashboard loads.
// `2`: Queries the data source when the dashboard time range changes.
type VariableRefresh int
// Dashboard variable type
// `query`: Query-generated list of values such as metric names, server names, sensor IDs, data centers, and so on.
// `adhoc`: Key/value filters that are automatically added to all metric queries for a data source (Prometheus, Loki, InfluxDB, and Elasticsearch only).
// `constant`: Define a hidden constant.
// `datasource`: Quickly change the data source for an entire dashboard.
// `interval`: Interval variables represent time spans.
// `textbox`: Display a free text input field with an optional default value.
// `custom`: Define the variable options manually using a comma-separated list.
// `system`: Variables defined by Grafana. See: https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/#global-variables
type VariableType string