From 83273001465aa19dbce992bc2988091488631247 Mon Sep 17 00:00:00 2001 From: Vitaly Zhuravlev Date: Fri, 1 Nov 2024 15:09:57 +0000 Subject: [PATCH] Sync upstream latest PRs --- docs/node-mixin/lib/aix/README.md | 42 ++++++++++++ docs/node-mixin/lib/aix/alerts.libsonnet | 23 +++++++ docs/node-mixin/lib/aix/config.libsonnet | 27 ++++++++ docs/node-mixin/lib/aix/main.libsonnet | 65 +++++++++++++++++++ docs/node-mixin/lib/aix/panels.libsonnet | 24 +++++++ docs/node-mixin/lib/aix/targets.libsonnet | 61 +++++++++++++++++ .../lib/linux/alerts/alerts.libsonnet | 2 +- docs/node-mixin/lib/linux/config.libsonnet | 3 +- .../node-mixin/lib/linux/dashboards.libsonnet | 12 ++-- docs/node-mixin/lib/linux/links.libsonnet | 2 +- .../node-mixin/lib/linux/panels/cpu.libsonnet | 2 +- .../lib/linux/panels/disk.libsonnet | 4 +- .../lib/linux/panels/fleet.libsonnet | 2 +- .../lib/linux/panels/memory.libsonnet | 2 +- docs/node-mixin/lib/macos/config.libsonnet | 5 +- docs/node-mixin/lib/macos/main.libsonnet | 8 ++- docs/node-mixin/mixin-aix.libsonnet | 10 +++ 17 files changed, 276 insertions(+), 18 deletions(-) create mode 100644 docs/node-mixin/lib/aix/README.md create mode 100644 docs/node-mixin/lib/aix/alerts.libsonnet create mode 100644 docs/node-mixin/lib/aix/config.libsonnet create mode 100644 docs/node-mixin/lib/aix/main.libsonnet create mode 100644 docs/node-mixin/lib/aix/panels.libsonnet create mode 100644 docs/node-mixin/lib/aix/targets.libsonnet create mode 100644 docs/node-mixin/mixin-aix.libsonnet diff --git a/docs/node-mixin/lib/aix/README.md b/docs/node-mixin/lib/aix/README.md new file mode 100644 index 0000000000..b638f71b3e --- /dev/null +++ b/docs/node-mixin/lib/aix/README.md @@ -0,0 +1,42 @@ +# AIX exporter observability lib + +This jsonnet observability lib can be used to generate observability package for node exporter(AIX). + +## Import + +```sh +jb init +jb install https://github.com/prometheus/node_exporter/docs/node-mixin/lib/aix +``` + +## Examples + +### Example 1: Basic example + +You can use observ-lib to fill in monitoring-mixin structure: + +```jsonnet +// mixin.libsonnet file +local aixlib = import 'aix/main.libsonnet'; + +local aix = + aixlib.new() + + aixlib.withConfigMixin({ + filteringSelector: 'job=~".*aix.*"', + groupLabels: ['job'], + instanceLabels: ['instance'], + dashboardNamePrefix: 'AIX / ', + dashboardTags: ['aix-mixin'], + uid: 'aix', + // enable loki logs + enableLokiLogs: true, + }); + +{ + grafanaDashboards+:: aix.grafana.dashboards, + prometheusAlerts+:: aix.prometheus.alerts, + prometheusRules+:: aix.prometheus.recordingRules, +} + +``` +For more examples see [node-mixin/lib/linux](../linux). diff --git a/docs/node-mixin/lib/aix/alerts.libsonnet b/docs/node-mixin/lib/aix/alerts.libsonnet new file mode 100644 index 0000000000..46f66bd5a3 --- /dev/null +++ b/docs/node-mixin/lib/aix/alerts.libsonnet @@ -0,0 +1,23 @@ +{ + new(this, parentPrometheus): + { + groups: + //keep only alerts listed in alertsKeep + std.filter( + function(group) std.length(group.rules) > 0, + [ + { + name: group.name, + rules: [ + rule + for rule in group.rules + if std.length(std.find(rule.alert, this.config.alertsKeep)) > 0 + ], + } + for group in parentPrometheus.alerts.groups + ], + + ), + + }, +} diff --git a/docs/node-mixin/lib/aix/config.libsonnet b/docs/node-mixin/lib/aix/config.libsonnet new file mode 100644 index 0000000000..70b22afb44 --- /dev/null +++ b/docs/node-mixin/lib/aix/config.libsonnet @@ -0,0 +1,27 @@ +{ + // Rest of the config is imported from linux + filteringSelector: 'job="aix"', + dashboardNamePrefix: 'MacOS / ', + //uid prefix + uid: 'aix', + + dashboardTags: ['aix-mixin'], + + + // Alerts to keep from node-observ-lib: + alertsKeep: [ + 'NodeFilesystemAlmostOutOfSpace', + 'NodeNetworkReceiveErrs', + 'NodeNetworkTransmitErrs', + 'NodeTextFileCollectorScrapeError', + 'NodeFilesystemFilesFillingUp', + 'NodeFilesystemAlmostOutOfFiles', + 'NodeCPUHighUsage', + 'NodeSystemSaturation', + 'NodeMemoryHighUtilization', + 'NodeDiskIOSaturation', + ], + // logs lib related + enableLokiLogs: false, + +} diff --git a/docs/node-mixin/lib/aix/main.libsonnet b/docs/node-mixin/lib/aix/main.libsonnet new file mode 100644 index 0000000000..8380bd5bfa --- /dev/null +++ b/docs/node-mixin/lib/aix/main.libsonnet @@ -0,0 +1,65 @@ +local g = import '../g.libsonnet'; +local nodelib = import '../linux/main.libsonnet'; +local alerts = import './alerts.libsonnet'; +local config = import './config.libsonnet'; +local panels = import './panels.libsonnet'; +local targets = import './targets.libsonnet'; + + +// inherit nodelib +nodelib +{ + + new(): + super.new() + + nodelib.withConfigMixin(config) + + + { + local this = self, + local parentGrafana = super.grafana, + local parentPrometheus = super.prometheus, + + grafana+: { + // drop backToFleet link + links+: { + local link = g.dashboard.link, + backToFleet:: {}, + backToOverview: + link.link.new('Back to ' + this.config.dashboardNamePrefix + 'overview', '/d/' + this.grafana.dashboards['nodes-darwin.json'].uid) + + link.link.options.withKeepTime(true), + }, + annotations: { + // keep only reboot annotation + reboot: parentGrafana.annotations.reboot, + }, + // override targets (memory) + targets+: targets.new(this), + // override panels (update description and targets in panels) + panels+: panels.new(this), + + // keep only overview and logs(optionally) dashes + dashboards: + { + 'nodes-aix.json': + parentGrafana.dashboards['nodes.json'] + + g.dashboard.withUid( + (if this.config.uid == 'aix' then std.md5('nodes-aix.json') else this.config.uid + '-overview') + ), + } + + + ( + if this.config.enableLokiLogs + then + { + 'logs-aix.json': parentGrafana.dashboards['logs.json'], + } + else {} + ), + }, + prometheus+: { + recordingRules: {}, + alerts: alerts.new(this, parentPrometheus), + }, + }, + +} diff --git a/docs/node-mixin/lib/aix/panels.libsonnet b/docs/node-mixin/lib/aix/panels.libsonnet new file mode 100644 index 0000000000..8a75182177 --- /dev/null +++ b/docs/node-mixin/lib/aix/panels.libsonnet @@ -0,0 +1,24 @@ +local g = import '../g.libsonnet'; +local commonlib = import 'common-lib/common/main.libsonnet'; + +{ + new(this): + { + local t = this.grafana.targets, + local table = g.panel.table, + local fieldOverride = g.panel.table.fieldOverride, + local instanceLabel = this.config.instanceLabels[0], + + // override description and targets + memory+: { + memoryUsageTsBytes+: + g.panel.timeSeries.queryOptions.withTargets([ + t.memory.memoryUsedBytes, + t.memory.memoryTotalBytes, + t.memory.memorySwapUsedBytes, + ]) + + commonlib.panels.generic.timeSeries.threshold.stylizeByRegexp('Physical memory'), + }, + + }, +} diff --git a/docs/node-mixin/lib/aix/targets.libsonnet b/docs/node-mixin/lib/aix/targets.libsonnet new file mode 100644 index 0000000000..a0704a0405 --- /dev/null +++ b/docs/node-mixin/lib/aix/targets.libsonnet @@ -0,0 +1,61 @@ +local g = import '../g.libsonnet'; +local prometheusQuery = g.query.prometheus; +local lokiQuery = g.query.loki; + +{ + new(this): { + local variables = this.grafana.variables.main, + local config = this.config, + local prometheusDatasource = '${' + variables.datasources.prometheus.name + '}', + local lokiDatasource = '${' + variables.datasources.loki.name + '}', + + // override memory targets (other metrics in macos) + memory+: { + memoryTotalBytes: + prometheusQuery.new( + prometheusDatasource, + 'node_memory_total_bytes{%(queriesSelector)s}' % variables + ) + + prometheusQuery.withLegendFormat('Physical memory'), + + memoryUsedBytes: + prometheusQuery.new( + prometheusDatasource, + ||| + ( + node_memory_total_bytes{%(queriesSelector)s} - + node_memory_available_bytes{%(queriesSelector)s} + ) + ||| % variables + ) + + prometheusQuery.withLegendFormat('Memory used'), + + memoryUsagePercent: + prometheusQuery.new( + prometheusDatasource, + ||| + ( + ( + node_memory_total_bytes{%(queriesSelector)s} - + node_memory_available_bytes{%(queriesSelector)s} + ) + /avg(node_memory_total_bytes{%(queriesSelector)s}) + ) * 100 + ||| + % variables, + ), + memorySwapTotal: + prometheusQuery.new( + prometheusDatasource, + 'node_memory_swap_total_bytes{%(queriesSelector)s}' % variables + ), + + memorySwapUsedBytes: + prometheusQuery.new( + prometheusDatasource, + 'node_memory_swap_used_bytes{%(queriesSelector)s}' % variables + ) + + prometheusQuery.withLegendFormat('Swap used'), + }, + }, +} diff --git a/docs/node-mixin/lib/linux/alerts/alerts.libsonnet b/docs/node-mixin/lib/linux/alerts/alerts.libsonnet index 8a307dff9f..ca1b9fedea 100644 --- a/docs/node-mixin/lib/linux/alerts/alerts.libsonnet +++ b/docs/node-mixin/lib/linux/alerts/alerts.libsonnet @@ -395,7 +395,7 @@ annotations: { summary: 'Disk IO queue is high.', description: ||| - Disk IO queue (aqu-sq) is high on {{ $labels.device }} at {{ $labels.instance }}, has been above %(diskIOSaturationThreshold)d for the last 15 minutes, is currently at {{ printf "%%.2f" $value }}. + Disk IO queue (aqu-sq) is high on {{ $labels.device }} at {{ $labels.instance }}, has been above %(diskIOSaturationThreshold)d for the last 30 minutes, is currently at {{ printf "%%.2f" $value }}. This symptom might indicate disk saturation. ||| % this.config, }, diff --git a/docs/node-mixin/lib/linux/config.libsonnet b/docs/node-mixin/lib/linux/config.libsonnet index 5ce5548269..4a10c69ba0 100644 --- a/docs/node-mixin/lib/linux/config.libsonnet +++ b/docs/node-mixin/lib/linux/config.libsonnet @@ -10,6 +10,7 @@ groupLabels: ['job'], instanceLabels: ['instance'], dashboardNamePrefix: 'Node exporter / ', + //uid prefix uid: 'node', dashboardTags: ['node-exporter-mixin'], @@ -76,7 +77,7 @@ fsSpaceAvailableWarningThreshold: 5, fsSpaceAvailableCriticalThreshold: 3, - // Memory utilzation (%) level on which to trigger the + // Memory utilization (%) level on which to trigger the // 'NodeMemoryHighUtilization' alert. memoryHighUtilizationThreshold: 90, diff --git a/docs/node-mixin/lib/linux/dashboards.libsonnet b/docs/node-mixin/lib/linux/dashboards.libsonnet index 18f4810ad7..b07adc5ef2 100644 --- a/docs/node-mixin/lib/linux/dashboards.libsonnet +++ b/docs/node-mixin/lib/linux/dashboards.libsonnet @@ -24,7 +24,7 @@ local logslib = import 'github.com/grafana/jsonnet-libs/logs-lib/logs/main.libso ) // hide link to self + root.applyCommon(vars.multiInstance, uid + '-fleet', tags, links { backToFleet+:: {}, backToOverview+:: {} }, annotations, timezone, refresh, period), - 'overview.json': + 'nodes.json': g.dashboard.new(prefix + 'overview') + g.dashboard.withPanels( g.util.panel.resolveCollapsedFlagOnRows( @@ -46,7 +46,7 @@ local logslib = import 'github.com/grafana/jsonnet-libs/logs-lib/logs/main.libso ) ) // defaults to uid=nodes for backward compatibility with old node-mixins - + root.applyCommon(vars.singleInstance, (if uid == 'node' then 'nodes' else uid + '-overview'), tags, links { backToOverview+:: {} }, annotations, timezone, refresh, period), + + root.applyCommon(vars.singleInstance, (if uid == 'node' then std.md5('nodes.json') else uid + '-overview'), tags, links { backToOverview+:: {} }, annotations, timezone, refresh, period), 'network.json': g.dashboard.new(prefix + 'network') + g.dashboard.withPanels( @@ -120,7 +120,7 @@ local logslib = import 'github.com/grafana/jsonnet-libs/logs-lib/logs/main.libso ) ) ) - + root.applyCommon(this.grafana.variables.use.singleInstance, uid + '-rsrc-use', tags, links, annotations, timezone, refresh, period), + + root.applyCommon(this.grafana.variables.use.singleInstance, std.md5(uid + '-cluster-rsrc-use.json'), tags, links, annotations, timezone, refresh, period), 'node-cluster-rsrc-use.json': g.dashboard.new(prefix + 'USE method / cluster') @@ -137,7 +137,7 @@ local logslib = import 'github.com/grafana/jsonnet-libs/logs-lib/logs/main.libso ) ) ) - + root.applyCommon(this.grafana.variables.useCluster.singleInstance, uid + '-cluster-rsrc-use', tags, links, annotations, timezone, refresh, period), + + root.applyCommon(this.grafana.variables.useCluster.singleInstance, std.md5(uid + '-cluster-rsrc-use.json'), tags, links, annotations, timezone, refresh, period), } + ( @@ -145,7 +145,7 @@ local logslib = import 'github.com/grafana/jsonnet-libs/logs-lib/logs/main.libso then { 'node-multicluster-rsrc-use.json': - g.dashboard.new(prefix + 'USE method / cluster') + g.dashboard.new(prefix + 'USE method / Multi-cluster') + g.dashboard.withPanels( g.util.panel.resolveCollapsedFlagOnRows( g.util.grid.wrapPanels( @@ -159,7 +159,7 @@ local logslib = import 'github.com/grafana/jsonnet-libs/logs-lib/logs/main.libso ) ) ) - + root.applyCommon(this.grafana.variables.useCluster.multiInstance, uid + '-multicluster-rsrc-use', tags, links, annotations, timezone, refresh, period), + + root.applyCommon(this.grafana.variables.useCluster.multiInstance, std.md5(uid + '-multicluster-rsrc-use.json'), tags, links, annotations, timezone, refresh, period), } else {} ) diff --git a/docs/node-mixin/lib/linux/links.libsonnet b/docs/node-mixin/lib/linux/links.libsonnet index 8a72f9035e..83546520c3 100644 --- a/docs/node-mixin/lib/linux/links.libsonnet +++ b/docs/node-mixin/lib/linux/links.libsonnet @@ -8,7 +8,7 @@ local commonlib = import 'common-lib/common/main.libsonnet'; link.link.new('Back to ' + this.config.dashboardNamePrefix + 'fleet', '/d/' + this.grafana.dashboards['fleet.json'].uid) + link.link.options.withKeepTime(true), backToOverview: - link.link.new('Back to ' + this.config.dashboardNamePrefix + 'overview', '/d/' + this.grafana.dashboards['overview.json'].uid) + link.link.new('Back to ' + this.config.dashboardNamePrefix + 'overview', '/d/' + this.grafana.dashboards['nodes.json'].uid) + link.link.options.withKeepTime(true), otherDashboards: link.dashboards.new('All ' + this.config.dashboardNamePrefix + ' dashboards', this.config.dashboardTags) diff --git a/docs/node-mixin/lib/linux/panels/cpu.libsonnet b/docs/node-mixin/lib/linux/panels/cpu.libsonnet index 17f5cf750d..aec88fda6a 100644 --- a/docs/node-mixin/lib/linux/panels/cpu.libsonnet +++ b/docs/node-mixin/lib/linux/panels/cpu.libsonnet @@ -19,7 +19,7 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet'; target=t.cpu.cpuUsage, topk=25, instanceLabels=this.config.instanceLabels, - drillDownDashboardUid=this.grafana.dashboards['overview.json'].uid, + drillDownDashboardUid=this.grafana.dashboards['nodes.json'].uid, ), cpuUsageStat: commonlib.panels.cpu.stat.usage.new(targets=[t.cpu.cpuUsage]), cpuUsageByMode: commonlib.panels.cpu.timeSeries.utilizationByMode.new( diff --git a/docs/node-mixin/lib/linux/panels/disk.libsonnet b/docs/node-mixin/lib/linux/panels/disk.libsonnet index 801bf54fc7..141ee98f8c 100644 --- a/docs/node-mixin/lib/linux/panels/disk.libsonnet +++ b/docs/node-mixin/lib/linux/panels/disk.libsonnet @@ -83,7 +83,7 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet'; target=t.disk.diskUsagePercent, topk=25, instanceLabels=this.config.instanceLabels + ['volume'], - drillDownDashboardUid=this.grafana.dashboards['overview.json'].uid, + drillDownDashboardUid=this.grafana.dashboards['nodes.json'].uid, ), diskIOBytesPerSec: commonlib.panels.disk.timeSeries.ioBytesPerSec.new( targets=[t.disk.diskIOreadBytesPerSec, t.disk.diskIOwriteBytesPerSec, t.disk.diskIOutilization] @@ -94,7 +94,7 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet'; target=t.disk.diskIOutilization, topk=25, instanceLabels=this.config.instanceLabels + ['volume'], - drillDownDashboardUid=this.grafana.dashboards['overview.json'].uid, + drillDownDashboardUid=this.grafana.dashboards['nodes.json'].uid, ), diskIOps: commonlib.panels.disk.timeSeries.iops.new( diff --git a/docs/node-mixin/lib/linux/panels/fleet.libsonnet b/docs/node-mixin/lib/linux/panels/fleet.libsonnet index 1ae7e6bb7e..729eea9624 100644 --- a/docs/node-mixin/lib/linux/panels/fleet.libsonnet +++ b/docs/node-mixin/lib/linux/panels/fleet.libsonnet @@ -83,7 +83,7 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet'; { targetBlank: false, title: 'Drill down to ${__field.name} ${__value.text}', - url: 'd/%s?var-%s=${__data.fields.%s}&${__url_time_range}&${datasource:queryparam}' % [this.grafana.dashboards['overview.json'].uid, instanceLabel, instanceLabel], + url: 'd/%s?var-%s=${__data.fields.%s}&${__url_time_range}&${datasource:queryparam}' % [this.grafana.dashboards['nodes.json'].uid, instanceLabel, instanceLabel], }, ]), fieldOverride.byRegexp.new(std.join('|', std.map(utils.toSentenceCase, this.config.groupLabels))) diff --git a/docs/node-mixin/lib/linux/panels/memory.libsonnet b/docs/node-mixin/lib/linux/panels/memory.libsonnet index d11267b8a7..8560a73500 100644 --- a/docs/node-mixin/lib/linux/panels/memory.libsonnet +++ b/docs/node-mixin/lib/linux/panels/memory.libsonnet @@ -30,7 +30,7 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet'; target=t.memory.memoryUsagePercent, topk=25, instanceLabels=this.config.instanceLabels, - drillDownDashboardUid=this.grafana.dashboards['overview.json'].uid, + drillDownDashboardUid=this.grafana.dashboards['nodes.json'].uid, ), memoryUsageTsBytes: commonlib.panels.memory.timeSeries.usageBytes.new( diff --git a/docs/node-mixin/lib/macos/config.libsonnet b/docs/node-mixin/lib/macos/config.libsonnet index e931a24f9d..370ab4d052 100644 --- a/docs/node-mixin/lib/macos/config.libsonnet +++ b/docs/node-mixin/lib/macos/config.libsonnet @@ -1,10 +1,11 @@ { // Rest of the config is imported from linux - filteringSelector: 'job="integrations/macos-node"', + filteringSelector: 'job=macos"', dashboardNamePrefix: 'MacOS / ', + //uid prefix uid: 'darwin', - dashboardTags: [self.uid], + dashboardTags: ['macos-mixin'], // Alerts to keep from node-observ-lib: diff --git a/docs/node-mixin/lib/macos/main.libsonnet b/docs/node-mixin/lib/macos/main.libsonnet index 18a418f221..6b15d25453 100644 --- a/docs/node-mixin/lib/macos/main.libsonnet +++ b/docs/node-mixin/lib/macos/main.libsonnet @@ -36,14 +36,18 @@ nodelib // keep only overview and logs(optionally) dashes dashboards: { - 'overview.json': parentGrafana.dashboards['overview.json'], + 'nodes-darwin.json': + parentGrafana.dashboards['nodes.json'] + + g.dashboard.withUid( + (if this.config.uid == 'darwin' then std.md5('nodes-darwin.json') else this.config.uid + '-overview') + ), } + ( if this.config.enableLokiLogs then { - 'logs.json': parentGrafana.dashboards['logs.json'], + 'logs-darwin.json': parentGrafana.dashboards['logs.json'], } else {} ), diff --git a/docs/node-mixin/mixin-aix.libsonnet b/docs/node-mixin/mixin-aix.libsonnet new file mode 100644 index 0000000000..dd86f36809 --- /dev/null +++ b/docs/node-mixin/mixin-aix.libsonnet @@ -0,0 +1,10 @@ +local aixlib = import './lib/aix/main.libsonnet'; +{ + _config:: {}, + _aixLib:: + aixlib.new() + + aixlib.withConfigMixin(self._config), + grafanaDashboards+:: self._aixLib.grafana.dashboards, + prometheusAlerts+:: self._aixLib.prometheus.alerts, + prometheusRules+:: self._aixLib.prometheus.recordingRules, +}