mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-10-20 11:39:04 +02:00
collector: name instance labels after the entity they identify (#2744)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -4,7 +4,7 @@ local sumRate(name) = 'sum(rate(' + metric(name) + '[$__rate_interval]))';
|
||||
local physical(name) = 'windows_physical_disk_' + name + '{job=~"$job", instance="$instance"}';
|
||||
local physicalRate(name) = 'rate(' + physical(name) + '[$__rate_interval])';
|
||||
// diskdrive names drives PHYSICALDRIVE<n>; physical_disk and logical_disk use <n> as disk.
|
||||
local drive(name, labels='') = 'label_replace(windows_diskdrive_' + name + '{job=~"$job", instance="$instance"' + labels + '}, "disk", "$1", "name", "PHYSICALDRIVE(\\\\d+)")';
|
||||
local drive(name, labels='') = 'label_replace(windows_diskdrive_' + name + '{job=~"$job", instance="$instance"' + labels + '}, "disk", "$1", "device_id", "PHYSICALDRIVE(\\\\d+)")';
|
||||
// Labels physical disk series with the drive model when diskdrive is enabled.
|
||||
local physicalByDisk(on, expr) =
|
||||
if on('diskdrive')
|
||||
@@ -418,12 +418,12 @@ function(on)
|
||||
b.stat(240, 'Pools not OK', 'Storage pools whose health status is not Healthy, excluding the primordial pool. Requires the storage_spaces collector.', 'count(' + pool('health_status') + ' != 0) or (0 * count(' + concretePools + '))', steps=[{ color: 'green', value: null }, { color: 'red', value: 1 }]),
|
||||
b.stat(241, 'Virtual disks not OK', 'Virtual disks whose health status is not Healthy. Requires the storage_spaces collector with its virtual_disk subcollector.', 'count(' + spaces('virtual_disk_health_status') + ' != 0) or (0 * count(' + spaces('virtual_disk_info') + '))', steps=[{ color: 'green', value: null }, { color: 'red', value: 1 }]),
|
||||
|
||||
b.joinedTable(242, 'Storage pools', 'Health, size, allocated capacity and used share of each storage pool, excluding the primordial pool of unpooled disks. Requires the storage_spaces collector.', 'name', [
|
||||
'max by (name) (' + pool('health_status') + ')',
|
||||
'max by (name) (' + pool('size_bytes') + ')',
|
||||
'max by (name) (' + pool('allocated_size_bytes') + ')',
|
||||
'max by (name) (100 * ' + pool('allocated_size_bytes') + ' / ' + pool('size_bytes') + ')',
|
||||
], [['name', 'Pool'], ['Value #A', 'Health'], ['Value #B', 'Size'], ['Value #C', 'Allocated'], ['Value #D', 'Used']], [
|
||||
b.joinedTable(242, 'Storage pools', 'Health, size, allocated capacity and used share of each storage pool, excluding the primordial pool of unpooled disks. Requires the storage_spaces collector.', 'pool', [
|
||||
'max by (pool) (' + pool('health_status') + ')',
|
||||
'max by (pool) (' + pool('size_bytes') + ')',
|
||||
'max by (pool) (' + pool('allocated_size_bytes') + ')',
|
||||
'max by (pool) (100 * ' + pool('allocated_size_bytes') + ' / ' + pool('size_bytes') + ')',
|
||||
], [['pool', 'Pool'], ['Value #A', 'Health'], ['Value #B', 'Size'], ['Value #C', 'Allocated'], ['Value #D', 'Used']], [
|
||||
health,
|
||||
{
|
||||
matcher: { id: 'byName', options: 'Used' },
|
||||
@@ -439,19 +439,19 @@ function(on)
|
||||
},
|
||||
] + bytes(['Size', 'Allocated'])),
|
||||
|
||||
b.joinedTable(243, 'Virtual disks', 'Health, size, allocated capacity, pool footprint and storage efficiency (allocated size per pool footprint) of each virtual disk. Mirrors and parity lower the efficiency. Requires the storage_spaces collector with its virtual_disk subcollector.', 'name', [
|
||||
'max by (name) (' + spaces('virtual_disk_health_status') + ')',
|
||||
'max by (name) (' + spaces('virtual_disk_size_bytes') + ')',
|
||||
'max by (name) (' + spaces('virtual_disk_allocated_size_bytes') + ')',
|
||||
'max by (name) (' + spaces('virtual_disk_footprint_on_pool_bytes') + ')',
|
||||
'max by (name) (' + spaces('virtual_disk_storage_efficiency_ratio') + ')',
|
||||
], [['name', 'Virtual disk'], ['Value #A', 'Health'], ['Value #B', 'Size'], ['Value #C', 'Allocated'], ['Value #D', 'Footprint'], ['Value #E', 'Efficiency']], [
|
||||
b.joinedTable(243, 'Virtual disks', 'Health, size, allocated capacity, pool footprint and storage efficiency (allocated size per pool footprint) of each virtual disk. Mirrors and parity lower the efficiency. Requires the storage_spaces collector with its virtual_disk subcollector.', 'virtual_disk', [
|
||||
'max by (virtual_disk) (' + spaces('virtual_disk_health_status') + ')',
|
||||
'max by (virtual_disk) (' + spaces('virtual_disk_size_bytes') + ')',
|
||||
'max by (virtual_disk) (' + spaces('virtual_disk_allocated_size_bytes') + ')',
|
||||
'max by (virtual_disk) (' + spaces('virtual_disk_footprint_on_pool_bytes') + ')',
|
||||
'max by (virtual_disk) (' + spaces('virtual_disk_storage_efficiency_ratio') + ')',
|
||||
], [['virtual_disk', 'Virtual disk'], ['Value #A', 'Health'], ['Value #B', 'Size'], ['Value #C', 'Allocated'], ['Value #D', 'Footprint'], ['Value #E', 'Efficiency']], [
|
||||
health,
|
||||
{ matcher: { id: 'byName', options: 'Efficiency' }, properties: [{ id: 'unit', value: 'percentunit' }, { id: 'decimals', value: 1 }] },
|
||||
] + bytes(['Size', 'Allocated', 'Footprint'])),
|
||||
|
||||
b.graph(244, 'Pool usage', 'Allocated share of each storage pool, excluding the primordial pool. A full pool cannot extend thin-provisioned virtual disks, which then fail writes.', 'percent', [['100 * ' + pool('allocated_size_bytes') + ' / ' + pool('size_bytes'), '{{name}}']])
|
||||
b.graph(244, 'Pool usage', 'Allocated share of each storage pool, excluding the primordial pool. A full pool cannot extend thin-provisioned virtual disks, which then fail writes.', 'percent', [['100 * ' + pool('allocated_size_bytes') + ' / ' + pool('size_bytes'), '{{pool}}']])
|
||||
+ b.panel.withDefaults({ max: 100, custom: { thresholdsStyle: { mode: 'dashed' } }, thresholds: { steps: b.levels(80, 90) } }),
|
||||
b.graph(245, 'Virtual disk footprint', 'Pool capacity consumed by each virtual disk, including resiliency copies.', 'bytes', [[spaces('virtual_disk_footprint_on_pool_bytes'), '{{name}}']]),
|
||||
b.graph(245, 'Virtual disk footprint', 'Pool capacity consumed by each virtual disk, including resiliency copies.', 'bytes', [[spaces('virtual_disk_footprint_on_pool_bytes'), '{{virtual_disk}}']]),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ function(on, config, overview=null)
|
||||
b.stat(252, 'CPU > %s%%' % config.cpuHighUsageThreshold, 'Hosts whose CPU usage is above the cpuHighUsageThreshold of the WindowsCPUHighUsage alert. The alert also requires 15 minutes above it.', countHosts(cpuBusy + ' > %s' % config.cpuHighUsageThreshold), steps=attention),
|
||||
b.stat(253, 'RAM > %s%%' % config.memoryHighUsageThreshold, 'Hosts whose physical memory usage is above the memoryHighUsageThreshold of the WindowsMemoryHighUsage alert. The alert also requires 15 minutes above it.', countHosts('max by (instance) (' + memoryUsed + ') > %s' % config.memoryHighUsageThreshold), steps=attention),
|
||||
b.stat(254, 'Low disk', 'Hosts with at least one volume with less than %s%% free space, the diskFreeWarningThreshold' % config.diskFreeWarningThreshold + ' of the WindowsDiskAlmostFull alert. HarddiskVolume* volumes without a drive letter are ignored.', countHosts('min by (instance) (' + volumeFree + ') < %s' % config.diskFreeWarningThreshold), steps=attention),
|
||||
b.stat(255, 'Auto stopped', 'Hosts with at least one service with start mode auto that is not running. Delayed-start and trigger-start services can show up here until they start.', countHosts('count by (instance) (windows_service_state{job=~"$job", state="running"} == 0 and on (instance, name) windows_service_start_mode{job=~"$job", start_mode="auto"} == 1)'), steps=attention),
|
||||
b.stat(255, 'Auto stopped', 'Hosts with at least one service with start mode auto that is not running. Delayed-start and trigger-start services can show up here until they start.', countHosts('count by (instance) (windows_service_state{job=~"$job", state="running"} == 0 and on (instance, service) windows_service_start_mode{job=~"$job", start_mode="auto"} == 1)'), steps=attention),
|
||||
|
||||
b.panel.new(2, 'Hosts', 'table')
|
||||
+ b.panel.withDescription('One row per scraped host. Click a hostname to open its details. C: used is the usage of the C: volume, usually the system drive; Fullest volume is the most used volume with a drive letter. Services up counts running services; Auto stopped counts services with start mode auto that are not running.')
|
||||
@@ -67,7 +67,7 @@ function(on, config, overview=null)
|
||||
b.query.new('(sum by (instance) (windows_service_state{job=~"$job", state="running"})) and on (instance) windows_os_hostname{job=~"$job", hostname=~"$hostname"}', 'J')
|
||||
+ b.query.withInstant()
|
||||
+ b.query.withFormat('table'),
|
||||
b.query.new('(count by (instance) (windows_service_state{job=~"$job", state="running"} == 0 and on (instance, name) windows_service_start_mode{job=~"$job", start_mode="auto"} == 1)) and on (instance) windows_os_hostname{job=~"$job", hostname=~"$hostname"}', 'K')
|
||||
b.query.new('(count by (instance) (windows_service_state{job=~"$job", state="running"} == 0 and on (instance, service) windows_service_start_mode{job=~"$job", start_mode="auto"} == 1)) and on (instance) windows_os_hostname{job=~"$job", hostname=~"$hostname"}', 'K')
|
||||
+ b.query.withInstant()
|
||||
+ b.query.withFormat('table'),
|
||||
b.query.new('(max by (instance) (windows_system_processes{job=~"$job"})) and on (instance) windows_os_hostname{job=~"$job", hostname=~"$hostname"}', 'L')
|
||||
|
||||
@@ -163,7 +163,7 @@ function(on)
|
||||
b.panel.new(17, 'Stopped auto services', 'stat')
|
||||
+ b.panel.withDescription('Services with start mode "auto" that are not running. See the Services tab for names.')
|
||||
+ b.panel.withQueries([
|
||||
b.query.new('count(windows_service_state{job=~"$job", instance="$instance", state="running"} == 0 and on (name) windows_service_start_mode{job=~"$job", instance="$instance", start_mode="auto"} == 1) or vector(0)', 'A')
|
||||
b.query.new('count(windows_service_state{job=~"$job", instance="$instance", state="running"} == 0 and on (service) windows_service_start_mode{job=~"$job", instance="$instance", start_mode="auto"} == 1) or vector(0)', 'A')
|
||||
+ b.query.withInstant(),
|
||||
])
|
||||
+ b.panel.withDefaults({
|
||||
|
||||
@@ -10,7 +10,7 @@ function(on)
|
||||
[
|
||||
b.stat(50, 'Running services', 'Number of services currently in the running state, reported by the service collector. Compare unexpected drops with the stopped automatic services table and service change history.', 'sum(windows_service_state{job=~"$job", instance="$instance", state="running"})', 'short'),
|
||||
|
||||
b.stat(51, 'Stopped auto services', 'Services with start mode "auto" that are not running.', 'count(windows_service_state{job=~"$job", instance="$instance", state="running"} == 0 and on (name) windows_service_start_mode{job=~"$job", instance="$instance", start_mode="auto"} == 1) or vector(0)', steps=[{ color: 'green', value: null }, { color: 'orange', value: 1 }]),
|
||||
b.stat(51, 'Stopped auto services', 'Services with start mode "auto" that are not running.', 'count(windows_service_state{job=~"$job", instance="$instance", state="running"} == 0 and on (service) windows_service_start_mode{job=~"$job", instance="$instance", start_mode="auto"} == 1) or vector(0)', steps=[{ color: 'green', value: null }, { color: 'orange', value: 1 }]),
|
||||
|
||||
b.stat(52, 'Pending services', 'Services in a start, stop, pause or continue pending state. A service that stays pending is hung.', 'sum(windows_service_state{job=~"$job", instance="$instance", state=~".* pending"}) or vector(0)', steps=[{ color: 'green', value: null }, { color: 'orange', value: 1 }]),
|
||||
|
||||
@@ -19,7 +19,7 @@ function(on)
|
||||
b.panel.new(54, 'Automatic services not running', 'table')
|
||||
+ b.panel.withDescription('Services configured to start automatically that are not in the running state. Delayed-start and trigger-start services may show up here until they start.')
|
||||
+ b.panel.withQueries([
|
||||
b.query.new('max by (name, state) (windows_service_state{job=~"$job", instance="$instance"} == 1) and on (name) (windows_service_state{job=~"$job", instance="$instance", state="running"} == 0) and on (name) (windows_service_start_mode{job=~"$job", instance="$instance", start_mode="auto"} == 1)', 'A')
|
||||
b.query.new('max by (service, state) (windows_service_state{job=~"$job", instance="$instance"} == 1) and on (service) (windows_service_state{job=~"$job", instance="$instance", state="running"} == 0) and on (service) (windows_service_start_mode{job=~"$job", instance="$instance", start_mode="auto"} == 1)', 'A')
|
||||
+ b.query.withInstant()
|
||||
+ b.query.withFormat('table'),
|
||||
])
|
||||
@@ -36,11 +36,11 @@ function(on)
|
||||
},
|
||||
includeByName: {},
|
||||
indexByName: {
|
||||
name: 0,
|
||||
service: 0,
|
||||
state: 1,
|
||||
},
|
||||
renameByName: {
|
||||
name: 'Service',
|
||||
service: 'Service',
|
||||
state: 'State',
|
||||
},
|
||||
},
|
||||
@@ -59,8 +59,8 @@ function(on)
|
||||
b.panel.new(55, 'Service state changes', 'state-timeline')
|
||||
+ b.panel.withDescription('Services that started or stopped in the selected time range.')
|
||||
+ b.panel.withQueries([
|
||||
b.query.new('windows_service_state{job=~"$job", instance="$instance", state="running"} and on (name) (changes(windows_service_state{job=~"$job", instance="$instance", state="running"}[$__range] @ end()) > 0)', 'A')
|
||||
+ b.query.withLegendFormat('{{name}}'),
|
||||
b.query.new('windows_service_state{job=~"$job", instance="$instance", state="running"} and on (service) (changes(windows_service_state{job=~"$job", instance="$instance", state="running"}[$__range] @ end()) > 0)', 'A')
|
||||
+ b.query.withLegendFormat('{{service}}'),
|
||||
])
|
||||
+ b.panel.withDefaults({
|
||||
mappings: [
|
||||
|
||||
@@ -88,7 +88,7 @@ for file in $(cat "$out/generated"); do
|
||||
diff -u {{vars.dashboards}}/"$file" "$out/$file" \
|
||||
|| { echo "{{vars.dashboards}}/$file is out of date; run mise run dashboard"; exit 1; }
|
||||
done
|
||||
promtool check rules windows_rules.yaml windows_alerts.yaml tests/custom_rules.yaml tests/custom_alerts.yaml
|
||||
promtool check rules windows_rules.yaml windows_alerts.yaml tests/custom_rules.yaml tests/custom_alerts.yaml ../../docs/example-0.32-compatibility-rules-new-to-old.yml
|
||||
pint --offline lint windows_rules.yaml windows_alerts.yaml
|
||||
pint --offline lint tests/custom_rules.yaml tests/custom_alerts.yaml
|
||||
'''
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
rule_files:
|
||||
- ../../../docs/example-0.32-compatibility-rules-new-to-old.yml
|
||||
evaluation_interval: 1m
|
||||
|
||||
tests:
|
||||
- name: 0.32 metrics are published under their 0.31 names, units and labels
|
||||
interval: 1m
|
||||
input_series:
|
||||
- series: 'windows_mscluster_resource_restart_delay_seconds{job="w",instance="h:9182",type="SQL Server",resource="SQL",resource_group="G1"}'
|
||||
values: '0.5'
|
||||
- series: 'windows_hyperv_virtual_smb_open_files{job="w",instance="h:9182",vm="VM1"}'
|
||||
values: '3'
|
||||
- series: 'windows_cpu_core_frequency_hertz{job="w",instance="h:9182",core="0,0"}'
|
||||
values: '3600000000'
|
||||
- series: 'windows_cpu_time_seconds_total{job="w",instance="h:9182",core="0,0",mode="idle"}'
|
||||
values: '42'
|
||||
promql_expr_test:
|
||||
- expr: windows_mscluster_resource_restart_delay
|
||||
eval_time: 0
|
||||
exp_samples:
|
||||
- labels: 'windows_mscluster_resource_restart_delay{job="w",instance="h:9182",type="SQL Server",name="SQL",owner_group="G1"}'
|
||||
value: 500
|
||||
- expr: windows_hyperv_virtual_smb_current_open_file_count
|
||||
eval_time: 0
|
||||
exp_samples:
|
||||
- labels: 'windows_hyperv_virtual_smb_current_open_file_count{job="w",instance="h:9182",exported_instance="VM1"}'
|
||||
value: 3
|
||||
- expr: windows_cpu_core_frequency_mhz
|
||||
eval_time: 0
|
||||
exp_samples:
|
||||
- labels: 'windows_cpu_core_frequency_mhz{job="w",instance="h:9182",core="0,0"}'
|
||||
value: 3600
|
||||
- expr: windows_cpu_time_total
|
||||
eval_time: 0
|
||||
exp_samples:
|
||||
- labels: 'windows_cpu_time_total{job="w",instance="h:9182",core="0,0",mode="idle"}'
|
||||
value: 42
|
||||
Reference in New Issue
Block a user