diff --git a/common-lib/common/variables/variables.libsonnet b/common-lib/common/variables/variables.libsonnet index 951bd94e5..417ae5f9a 100644 --- a/common-lib/common/variables/variables.libsonnet +++ b/common-lib/common/variables/variables.libsonnet @@ -13,6 +13,11 @@ local utils = import '../utils.libsonnet'; prometheusDatasourceName=if enableLokiLogs then 'prometheus_datasource' else 'datasource', prometheusDatasourceLabel=if enableLokiLogs then 'Prometheus data source' else 'Data source', ): { + // strip trailing or starting comma if present: + // while trailing comman is accepted in PromQL expressions, starting comma is not. + // starting comma can be present in case of concatenation of empty filteringSelector with some extra selectors. + local _filteringSelector = std.stripChars(std.stripChars(filteringSelector, ' '), ','), + local varMetricTemplate(varMetric, chainSelector) = // check if chainSelector is not empty string (case when filtering selector is empty): if std.type(varMetric) == 'array' && chainSelector != '' @@ -57,16 +62,16 @@ local utils = import '../utils.libsonnet'; // Use on dashboards where multiple entities can be selected, like fleet dashboards multiInstance: [root.datasources.prometheus] - + variablesFromLabels(groupLabels, instanceLabels, filteringSelector), + + variablesFromLabels(groupLabels, instanceLabels, _filteringSelector), // Use on dashboards where only single entity can be selected singleInstance: [root.datasources.prometheus] - + variablesFromLabels(groupLabels, instanceLabels, filteringSelector, multiInstance=false), + + variablesFromLabels(groupLabels, instanceLabels, _filteringSelector, multiInstance=false), queriesSelectorAdvancedSyntax: std.join( ',', std.filter(function(x) std.length(x) > 0, [ - filteringSelector, + _filteringSelector, utils.labelsToPromQLSelectorAdvanced(groupLabels + instanceLabels), ]) ), @@ -74,7 +79,7 @@ local utils = import '../utils.libsonnet'; std.join( ',', std.filter(function(x) std.length(x) > 0, [ - filteringSelector, + _filteringSelector, utils.labelsToPromQLSelector(groupLabels + instanceLabels), ]) ), diff --git a/jvm-observ-lib/config.libsonnet b/jvm-observ-lib/config.libsonnet index c16a36581..5f265a1f1 100644 --- a/jvm-observ-lib/config.libsonnet +++ b/jvm-observ-lib/config.libsonnet @@ -1,6 +1,6 @@ { local this = self, - filteringSelector: 'job!=""', + filteringSelector: '', // set to apply static filters to all queries and alerts, i.e. job="bar" groupLabels: ['job'], instanceLabels: ['instance'], uid: 'jvm', diff --git a/kafka-observ-lib/config.libsonnet b/kafka-observ-lib/config.libsonnet index d6c0e07e1..1b1bbadf0 100644 --- a/kafka-observ-lib/config.libsonnet +++ b/kafka-observ-lib/config.libsonnet @@ -1,6 +1,6 @@ { local this = self, - filteringSelector: 'job!=""', + filteringSelector: '', // set to apply static filters to all queries and alerts, i.e. job="integrations/kafka" zookeeperfilteringSelector: this.filteringSelector, groupLabels: ['kafka_cluster'], // label(s) that defines kafka cluster instanceLabels: ['instance'], // label(s) that defines single broker diff --git a/process-observ-lib/config.libsonnet b/process-observ-lib/config.libsonnet index d353e9b55..8e6a08b38 100644 --- a/process-observ-lib/config.libsonnet +++ b/process-observ-lib/config.libsonnet @@ -6,7 +6,7 @@ // 'instanceLabels' - one or more labels that can be used to identify single entity of instances. In simple cases, can be 'instance' or 'pod'. // 'uid' - UID to prefix all dashboards original uids local this = self, - filteringSelector: 'job!=""', + filteringSelector: '', // set to apply static filters to all queries and alerts, i.e. job="bar" groupLabels: ['job'], instanceLabels: ['instance'], dashboardTags: [self.uid], diff --git a/windows-observ-lib/config.libsonnet b/windows-observ-lib/config.libsonnet index 8ff0a6e0b..cd603b7ed 100644 --- a/windows-observ-lib/config.libsonnet +++ b/windows-observ-lib/config.libsonnet @@ -7,7 +7,7 @@ // 'uid' - UID to prefix all dashboards original uids groupLabels: ['job'], instanceLabels: ['instance'], - filteringSelector: 'job=~".*windows.*"', + filteringSelector: '', // set to apply static filters to all queries and alerts, i.e. job="windows" dashboardTags: ['windows'], uid: 'windows', dashboardNamePrefix: '', diff --git a/zookeeper-observ-lib/config.libsonnet b/zookeeper-observ-lib/config.libsonnet index 0e65a2ca1..7249516dc 100644 --- a/zookeeper-observ-lib/config.libsonnet +++ b/zookeeper-observ-lib/config.libsonnet @@ -1,6 +1,6 @@ { local this = self, - filteringSelector: 'job!=""', + filteringSelector: '', // set to apply static filters to all queries and alerts, i.e. job="bar" groupLabels: ['job'], instanceLabels: ['instance'], uid: 'zookeeper',