-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfield_config.libsonnet
More file actions
275 lines (247 loc) · 13.7 KB
/
Copy pathfield_config.libsonnet
File metadata and controls
275 lines (247 loc) · 13.7 KB
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
{
defaults:: {
thresholdsBaseColor: 'green',
},
new(
color = null, // Map values to a display color.
custom = {},
decimals = null, // Significant digits (for display).
description = null, // Human readable field metadata.
displayName = null, // The display value for this field. This supports template variables blank is auto.
displayNameFromDS = null, // This can be used by data sources that return and explicit naming structure for values and labels.
filterable = null, // True if data source field supports ad-hoc filters.
min = null, // Hard min limit
max = null, // Hard max limit
noValue = null, // Alternative to empty string.
path = null, // An explicit path to the field in the datasource.
unit = null,
thresholds = null,
thresholdsBaseColor = $.defaults.thresholdsBaseColor,
writeable = null, // True if data source can write a value to the path.
overrides = null,
):: {
defaults: {
color: if color != null then color else {
mode: $.colorMode.Classic,
},
custom: custom,
[if decimals != null then 'decimals' ]: decimals,
[if description != null then 'description' ]: description,
[if displayName != null then 'displayName' ]: displayName,
[if displayNameFromDS != null then 'displayNameFromDS']: displayNameFromDS,
[if filterable != null then 'filterable' ]: filterable,
[if min != null then 'min' ]: min,
[if max != null then 'max' ]: max,
[if noValue != null then 'noValue' ]: noValue,
[if path != null then 'path' ]: path,
[if unit != null then 'unit' ]: unit,
[if writeable != null then 'writeable' ]: writeable,
mappings: [],
thresholds: if thresholds != null then thresholds else {
mode: $.thresholdMode.Absolute,
steps: [
{
color: thresholdsBaseColor,
value: null
}
]
},
},
overrides: if overrides != null then overrides else [],
withThresholds(baseColor, steps = []):: $.withThresholds (self, baseColor, steps),
withThresholdStyle(style):: $.withThresholdStyle(self, style),
addThreshold(threshold):: $.addThreshold (self, threshold),
addThresholds(steps):: $.addThresholds (self, steps),
addOverride(override):: $.addOverride (self, override),
addOverrides(overrides):: $.addOverrides (self, overrides),
addMapping(mapping):: $.addMapping (self, mapping),
addMappings(mappings):: $.addMappings (self, mappings),
withColor(mode, fixedColor = null):: $.withColor (self, mode, fixedColor),
withSoftLimit(axisSoftMin = 0,axisSoftMax = 100):: $.withSoftLimit (self, axisSoftMin, axisSoftMax),
withUnit(unit):: $.withUnit (self, unit),
},
withThresholds(_self, baseColor, steps = []):: _self {
defaults+: {
thresholds: {
steps: [
{
color: baseColor,
value: null
}
] + steps,
}
},
},
withThresholdStyle(_self, style):: _self {
defaults+: {
custom+: {
thresholdsStyle+: {
mode: style,
},
},
},
},
addThreshold(_self, threshold):: _self {
defaults+: {
thresholds+: {
steps+: [threshold],
}
}
},
addThresholds(_self, steps):: std.foldl(function(p, s) p.addThreshold(s), steps, _self),
addOverride(_self, override):: _self {
overrides+: [override],
},
addOverrides(_self, overrides):: std.foldl(function(p, s) p.addOverride(s), overrides, _self),
addMapping(_self, mapping):: _self {
defaults+: {
mappings+: [mapping],
}
},
addMappings(_self, mappings):: std.foldl(function(p, m) p.addMapping(m), mappings, _self),
withColor(_self, mode, fixedColor = null):: _self {
defaults+: {
color: {
mode: mode,
[if fixedColor != null then 'fixedColor']: fixedColor,
},
},
},
withSoftLimit(
_self,
axisSoftMin = 0,
axisSoftMax = 100,
):: _self {
defaults+: {
custom+: {
[if axisSoftMin != null then 'axisSoftMin']: axisSoftMin,
[if axisSoftMax != null then 'axisSoftMax']: axisSoftMax,
},
},
},
withUnit(_self, unit):: _self {
defaults+: {
unit: unit,
},
},
//////////////////////////////////////////////////////////////////////////////
// Constants
thresholdMode:: {
Absolute:: 'absolute',
Percentage:: 'percentage',
},
colorMode:: {
Fixed:: 'fixed',
Thresholds:: 'thresholds',
Classic:: 'palette-classic',
GreenYellowRed:: 'continuous-GrYlRd',
RedYellowGreen:: 'continuous-RdYlGr',
BlueYellowRed:: 'continuous-BlYlRd',
YellowRed:: 'continuous-YlRd',
BluePurple:: 'continuous-BlPu',
YellowBlue:: 'continuous-YlBl',
Blues:: 'continuous-blues',
Reds:: 'continuous-reds',
Greens:: 'continuous-greens',
Purples:: 'continuous-purples',
},
thresholdStyle:: {
Off:: 'off',
Line:: 'line',
Dashed:: 'dashed',
Area:: 'area',
LineArea:: 'line+area',
DashedArea:: 'dashed+area',
Fill:: 'fill',
},
units:: {
Number:: 'none',
String:: 'string',
Short:: 'short', // Short
Percent:: 'percent', // Percent (0 - 100)
PercentUnit:: 'percentunit', // Percent (0.0 - 1.0))
Hex0x:: 'hex0x', // Hexadecimal with 0x prefix
Hex:: 'hex', // Hexadecimal
Scientific:: 'sci', // Scientific notation
Local:: 'locale', // Localized number
Bits:: 'bits', // Bits (IEC)
Bytes:: 'bytes', // Bytes (IEC)
Kibibytes:: 'kbytes', // Kibibytes (IEC)
Mebibytes:: 'mbytes', // Mebibytes (IEC)
Gigibytes:: 'gbytes', // Gigibytes (IEC)
Tebibytes:: 'tbytes', // Tebibytes (IEC)
Pebibytes:: 'pbytes', // Pebibytes (IEC)
DecBits:: 'decbits', // Bits (DEC)
DecBytes:: 'decbytes', // Bytes (DEC)
Kilobytes:: 'deckbytes', // Kilobytes (DEC)
Megabytes:: 'decmbytes', // Megabytes (DEC)
Gigabytes:: 'decgbytes', // Gigabytes (DEC)
Terabytes:: 'dectbytes', // Terabytes (DEC)
Petabytes:: 'decpbytes', // Petabytes (DEC)
PacketPerSecond:: 'pps', // Packets per second
BitsPerSecond:: 'binbps', // Bits per second (IEC)
KibibitsPerSecond:: 'Kibits', // Kibibits per second (IEC)
MebibitePerSeconds:: 'MiBs', // Mebibits per second (IEC)
GigibitsPerSeconds:: 'Gibits', // Gigibits per second (IEC)
TebibitsPerSeconds:: 'Tibits', // Tebibits per second (IEC)
PebibitsPerSeconds:: 'Pibits', // Pebibits per second (IEC)
BitsPerSecondDec:: 'bps', // Bits per second (DEC)
KilobitsPerSecond:: 'Kbits', // Kilobits per second (DEC)
MegabitsPerSeconds:: 'Mbits', // Megabits per second (DEC)
GigabitsPerSeconds:: 'Gbits', // Gigabits per second (DEC)
TerabitPerSeconds:: 'Tbits', // Terabits per second (DEC)
PetabitsPerSeconds:: 'Pbits', // Petabits per second (DEC)
BytesPerSecond:: 'binBps', // Bytes per second (IEC)
KibibytesPerSecond:: 'KiBs', // Kibibytes per second (IEC)
MebibytesPerSeconds:: 'MiBs', // Mebibytes per second (IEC)
GigibytesPerSeconds:: 'GiBs', // Gigibytes per second (IEC)
TebibytesPerSeconds:: 'TiBs', // Tebibytes per second (IEC)
PebibytesPerSeconds:: 'PiBs', // Pebibytes per second (IEC)
BytesPerSecondDec:: 'Bps', // Bytes per second (DEC)
KilobytesPerSecond:: 'KBs', // Kilobytes per second (DEC)
MegabytesPerSeconds:: 'MBs', // Megabytes per second (DEC)
GigabytesPerSeconds:: 'GBs', // Gigabytes per second (DEC)
TerabytesPerSeconds:: 'TBs', // Terabytes per second (DEC)
PetabytesPerSeconds:: 'PBs', // Petabytes per second (DEC)
DateTimeIso:: 'dateTimeAsIso', // Date and time in ISO format
DateTimeIsoNoDateIfToday:: 'dateTimeAsIsoNoDateIfToday', // Date and time in ISO format, no date if today
DateTimeUS:: 'dateTimeAsUS', // Date and time in US format
DateTimeUSNoDateIfToday:: 'dateTimeAsUSNoDateIfToday', // Date and time in US format, no date if today
dateTimeLocal:: 'dateTimeAsLocal', // Date and time in local format
dateTimeLocalNoDateIfToday:: 'dateTimeAsLocalNoDateIfToday', // Date and time in local format, no date if today
Nanoseconds:: 'ns', // Nanoseconds
Microseconds:: 'µs', // Microseconds
Milliseconds:: 'ms', // Milliseconds
Seconds:: 's', // Seconds
Minutes:: 'm', // Minutes
Hours:: 'h', // Hours
Days:: 'd', // Days
DurationMilliseconds:: 'dtdurationms', // Duration in milliseconds
DurationSeconds:: 'dtdurations', // Duration in seconds
DurationHMS:: 'dthms', // Duration (hh:mm:ss)
DurationDHMS:: 'dtdhms', // Duration (d hh:mm:ss)
Timeticks:: 'timeticks', // Timeticks (s/100)
ClockMilliseconds:: 'clockms', // Clock in milliseconds
ClockSeconds:: 'clocks', // Clock in seconds
HashesPerSecond:: 'Hs', // Hashes per second
KiloHashesPerSecond:: 'KHs', // Kilo hashes per second
MegaHashesPerSecond:: 'MHs', // Mega hashes per second
GigaHashesPerSecond:: 'GHs', // Giga hashes per second
TeraHashesPerSecond:: 'THs', // Tera hashes per second
PetaHashesPerSecond:: 'PHs', // Peta hashes per second
ExaHashesPerSecond:: 'EHs', // Exa hashes per second
CountsPerSecond:: 'cps', // Counts per second
OpsPerSecond:: 'ops', // Operations per second
RequestsPerSecond:: 'reqps', // Requests per second
ReadsPerSecond:: 'rps', // Reads per second
WritesPerSecond:: 'wps', // Writes per second
IOPerSeconds:: 'iops', // I/O ops per second
CountsPerMinute:: 'cpm', // Counts per minute
OpsPerMinute:: 'opm', // Operations per minute
ReadsPerMinute:: 'rpm', // Reads per minute
WritesPerMinute:: 'wpm', // Writes per minute
TrueFalse:: 'bool', // True / False
YesNo:: 'bool_yes_no', // Yes / No
OnOff:: 'bool_on_off', // On / Off
}
}