Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove confusing job!="" filteringSelector when no selector is required. #1370

Merged
merged 7 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo fix suggestion in dependency PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fixed by merge.

// 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
17 changes: 6 additions & 11 deletions jvm-mixin/.lint
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
exclusions:
panel-title-description-rule:
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
panel-datasource-rule:
entries:
- panel: GC duration
- panel: Allocated/promoted
panel-units-rule:
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
template-datasource-rule:
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
template-instance-rule:
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
template-job-rule:
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
template-on-time-change-reload-rule:
reason: "mixtool upgrade made this rule stricter. TODO: Fix errors and remove the warning exclusion"
entries:
- panel: Process files open
2 changes: 1 addition & 1 deletion jvm-mixin/config.libsonnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
filteringSelector: 'job!=""',
filteringSelector: '',
groupLabels: ['job'],
instanceLabels: ['instance'],
uid: 'jvm',
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 kafka-observ-lib/signals/consumerGroup.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local commonlib = import 'common-lib/common/main.libsonnet';

function(this)
{
filteringSelector: std.join(',', [this.filteringSelector, this.topicsFilteringSelector, this.consumerGroupFilteringSelector]),
filteringSelector: std.join(',', [this.topicsFilteringSelector, this.consumerGroupFilteringSelector, this.filteringSelector]),
groupLabels: this.groupLabels,
instanceLabels: ['topic', 'consumergroup'], // this.instanceLabels is ommitted, as it would point to kafka_exporter instance.
aggLevel: 'group',
Expand Down
2 changes: 1 addition & 1 deletion kafka-observ-lib/signals/topic.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local commonlib = import 'common-lib/common/main.libsonnet';

function(this)
{
filteringSelector: std.join(',', [this.filteringSelector, this.topicsFilteringSelector]),
filteringSelector: std.join(',', [this.topicsFilteringSelector, this.filteringSelector]),
groupLabels: this.groupLabels,
instanceLabels: ['topic'], // this.instanceLabels is ommitted, as it would point to kafka_exporter instance.
aggLevel: 'group',
Expand Down
2 changes: 1 addition & 1 deletion kafka-observ-lib/signals/totalTime.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local commonlib = import 'common-lib/common/main.libsonnet';
// TotalTimeMs metric
function(this)
{
filteringSelector: this.filteringSelector + ', quantile="%s"' % this.totalTimeMsQuantile,
filteringSelector: ('quantile="%s"' % this.totalTimeMsQuantile) + ',' + this.filteringSelector,
groupLabels: this.groupLabels,
instanceLabels: this.instanceLabels,
aggLevel: if this.totalTimeMetricsRepeat then 'instance' else 'group',
Expand Down
2 changes: 1 addition & 1 deletion kafka-observ-lib/signals/zookeeperClient.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local commonlib = import 'common-lib/common/main.libsonnet';

function(this)
{
filteringSelector: this.filteringSelector + ', quantile="%s"' % this.zookeeperClientQuantile,
filteringSelector: ('quantile="%s"' % this.zookeeperClientQuantile) + ',' + this.filteringSelector,
groupLabels: this.groupLabels,
instanceLabels: this.instanceLabels,
aggLevel: 'instance',
Expand Down
11 changes: 7 additions & 4 deletions logs-lib/logs/variables.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ function(
+ [self.regex_search],

queriesSelector:
'%s,%s' % [
filterSelector,
utils.labelsToPromQLSelector(labels),
],
std.join(
',',
std.filter(function(x) std.length(x) > 0, [
filterSelector,
utils.labelsToPromQLSelector(labels),
])
),
}
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-mixin/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// labels to identify single windows host:
instanceLabels: ['instance'],
// selector to include in all queries(including alerts)
filteringSelector: 'job=~".*windows.*"',
filteringSelector: '',
// prefix all dashboards uids and alert groups
uid: 'windows',
// prefix dashboards titles
Expand Down
6 changes: 3 additions & 3 deletions windows-observ-lib/alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
{
alert: 'WindowsCPUHighUsage',
expr: |||
100 - (avg without (mode, core) (rate(windows_cpu_time_total{%(filteringSelector)s, mode="idle"}[2m])) * 100) > %(alertsCPUThresholdWarning)s
100 - (avg without (mode, core) (rate(windows_cpu_time_total{mode="idle", %(filteringSelector)s}[2m])) * 100) > %(alertsCPUThresholdWarning)s
||| % this.config,
'for': '15m',
keep_firing_for: '5m',
Expand Down Expand Up @@ -133,7 +133,7 @@
{
alert: 'WindowsServiceNotHealthy',
expr: |||
windows_service_status{%(filteringSelector)s, status!~"starting|stopping|ok"} > 0
windows_service_status{status!~"starting|stopping|ok", %(filteringSelector)s} > 0
||| % this.config,
'for': '5m',
labels: {
Expand All @@ -150,7 +150,7 @@
{
alert: 'WindowsDiskDriveNotHealthy',
expr: |||
windows_disk_drive_status{%(filteringSelector)s, status="OK"} != 1
windows_disk_drive_status{status="OK", %(filteringSelector)s} != 1
||| % this.config,
'for': '5m',
labels: {
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
Loading