Skip to content

Commit a9c2e60

Browse files
authored
Provide alerting rule for Nextcloud updates (#129)
1 parent 00ebdcf commit a9c2e60

File tree

7 files changed

+658
-4
lines changed

7 files changed

+658
-4
lines changed

.bingo/Variables.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ $(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
2929
@echo "(re)installing $(GOBIN)/golangci-lint-v1.62.2"
3030
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.62.2 "github.com/golangci/golangci-lint/cmd/golangci-lint"
3131

32+
PROMTOOL := $(GOBIN)/promtool-v0.306.0
33+
$(PROMTOOL): $(BINGO_DIR)/promtool.mod
34+
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
35+
@echo "(re)installing $(GOBIN)/promtool-v0.306.0"
36+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=promtool.mod -o=$(GOBIN)/promtool-v0.306.0 "github.com/prometheus/prometheus/cmd/promtool"
37+

.bingo/promtool.mod

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
2+
3+
go 1.23.0
4+
5+
toolchain go1.23.4
6+
7+
replace github.com/fsnotify/fsnotify v1.8.0 => github.com/fsnotify/fsnotify v1.7.0
8+
9+
exclude github.com/linode/linodego v1.0.0
10+
11+
exclude github.com/grpc-ecosystem/grpc-gateway v1.14.7
12+
13+
exclude google.golang.org/api v0.30.0
14+
15+
require github.com/prometheus/prometheus v0.306.0 // cmd/promtool

.bingo/promtool.sum

Lines changed: 608 additions & 0 deletions
Large diffs are not rendered by default.

.bingo/variables.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ BINGO="${GOBIN}/bingo-v0.9.0"
1212

1313
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.62.2"
1414

15+
PROMTOOL="${GOBIN}/promtool-v0.306.0"
16+

.github/workflows/pull-request.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ jobs:
1515
uses: golangci/golangci-lint-action@v4
1616
with:
1717
version: v1.62.2
18+
- name: promtool
19+
run: make lint-promtool

Makefile

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ test:
1717
$(GO_CMD) test -cover ./...
1818

1919
.PHONY: lint
20-
lint: $(GOLANGCI_LINT)
20+
lint: lint-go lint-promtool
21+
22+
.PHONY: lint-go
23+
lint-go: $(GOLANGCI_LINT)
2124
$(GOLANGCI_LINT) run
2225

23-
.PHONY: lint-fix
24-
lint-fix: $(GOLANGCI_LINT)
26+
.PHONY: lint-go-fix
27+
lint-go-fix: $(GOLANGCI_LINT)
2528
$(GOLANGCI_LINT) run --fix
2629

30+
.PHONY: lint-promtool
31+
lint-promtool: $(PROMTOOL) contrib/prometheus-alerts.yaml
32+
$(PROMTOOL) check rules contrib/prometheus-alerts.yaml
33+
2734
.PHONY: build-binary
2835
build-binary:
2936
$(GO_CMD) build -tags netgo -ldflags "-w -X main.Version=$(VERSION) -X main.GitCommit=$(GIT_COMMIT)" -o nextcloud-exporter .
@@ -49,7 +56,7 @@ all-images:
4956
docker buildx build -t "ghcr.io/$(DOCKER_REPO):$(DOCKER_TAG)" -t "docker.io/$(DOCKER_REPO):$(DOCKER_TAG)" --platform linux/amd64,linux/arm64 --push .
5057

5158
.PHONY: tools
52-
tools: $(BINGO) $(GOLANGCI_LINT)
59+
tools: $(BINGO) $(GOLANGCI_LINT) $(PROMTOOL)
5360
@echo Tools built.
5461

5562
.PHONY: clean

contrib/prometheus-alerts.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
groups:
2+
- name: nextcloud
3+
rules:
4+
- alert: NextcloudUpdateWarning
5+
expr: |
6+
sum by (instance, version, available_version) (nextcloud_system_update_available) > 0
7+
for: 15m
8+
annotations:
9+
summary: |
10+
Version {{ index $labels "available_version" }} available for Nextcloud server {{ index $labels "instance" }}.
11+
description: |
12+
The Nextcloud server at {{ index $labels "instance" }} can be updated to version {{ index $labels "available_version" }} (from {{ index $labels "version" }}).
13+
labels:
14+
severity: warning

0 commit comments

Comments
 (0)