|
1 | 1 | local g = import 'github.com/grafana/grafonnet/gen/grafonnet-latest/main.libsonnet'; |
2 | 2 | local defaultQueries = import './queries/cluster-queries.libsonnet'; |
| 3 | +local defaultVariables = import './variables/cluster-variables.libsonnet'; |
3 | 4 |
|
4 | 5 | local prometheus = g.query.prometheus; |
5 | 6 | local stat = g.panel.stat; |
@@ -41,36 +42,10 @@ local var = g.dashboard.variable; |
41 | 42 | then $._queries.cluster |
42 | 43 | else defaultQueries; |
43 | 44 |
|
44 | | - local variables = { |
45 | | - datasource: |
46 | | - var.datasource.new('datasource', 'prometheus') |
47 | | - + var.datasource.withRegex($._config.datasourceFilterRegex) |
48 | | - + var.datasource.generalOptions.showOnDashboard.withLabelAndValue() |
49 | | - + var.datasource.generalOptions.withLabel('Data source') |
50 | | - + { |
51 | | - current: { |
52 | | - selected: true, |
53 | | - text: $._config.datasourceName, |
54 | | - value: $._config.datasourceName, |
55 | | - }, |
56 | | - }, |
57 | | - |
58 | | - cluster: |
59 | | - var.query.new('cluster') |
60 | | - + var.query.withDatasourceFromVariable(self.datasource) |
61 | | - + var.query.queryTypes.withLabelValues( |
62 | | - $._config.clusterLabel, |
63 | | - 'up{%(cadvisorSelector)s}' % $._config, |
64 | | - ) |
65 | | - + var.query.generalOptions.withLabel('cluster') |
66 | | - + var.query.refresh.onTime() |
67 | | - + ( |
68 | | - if $._config.showMultiCluster |
69 | | - then var.query.generalOptions.showOnDashboard.withLabelAndValue() |
70 | | - else var.query.generalOptions.showOnDashboard.withNothing() |
71 | | - ) |
72 | | - + var.query.withSort(type='alphabetical'), |
73 | | - }; |
| 45 | + // Allow overriding variables via $._variables.cluster, otherwise use default |
| 46 | + local variables = if std.objectHas($, '_variables') && std.objectHas($._variables, 'cluster') |
| 47 | + then $._variables.cluster($._config) |
| 48 | + else defaultVariables.cluster($._config); |
74 | 49 |
|
75 | 50 | local links = { |
76 | 51 | namespace: { |
|
0 commit comments