Skip to content

Commit

Permalink
Sync upstream latest PRs
Browse files Browse the repository at this point in the history
Signed-off-by: Vitaly Zhuravlev <v-zhuravlev@users.noreply.github.com>
  • Loading branch information
v-zhuravlev committed Nov 1, 2024
1 parent 16bdcdf commit 6f48c3c
Show file tree
Hide file tree
Showing 17 changed files with 276 additions and 18 deletions.
42 changes: 42 additions & 0 deletions docs/node-mixin/lib/aix/README.md
Original file line number Diff line number Diff line change
@@ -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).
23 changes: 23 additions & 0 deletions docs/node-mixin/lib/aix/alerts.libsonnet
Original file line number Diff line number Diff line change
@@ -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
],

),

},
}
27 changes: 27 additions & 0 deletions docs/node-mixin/lib/aix/config.libsonnet
Original file line number Diff line number Diff line change
@@ -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,

}
65 changes: 65 additions & 0 deletions docs/node-mixin/lib/aix/main.libsonnet
Original file line number Diff line number Diff line change
@@ -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),
},
},

}
24 changes: 24 additions & 0 deletions docs/node-mixin/lib/aix/panels.libsonnet
Original file line number Diff line number Diff line change
@@ -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'),
},

},
}
61 changes: 61 additions & 0 deletions docs/node-mixin/lib/aix/targets.libsonnet
Original file line number Diff line number Diff line change
@@ -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'),
},
},
}
2 changes: 1 addition & 1 deletion docs/node-mixin/lib/linux/alerts/alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
3 changes: 2 additions & 1 deletion docs/node-mixin/lib/linux/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
groupLabels: ['job'],
instanceLabels: ['instance'],
dashboardNamePrefix: 'Node exporter / ',
//uid prefix
uid: 'node',
dashboardTags: ['node-exporter-mixin'],

Expand Down Expand Up @@ -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,

Expand Down
12 changes: 6 additions & 6 deletions docs/node-mixin/lib/linux/dashboards.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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')
Expand All @@ -137,15 +137,15 @@ 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),
}
+
(
if this.config.showMultiCluster
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(
Expand All @@ -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 {}
)
Expand Down
2 changes: 1 addition & 1 deletion docs/node-mixin/lib/linux/links.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion docs/node-mixin/lib/linux/panels/cpu.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions docs/node-mixin/lib/linux/panels/disk.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion docs/node-mixin/lib/linux/panels/fleet.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion docs/node-mixin/lib/linux/panels/memory.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 3 additions & 2 deletions docs/node-mixin/lib/macos/config.libsonnet
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Loading

0 comments on commit 6f48c3c

Please sign in to comment.