Skip to content

Commit ab84b9f

Browse files
authored
Add support for empty lists: instanceLabels=[],grouplabels=[] in commonlib.variables generation (#1352)
1 parent 2c38760 commit ab84b9f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

common-lib/common/variables/variables.libsonnet

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,21 @@ local utils = import '../utils.libsonnet';
5959
[root.datasources.prometheus]
6060
+ variablesFromLabels(groupLabels, instanceLabels, filteringSelector, multiInstance=false),
6161
queriesSelectorAdvancedSyntax:
62-
'%s' % [
63-
utils.labelsToPromQLSelectorAdvanced(groupLabels + instanceLabels),
64-
],
62+
std.join(
63+
',',
64+
std.filter(function(x) std.length(x) > 0, [
65+
filteringSelector,
66+
utils.labelsToPromQLSelectorAdvanced(groupLabels + instanceLabels),
67+
])
68+
),
6569
queriesSelector:
66-
'%s,%s' % [
67-
filteringSelector,
68-
utils.labelsToPromQLSelector(groupLabels + instanceLabels),
69-
],
70+
std.join(
71+
',',
72+
std.filter(function(x) std.length(x) > 0, [
73+
filteringSelector,
74+
utils.labelsToPromQLSelector(groupLabels + instanceLabels),
75+
])
76+
),
7077

7178
}
7279
+ if enableLokiLogs then self.withLokiLogs() else {},

0 commit comments

Comments
 (0)