You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Uses (jsonnet)[https://jsonnet.org/learning/tutorial.html], jsonnet-bundler, and grafonnet[https://github.com/grafana/grafonnet]
79
+
- Uses [jsonnet](https://jsonnet.org/learning/tutorial.html), jsonnet-bundler, and [grafonnet](https://github.com/grafana/grafonnet)
80
80
- Highly customizable and flexible:
81
81
82
-
Any object like `panel`, `target` (query) can be easily referenced by key and then overriden before output of the lib is provided by using jsonnet (patching)[https://tanka.dev/tutorial/environments#patching] technique:
82
+
Any object like `panel`, `target` (query) can be easily referenced by key and then overriden before output of the lib is provided by using jsonnet [patching](https://tanka.dev/tutorial/environments#patching) technique:
### Example 2: Monitoring-mixin example with custom config
125
+
126
+
127
+
Any modular library should include as mandator configuration paramaters:
128
+
-`filteringSelector` - Static selector to apply to ALL dashboard variables of type query, panel queries, alerts and recording rules.
129
+
-`groupLabels` - one or more labels that can be used to identify 'group' of instances. In simple cases, can be 'job' or 'cluster'.
130
+
-`instanceLabels` - one or more labels that can be used to identify single entity of instances. In simple cases, can be 'instance' or 'pod'.
131
+
-`uid` - UID to prefix all dashboards original uids
132
+
-`dashboardNamePrefix` - Use as prefix for all Dashboards and (optional) rule groups
133
+
134
+
By changing those you can install same mixin two or more times into same Grafana/Prometheus, or import them into other mixins, without any potential problem of conflicting dashboard ids or intersecting PromQL queries:
135
+
136
+
First:
137
+
138
+
```
139
+
local helloworldlib = import './main.libsonnet';
140
+
141
+
local helloworld =
142
+
helloworldlib.new()
143
+
+ helloworldlib.withConfigMixin(
144
+
{
145
+
filteringSelector: 'job=~"integrations/first"',
146
+
uid: 'firsthelloworld',
147
+
groupLabels: ['environment', 'cluster', 'job'],
148
+
instanceLabels: ['instance'],
149
+
}
125
150
);
126
151
127
152
// populate monitoring-mixin:
@@ -132,23 +157,43 @@ local helloworld =
132
157
}
133
158
```
134
159
135
-
### Example 2: Changing specific panel before rendering dashboards
160
+
Second:
136
161
137
-
We can point to any object (i.e grafana.panels.panel1) and modify it by using (jsonnnet mixins)[https://jsonnet.org/learning/tutorial.html].
162
+
```
163
+
local helloworldlib = import './main.libsonnet';
138
164
139
-
For example, let's modify panel's default draw style to bars by mutating it with (grafonnet)[https://grafana.github.io/grafonnet/API/panel/timeSeries/index.html#fn-fieldconfigdefaultscustomwithdrawstyle]
### Example 3: Changing specific panel before rendering dashboards
186
+
187
+
We can point to any object (i.e grafana.panels.panel1) and modify it by using [jsonnnet mixins](https://jsonnet.org/learning/tutorial.html).
188
+
189
+
For example, let's modify panel's default draw style to bars by mutating it with [grafonnet](https://grafana.github.io/grafonnet/API/panel/timeSeries/index.html#fn-fieldconfigdefaultscustomwithdrawstyle):
140
190
141
191
```
142
192
local g = import './g.libsonnet';
143
193
local helloworldlib = import 'helloworld-observ-lib/main.libsonnet';
0 commit comments