Make more use of config.libsonnet

Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
beorn7 2019-07-16 19:34:27 +02:00
parent 2180c2f3bf
commit 3ab1f41d12
3 changed files with 14 additions and 9 deletions

View File

@ -1,11 +1,16 @@
{ {
_config+:: { _config+:: {
// Selectors are inserted between {} in Prometheus queries. // Selectors are inserted between {} in Prometheus queries.
// Select the metrics coming from the node exporter.
nodeExporterSelector: 'job="node-exporter"', nodeExporterSelector: 'job="node-exporter"',
// Mainly extracted because they are repetitive, but also useful to customize. // Select the fstype for filesystem-related queries.
fsSelector: 'fstype=~"ext.|xfs",mountpoint!="/var/lib/docker/aufs"', fsSelector: 'fstype=~"ext.|xfs",mountpoint!="/var/lib/docker/aufs"',
// Select the device for disk-related queries.
diskDeviceSelector: 'device=~"(sd|xvd).+"',
grafana_prefix: '', grafana_prefix: '',
}, },
} }

View File

@ -104,17 +104,17 @@ local g = import 'grafana-builder/grafana.libsonnet';
( (
sum without (device) ( sum without (device) (
max without (fstype, mountpoint) ( max without (fstype, mountpoint) (
node_filesystem_size_bytes{fstype=~"ext[24]"} - node_filesystem_avail_bytes{fstype=~"ext[24]"} node_filesystem_size_bytes{%(nodeExporterSelector)s, %(fsSelector)s} - node_filesystem_avail_bytes{%(nodeExporterSelector)s, %(fsSelector)s}
) )
) )
/ ignoring (instance) group_left / ignoring (instance) group_left
sum without (instance, device) ( sum without (instance, device) (
max without (fstype, mountpoint) ( max without (fstype, mountpoint) (
node_filesystem_size_bytes{fstype=~"ext[24]"} node_filesystem_size_bytes{%(nodeExporterSelector)s, %(fsSelector)s}
) )
) )
) )
|||, '{{instance}}', legendLink) + ||| % $._config, '{{instance}}', legendLink) +
g.stack + g.stack +
{ yaxes: g.yaxes({ format: 'percentunit', max: 1 }) }, { yaxes: g.yaxes({ format: 'percentunit', max: 1 }) },
), ),
@ -182,11 +182,11 @@ local g = import 'grafana-builder/grafana.libsonnet';
g.queryPanel(||| g.queryPanel(|||
1 - 1 -
( (
sum(max without (mountpoint, fstype) (node_filesystem_avail_bytes{fstype=~"ext[24]"})) sum(max without (mountpoint, fstype) (node_filesystem_avail_bytes{%(nodeExporterSelector)s, %(fsSelector)s}))
/ /
sum(max without (mountpoint, fstype) (node_filesystem_size_bytes{fstype=~"ext[24]"})) sum(max without (mountpoint, fstype) (node_filesystem_size_bytes{%(nodeExporterSelector)s, %(fsSelector)s}))
) )
|||, 'Disk') + ||| % $._config, 'Disk') +
{ yaxes: g.yaxes('percentunit') }, { yaxes: g.yaxes('percentunit') },
), ),
), ),

View File

@ -62,7 +62,7 @@
record: 'instance:node_disk_utilisation:sum_irate', record: 'instance:node_disk_utilisation:sum_irate',
expr: ||| expr: |||
sum without (device) ( sum without (device) (
irate(node_disk_io_time_seconds_total{%(nodeExporterSelector)s,device=~"(sd|xvd).+"}[1m]) irate(node_disk_io_time_seconds_total{%(nodeExporterSelector)s, %(diskDeviceSelector)s}[1m])
) )
||| % $._config, ||| % $._config,
}, },
@ -71,7 +71,7 @@
record: 'instance:node_disk_saturation:sum_irate', record: 'instance:node_disk_saturation:sum_irate',
expr: ||| expr: |||
sum without (device) ( sum without (device) (
irate(node_disk_io_time_weighted_seconds_total{%(nodeExporterSelector)s,device=~"(sd|xvd).+"}[1m]) irate(node_disk_io_time_weighted_seconds_total{%(nodeExporterSelector)s, %(diskDeviceSelector)s}[1m])
) )
||| % $._config, ||| % $._config,
}, },