Skip to content

Enhance windows observ lib with detailed alerts and add promtool tests. #1408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 79 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
c6d41bf
Add Check for unexpected changes in generated files
v-zhuravlev Feb 21, 2025
cd876c0
Fix kafka dashboards CI check
v-zhuravlev Feb 21, 2025
2220920
Add to docker-mixin
v-zhuravlev Feb 21, 2025
2f9ce49
Add golang-observ-lib
v-zhuravlev Feb 21, 2025
a9aeab3
Add jvm-observ-lib
v-zhuravlev Feb 21, 2025
cebe197
Add windows
v-zhuravlev Feb 21, 2025
8835676
Add process lib
v-zhuravlev Feb 21, 2025
3df9443
Add zookeeper
v-zhuravlev Feb 21, 2025
b4303f4
Add to csp-mixin check
v-zhuravlev Feb 21, 2025
37eeffb
Fix process-dashboards.json diff
v-zhuravlev Feb 21, 2025
766c790
Regenerate golang
v-zhuravlev Feb 21, 2025
0c632bb
Regenerate windows
v-zhuravlev Feb 21, 2025
2d976bf
Update ci
v-zhuravlev Feb 21, 2025
b32e127
Update README
v-zhuravlev Feb 21, 2025
867a185
Update snmp Makefile
v-zhuravlev Feb 21, 2025
8c25936
Add common Makefile
v-zhuravlev Feb 21, 2025
2251f7c
Add activemq
v-zhuravlev Feb 21, 2025
b5a7097
Add apache mixins
v-zhuravlev Feb 21, 2025
b7adf7c
add confluent
v-zhuravlev Feb 21, 2025
e530cf9
Add docker-mixin
v-zhuravlev Feb 21, 2025
d2b729f
Add csp-mixin
v-zhuravlev Feb 21, 2025
77edfad
Update goruntime
v-zhuravlev Feb 21, 2025
4ec438f
Update f5
v-zhuravlev Feb 21, 2025
845b16a
Update grafana-agent
v-zhuravlev Feb 21, 2025
c37c399
Simplify Makefile to use common mixin Makefile
v-zhuravlev Feb 21, 2025
c124dc0
Add grafana-builder dependency
v-zhuravlev Feb 21, 2025
d56ddf0
Add envoy
v-zhuravlev Feb 21, 2025
88859ba
Add harbor
v-zhuravlev Feb 21, 2025
1f17819
Add hass-mixin
v-zhuravlev Feb 21, 2025
4e78765
Add influx
v-zhuravlev Feb 21, 2025
74d0489
Add haproxy
v-zhuravlev Feb 21, 2025
9cb6312
Add istio
v-zhuravlev Feb 21, 2025
a481859
Add multiple mixins: IBM MQ, Istio, Jaeger, Jenkins, Jira, and JVM
v-zhuravlev Feb 21, 2025
4e76275
Update kafka-mixin
v-zhuravlev Feb 21, 2025
8f331e8
Add multiple mixins: Couchbase, Discourse, Elasticsearch, GitLab, Kub…
v-zhuravlev Feb 21, 2025
5920d02
Add Spark mixin
v-zhuravlev Feb 21, 2025
4d460f1
Add multiple mixins: Node.js, Nomad, OpenLDAP, OpenSearch, OpenStack,…
v-zhuravlev Feb 21, 2025
bec9421
Add multiple mixins: Supabase, Tensorflow, Traefik, Vault, Velero, Wi…
v-zhuravlev Feb 21, 2025
36bf2dd
add snmp-mixin
v-zhuravlev Feb 21, 2025
f4d41b0
Remove unrelated links from snmp-mixin
v-zhuravlev Feb 21, 2025
a5ce82c
set editable: false
v-zhuravlev Feb 21, 2025
2c93f77
Fix jvm
v-zhuravlev Feb 21, 2025
0fcf3f4
Update spring
v-zhuravlev Feb 21, 2025
41a2548
make fmt camel
v-zhuravlev Feb 21, 2025
15a5bdb
Fix redis mixin linter
v-zhuravlev Feb 21, 2025
81581cf
Fix lint for golang
v-zhuravlev Feb 21, 2025
081db0d
Update lint for kafka
v-zhuravlev Feb 21, 2025
b571c77
update oracle
v-zhuravlev Feb 21, 2025
59fa8a1
Update nomad
v-zhuravlev Feb 21, 2025
b8566bb
Update haproxy
v-zhuravlev Feb 21, 2025
edc312f
update envoy
v-zhuravlev Feb 21, 2025
33ea6dd
Update jaeger
v-zhuravlev Feb 21, 2025
e359ff6
update ceph linter
v-zhuravlev Feb 21, 2025
20c48be
Fix for asterisk
v-zhuravlev Feb 21, 2025
3a615ba
Fix .lint
v-zhuravlev Feb 21, 2025
19469e4
Update oracle
v-zhuravlev Feb 21, 2025
e51df7e
Fix cilium
v-zhuravlev Feb 21, 2025
593e693
Update install-ci-deps
v-zhuravlev Feb 21, 2025
74189ad
Reset minio
v-zhuravlev Feb 21, 2025
e4dc26a
Add .gitattributes
v-zhuravlev Feb 21, 2025
090b5b8
fix haproxy
v-zhuravlev Feb 21, 2025
9d9b382
Update gitattributes
v-zhuravlev Feb 21, 2025
25bbf45
Fix mixin format
v-zhuravlev Feb 21, 2025
66155d8
Fix nomad lint
v-zhuravlev Feb 21, 2025
8eeeca3
Fix .lint
v-zhuravlev Feb 22, 2025
054d110
Update makefile
v-zhuravlev Feb 22, 2025
b6c385d
fix typo in snmp
v-zhuravlev Feb 22, 2025
6fc3548
Update lint error message
v-zhuravlev Feb 24, 2025
15303c8
Add newline
v-zhuravlev Feb 24, 2025
293be9e
Merge branch 'master' into generated_files_check
v-zhuravlev Feb 24, 2025
dba2b75
Update mixtool to main
v-zhuravlev Feb 24, 2025
17012b9
Update snmp
v-zhuravlev Feb 24, 2025
d29d619
Fix
v-zhuravlev Feb 24, 2025
7720dc4
Fix snmp
v-zhuravlev Feb 24, 2025
a720fc0
Add conditiona promtool tests
v-zhuravlev Feb 22, 2025
dbe09b8
Add promtool install in ci
v-zhuravlev Feb 22, 2025
5fc521f
Update README
v-zhuravlev Feb 22, 2025
739fe40
Update alerts
v-zhuravlev Feb 24, 2025
e4be607
Merge remote-tracking branch 'origin/master' into add-promtool
v-zhuravlev Feb 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/lint-mixins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,6 @@ jobs:
working-directory: ./${{ matrix.mixin }}
run: "make && git diff --exit-code || ( echo 'Error: Generated files are not up to date. Run make and commit the local diff'; exit 1; )"

