forked from grafana/grafonnet-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.libsonnet
87 lines (79 loc) · 2.6 KB
/
dashboard.libsonnet
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
// This file was generated by https://github.com/grafana/dashboard-spec
{
new(
description=null,
editable=true,
graphTooltip=0,
refresh=null,
schemaVersion=25,
style='dark',
tags=[],
timezone=null,
title=null,
uid=null,
):: {
[if description != null then 'description']: description,
[if editable != null then 'editable']: editable,
[if graphTooltip != null then 'graphTooltip']: graphTooltip,
[if refresh != null then 'refresh']: refresh,
[if schemaVersion != null then 'schemaVersion']: schemaVersion,
[if style != null then 'style']: style,
[if tags != null then 'tags']: tags,
[if timezone != null then 'timezone']: timezone,
[if title != null then 'title']: title,
[if uid != null then 'uid']: uid,
setTime(
from='now-6h',
to='now',
):: self {}
+ { time+: { [if from != null then 'from']: from } }
+ { time+: { [if to != null then 'to']: to } }
,
setTimepicker(
hidden=false,
refreshIntervals=['5s', '10s', '30s', '1m', '5m', '15m', '30m', '1h', '2h', '1d'],
):: self {}
+ { timepicker+: { [if hidden != null then 'hidden']: hidden } }
+ { timepicker+: { [if refreshIntervals != null then 'refresh_intervals']: refreshIntervals } }
,
addTemplate(
template
):: self {}
+ { templating+: { list+: [
template,
] } },
addAnnotation(
builtIn=0,
datasource='default',
enable=true,
hide=false,
iconColor=null,
name=null,
rawQuery=null,
showIn=0,
):: self {}
+ { annotations+: { list+: [
{
[if builtIn != null then 'builtIn']: builtIn,
[if datasource != null then 'datasource']: datasource,
[if enable != null then 'enable']: enable,
[if hide != null then 'hide']: hide,
[if iconColor != null then 'iconColor']: iconColor,
[if name != null then 'name']: name,
[if rawQuery != null then 'rawQuery']: rawQuery,
[if showIn != null then 'showIn']: showIn,
},
] } },
panels: [],
_nextPanelID:: 2,
addPanel(panel):: self {
local nextPanelID = super._nextPanelID,
panels+: [
panel { id: nextPanelID } +
if 'panels' in panel then { panels: std.mapWithIndex(function(i, p) p { id: nextPanelID + i + 1 }, panel.panels) } else {},
],
_nextPanelID:: nextPanelID + 1 + (if 'panels' in panel then std.length(panel.panels) else 0),
},
addPanels(panels):: std.foldl(function(d, p) d.addPanel(p), panels, self),
},
}