Skip to content

Commit

Permalink
Remove confusing job!="" filteringSelector when no selector is required.
Browse files Browse the repository at this point in the history
  • Loading branch information
v-zhuravlev committed Dec 10, 2024
1 parent 1a75f65 commit b8ffd20
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
13 changes: 9 additions & 4 deletions common-lib/common/variables/variables.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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 != ''
Expand Down Expand Up @@ -57,24 +62,24 @@ 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),
])
),
queriesSelector:
std.join(
',',
std.filter(function(x) std.length(x) > 0, [
filteringSelector,
_filteringSelector,
utils.labelsToPromQLSelector(groupLabels + instanceLabels),
])
),
Expand Down
2 changes: 1 addition & 1 deletion jvm-observ-lib/config.libsonnet
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion kafka-observ-lib/config.libsonnet
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion process-observ-lib/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion windows-observ-lib/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down
2 changes: 1 addition & 1 deletion zookeeper-observ-lib/config.libsonnet
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit b8ffd20

Please sign in to comment.