- name: Run promtool test
working-directory: ./${{ matrix.mixin }}
run: make test
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s
SHELL := /bin/bash
PROMTOOL_VERSION := 3.2.0

install-ci-deps:
# Detect OS and architecture
UNAME_S := $(shell uname -s | tr '[:upper:]' '[:lower:]')
UNAME_M := $(shell uname -m)

# Map architecture names
ifeq ($(UNAME_M),x86_64)
ARCH := amd64
else ifeq ($(UNAME_M),aarch64)
ARCH := arm64
else ifeq ($(UNAME_M),armv7l)
ARCH := armv7
else
ARCH := $(UNAME_M)
endif

install-ci-deps: install-promtool
go install github.com/google/go-jsonnet/cmd/jsonnet@v0.20.0
go install github.com/google/go-jsonnet/cmd/jsonnetfmt@v0.20.0
go install github.com/google/go-jsonnet/cmd/jsonnet-lint@v0.20.0
go install github.com/monitoring-mixins/mixtool/cmd/mixtool@main
go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@v0.5.1

.PHONY: install-promtool
install-promtool:
@echo "Installing promtool $(PROMTOOL_VERSION) for $(UNAME_S)/$(ARCH)..."
@wget https://github.com/prometheus/prometheus/releases/download/v$(PROMTOOL_VERSION)/prometheus-$(PROMTOOL_VERSION).$(UNAME_S)-$(ARCH).tar.gz
@mkdir -p prometheus-$(PROMTOOL_VERSION).$(UNAME_S)-$(ARCH)
@tar xvf prometheus-$(PROMTOOL_VERSION).$(UNAME_S)-$(ARCH).tar.gz
@sudo mv prometheus-$(PROMTOOL_VERSION).$(UNAME_S)-$(ARCH)/promtool /usr/local/bin/
@rm -rf prometheus-$(PROMTOOL_VERSION).$(UNAME_S)-$(ARCH) prometheus-$(PROMTOOL_VERSION).$(UNAME_S)-$(ARCH).tar.gz
@echo "promtool $(PROMTOOL_VERSION) installed successfully"


fmt:
@find . -name '*.libsonnet' -print -o -name '*.jsonnet' -print | \
xargs -n 1 -- $(JSONNET_FMT) -i
Expand Down
10 changes: 9 additions & 1 deletion Makefile_mixin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
JSONNET_FMT := jsonnetfmt -n 2 --max-blank-lines 1 --string-style s --comment-style s

.PHONY: all
all: build dashboards_out prometheus_alerts.yaml prometheus_rules.yaml
all: build dashboards_out prometheus_alerts.yaml prometheus_rules.yaml test

