Skip to content

Commit 28bf2fe

Browse files
authored
feat: enables prometheus rules and alerts (#292)
* feat: enables prometheus rules and alerts which can be sent to alertmanager * chore: adding configs for alertmanager, alert, and prom * chore: alerts WIP * chore: alerts WIP * chore: alerts WIP * chore: setRules API will update rules * chore: initialization of prometheus related stuff moved to separate function * chore: alerts WIP * chore: alerts WIP * fix: r.promConfig was nil * feat: routing alertmanager apis to alertmanager service at nginx * chore: not writing to localDB if string parsing gives error * feat: list alerts API * chore: error in creating multiple groups * feat: CRUD APIs for rules working * chore: changed prometheus version * chore: updated AlertingRuleResponse struct's Id json value * chore: updated prometheus's version * chore: will load rules from database on bootup * feat: crud APIs for notification channels WIP * fix: changed ALERTMANAGER_API_PREFIX * chore: enabling scrape and notify discover manager * chore: fixing path for signoz.db * chore: used transactions for rules APIs * chore: editchannel API updated and other apis refactored * chore: fixed merge conflicts * chore: changing createChannel api from yaml to json reader * chore: changing editChannel api from yaml to json reader * chore: porting loadChannels to json format * chore: editRule returning rule not found * chore: pre-release * chore: fixed db path for persistence * release: v0.5.0
1 parent 849c3d1 commit 28bf2fe

File tree

18 files changed

+1457
-53
lines changed

18 files changed

+1457
-53
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
global:
2+
resolve_timeout: 1m
3+
slack_api_url: 'https://hooks.slack.com/services/xxx'
4+
5+
route:
6+
receiver: 'slack-notifications'
7+
8+
receivers:
9+
- name: 'slack-notifications'
10+
slack_configs:
11+
- channel: '#alerts'
12+
send_resolved: true
13+
icon_url: https://avatars3.githubusercontent.com/u/3380462
14+
title: |-
15+
[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }} for {{ .CommonLabels.job }}
16+
{{- if gt (len .CommonLabels) (len .GroupLabels) -}}
17+
{{" "}}(
18+
{{- with .CommonLabels.Remove .GroupLabels.Names }}
19+
{{- range $index, $label := .SortedPairs -}}
20+
{{ if $index }}, {{ end }}
21+
{{- $label.Name }}="{{ $label.Value -}}"
22+
{{- end }}
23+
{{- end -}}
24+
)
25+
{{- end }}
26+
text: >-
27+
{{ range .Alerts -}}
28+
*Alert:* {{ .Annotations.title }}{{ if .Labels.severity }} - `{{ .Labels.severity }}`{{ end }}
29+
30+
*Description:* {{ .Annotations.description }}
31+
32+
*Details:*
33+
{{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
34+
{{ end }}
35+
{{ end }}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
groups:
2+
- name: ExampleCPULoadGroup
3+
rules:
4+
- alert: HighCpuLoad
5+
expr: system_cpu_load_average_1m > 0.1
6+
for: 0m
7+
labels:
8+
severity: warning
9+
annotations:
10+
summary: High CPU load
11+
description: "CPU load is > 0.1\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"

deploy/docker/clickhouse-setup/docker-compose.yaml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,19 @@ services:
2121
timeout: 5s
2222
retries: 3
2323

24+
alertmanager:
25+
image: signoz/alertmanager:0.5.0
26+
volumes:
27+
- ./alertmanager.yml:/prometheus/alertmanager.yml
28+
- ./data/alertmanager:/data
29+
command:
30+
- '--config.file=/prometheus/alertmanager.yml'
31+
- '--storage.path=/data'
32+
ports:
33+
- 9093:9093
34+
2435
query-service:
25-
image: signoz/query-service:0.4.5
36+
image: signoz/query-service:0.5.0
2637
container_name: query-service
2738
command: ["-config=/root/config/prometheus.yml"]
2839
ports:
@@ -43,7 +54,7 @@ services:
4354
condition: service_healthy
4455

4556
frontend:
46-
image: signoz/frontend:0.4.5
57+
image: signoz/frontend:0.5.0
4758
container_name: frontend
4859

4960
depends_on:

deploy/docker/clickhouse-setup/prometheus.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ alerting:
99
alertmanagers:
1010
- static_configs:
1111
- targets:
12-
# - alertmanager:9093
12+
- alertmanager:9093
1313

1414
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
1515
rule_files:
1616
# - "first_rules.yml"
1717
# - "second_rules.yml"
18+
- 'alerts.yml'
1819

1920
# A scrape configuration containing exactly one endpoint to scrape:
2021
# Here it's Prometheus itself.

deploy/docker/common/nginx-config.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ server {
1616
index index.html index.htm;
1717
try_files $uri $uri/ /index.html;
1818
}
19+
location /api/alertmanager{
20+
proxy_pass http://alertmanager:9093/api/v2;
21+
}
1922
location /api {
2023
proxy_pass http://query-service:8080/api;
2124

0 commit comments

Comments
 (0)