mirror of
				https://github.com/prometheus/node_exporter.git
				synced 2025-08-20 18:33:52 -07:00 
			
		
		
		
	Make more use of config.libsonnet
Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
		
							parent
							
								
									2180c2f3bf
								
							
						
					
					
						commit
						3ab1f41d12
					
				| 
						 | 
				
			
			@ -1,11 +1,16 @@
 | 
			
		|||
{
 | 
			
		||||
  _config+:: {
 | 
			
		||||
    // Selectors are inserted between {} in Prometheus queries.
 | 
			
		||||
 | 
			
		||||
    // Select the metrics coming from the 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"',
 | 
			
		||||
 | 
			
		||||
    // Select the device for disk-related queries.
 | 
			
		||||
    diskDeviceSelector: 'device=~"(sd|xvd).+"',
 | 
			
		||||
 | 
			
		||||
    grafana_prefix: '',
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -104,17 +104,17 @@ local g = import 'grafana-builder/grafana.libsonnet';
 | 
			
		|||
            (
 | 
			
		||||
              sum without (device) (
 | 
			
		||||
                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
 | 
			
		||||
              sum without (instance, device) (
 | 
			
		||||
                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 +
 | 
			
		||||
          { yaxes: g.yaxes({ format: 'percentunit', max: 1 }) },
 | 
			
		||||
        ),
 | 
			
		||||
| 
						 | 
				
			
			@ -182,11 +182,11 @@ local g = import 'grafana-builder/grafana.libsonnet';
 | 
			
		|||
          g.queryPanel(|||
 | 
			
		||||
            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') },
 | 
			
		||||
        ),
 | 
			
		||||
      ),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -62,7 +62,7 @@
 | 
			
		|||
            record: 'instance:node_disk_utilisation:sum_irate',
 | 
			
		||||
            expr: |||
 | 
			
		||||
              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,
 | 
			
		||||
          },
 | 
			
		||||
| 
						 | 
				
			
			@ -71,7 +71,7 @@
 | 
			
		|||
            record: 'instance:node_disk_saturation:sum_irate',
 | 
			
		||||
            expr: |||
 | 
			
		||||
              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,
 | 
			
		||||
          },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue