Skip to content

Commit

Permalink
Consider physical blocksize for SmartHealthStatusFail alert
Browse files Browse the repository at this point in the history
  • Loading branch information
Deezzir committed Dec 14, 2024
1 parent af58ad1 commit 10f2583
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/prometheus_alert_rules/smart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ groups:
LABELS = {{ $labels }}
- alert: SmartHealthStatusFail
expr: smartctl_device_smart_status == 0
expr: (smartctl_device_smart_status == 0) and on(device, juju_unit) (smartctl_device_block_size{blocks_type="physical"} != 0)
for: 2m
labels:
severity: critical
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/test_alert_rules/test_smart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ tests:
input_series:
- series: 'smartctl_device_smart_status{device="sda", instance="ubuntu-1"}'
values: '0x15'
- series: 'smartctl_device_block_size{device="sda", instance="ubuntu-1", blocks_type="physical"}'
values: '1x15'

alert_rule_test:
- eval_time: 10m
Expand All @@ -84,6 +86,18 @@ tests:
VALUE = 0
LABELS = map[__name__:smartctl_device_smart_status device:sda instance:ubuntu-1]
- interval: 1m
input_series:
- series: 'smartctl_device_smart_status{device="sda", instance="ubuntu-1"}'
values: '0x15'
- series: 'smartctl_device_block_size{device="sda", instance="ubuntu-1", blocks_type="physical"}'
values: '0x15'

alert_rule_test:
- eval_time: 10m
alertname: SmartHealthStatusFail
exp_alerts: # alerts shouldn't fire since block size is 0

- interval: 1m
input_series:
- series: 'smartctl_device_smartctl_exit_status{device="sda", instance="ubuntu-2"}'
Expand Down

0 comments on commit 10f2583

Please sign in to comment.