vendor: $(wildcard jsonnetfile.json)
ifneq ("$(wildcard jsonnetfile.json)","")
Expand Down Expand Up @@ -42,6 +42,14 @@ prometheus_rules.yaml: $(wildcard vendor/**/rules.yaml) $(wildcard vendor/**/rul
touch prometheus_rules_out/prometheus_rules.yaml; \
fi

.PHONY: test
test:
@if [ -f tests/prometheus_*.yaml ]; then \
promtool test rules tests/prometheus_*.yaml; \
else \
echo "No tests/prometheus_*.yaml files found, skipping promtool test."; \
fi

.PHONY: deploy deploy_rules deploy_dashboards
deploy: deploy_rules deploy_dashboards

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Based on format described [here](https://monitoring.mixins.dev/):
* [`caddy-mixin`](caddy-mixin/): A set of reusable and extensible dashboards
for Caddy.



* [`jira-mixin`](jira-mixin/): A set of reusable and extensible dashboards and alerts for JIRA.

You can find more in directories with `-mixin` suffix.
Expand All @@ -54,6 +52,14 @@ Examples:
- [golang-observ-lib](golang-observ-lib/)
- [csp-mixin](csp-mixin/)

## Prometheus rules testing for monitoring mixins and observability libraries

It is highly recommended to test prometheus alerts with [promtool test rules](https://prometheus.io/docs/prometheus/latest/configuration/unit_testing_rules) command when complex PromQL queries are used or when additional queries are used in alerts' annotations.

promtool tests files should be placed in tests directory in the root of the library and should be named like `prometheus_*.yaml`. This will enable running tests ing Github Actions and with `make test` command.

A good example of promtool tests can be found in windows-observ-lib: [prometheus_alerts_test.yaml](windows-observ-lib/tests/prometheus_alerts_test.yaml)

## LICENSE

[Apache-2.0](LICENSE)
12 changes: 10 additions & 2 deletions windows-observ-lib/alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@
annotations: {
summary: 'High memory usage on Windows host.',
description: |||
Memory usage on host {{ $labels.instance }} is above %(alertMemoryUsageThresholdCritical)s%%. The current value is {{ $value | printf "%%.2f" }}%%.
Memory usage on host {{ $labels.instance }} is critically high, with {{ printf "%%.2f" $value }}%% of total memory used.
This exceeds the threshold of %(alertMemoryUsageThresholdCritical)s%%.
Current memory free: {{ with printf `windows_os_physical_memory_free_bytes{%(filteringSelector)s}` | query | first | value | humanize }}{{ . }}{{ end }}.
Total memory: {{ with printf `windows_cs_physical_memory_bytes{%(filteringSelector)s}` | query | first | value | humanize }}{{ . }}{{ end }}.
Consider investigating processes consuming high memory or increasing available memory.
||| % this.config,
},
},
Expand All @@ -126,7 +130,11 @@
annotations: {
summary: 'Disk is almost full on Windows host.',
description: |||
Volume {{ $labels.volume }} is almost full on host {{ $labels.instance }}, more than %(alertDiskUsageThresholdCritical)s%% of space is used. The current volume utilization is {{ $value | printf "%%.2f" }}%%.
Disk space on volume {{ $labels.volume }} of host {{ $labels.instance }} is critically low, with {{ printf "%%.2f" $value }}%% of total space used.
This exceeds the threshold of %(alertDiskUsageThresholdCritical)s%%.
Current disk free: {{ with printf `windows_logical_disk_free_bytes{volume="%%s", %(filteringSelector)s}` $labels.volume | query | first | value | humanize }}{{ . }}{{ end }}.
Total disk size: {{ with printf `windows_logical_disk_size_bytes{volume="%%s", %(filteringSelector)s}` $labels.volume | query | first | value | humanize }}{{ . }}{{ end }}.
Consider cleaning up unnecessary files or increasing disk capacity.
||| % this.config,
},
},
Expand Down
12 changes: 10 additions & 2 deletions windows-observ-lib/prometheus_rules_out/prometheus_alerts.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions windows-observ-lib/tests/prometheus_alerts_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
rule_files:
- ../prometheus_rules_out/prometheus_alerts.yaml

evaluation_interval: 15m

tests:
- interval: 1m
input_series:
- series: 'windows_os_physical_memory_free_bytes{instance="host1"}'
values: '10000000x15'
- series: 'windows_cs_physical_memory_bytes{instance="host1"}'
values: '1000000000x15'
- series: 'windows_logical_disk_free_bytes{volume="C:", instance="host1"}'
values: '10000000x15'
- series: 'windows_logical_disk_size_bytes{volume="C:", instance="host1"}'
values: '1000000000x15'


alert_rule_test:
- eval_time: 15m
alertname: WindowsMemoryHighUtilization
exp_alerts:
- exp_labels:
severity: critical
instance: host1
exp_annotations:
description: |
Memory usage on host host1 is critically high, with 99.00% of total memory used.
This exceeds the threshold of 90%.
Current memory free: 10M.
Total memory: 1G.
Consider investigating processes consuming high memory or increasing available memory.
summary: 'High memory usage on Windows host.'

- eval_time: 15m
alertname: WindowsDiskAlmostOutOfSpace
exp_alerts:
- exp_labels:
severity: critical
instance: host1
volume: "C:"
exp_annotations:
description: |
Disk space on volume C: of host host1 is critically low, with 99.00% of total space used.
This exceeds the threshold of 90%.
Current disk free: 10M.
Total disk size: 1G.
Consider cleaning up unnecessary files or increasing disk capacity.
summary: 'Disk is almost full on Windows host.'
Loading