Skip to content

Commit

Permalink
feat: add demo alert rules
Browse files Browse the repository at this point in the history
  • Loading branch information
dy0gu committed Nov 26, 2024
1 parent f5d92a0 commit 30f369d
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
LOKI_PORT=3100
GRAFANA_PORT=4859
GRAFANA_ALERT_RECEIVERS=desenvolvimento@neiaac.com,direcao@neiaac.com
GF_SMTP_ENABLED=true
GF_SMTP_FROM_ADDRESS=no-reply@neiaac.com
GF_SMTP_FROM_NAME=no-reply
GF_SMTP_HOST=email-smtp.eu-north-1.amazonaws.com:587
GF_SMTP_STARTTLS_POLICY=OpportunisticStartTLS
GF_SMTP_USER=user
GF_SMTP_PASSWORD=password
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ services:
volumes:
- ./grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
- ./grafana-dashboards.yaml:/etc/grafana/provisioning/dashboards/dashboards.yaml
- ./grafana-alert-triggers.yaml:/etc/grafana/provisioning/alerting/triggers.yaml
- ./grafana-alert-contacts.yaml:/etc/grafana/provisioning/alerting/contacts.yaml
- ./grafana-metrics-dashboard.json:/var/lib/grafana/dashboards/metrics.json
- ./grafana-logs-dashboard.json:/var/lib/grafana/dashboards/logs.json
- grafana-data:/var/lib/grafana
Expand Down
10 changes: 10 additions & 0 deletions grafana-alert-contacts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: 1

contactPoints:
name: grafana-default-email
receivers:
- uid: grafana-default-email
type: email
settings:
addresses: ${GRAFANA_ALERT_RECEIVER}
singleEmail: true
102 changes: 102 additions & 0 deletions grafana-alert-triggers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
apiVersion: 1

groups:
name: Overload
folder: metrics
interval: 60s
rules:
- uid: cpu
title: CPU Usage
condition: A
data:
- refId: A
datasourceUid: "prometheus"
model:
conditions:
- evaluator:
params:
- 50
type: gt
operator:
type: and
query:
params:
- "100 * (1 - avg(rate(node_cpu_seconds_total{mode='idle', job='node'}[5m])) by (instance))"
reducer:
type: last
type: query
datasource:
type: prometheus
uid: "prometheus"
expression: 1==0
intervalMs: 1000
maxDataPoints: 43200
refId: A
type: math
noDataState: Alerting
execErrState: Alerting
for: 60s

- uid: disk_usage
title: Disk Usage
condition: A
data:
- refId: A
datasourceUid: "prometheus"
model:
conditions:
- evaluator:
params:
- 90
type: gt
operator:
type: and
query:
params:
- "100 * (1 - avg(rate(node_filesystem_free_bytes{fstype!='tmpfs', job='node'}[5m])) by (instance) / avg(rate(node_filesystem_size_bytes{fstype!='tmpfs', job='node'}[5m])) by (instance))"
reducer:
type: last
type: query
datasource:
type: prometheus
uid: "prometheus"
expression: 1==0
intervalMs: 1000
maxDataPoints: 43200
refId: A
type: math
noDataState: Alerting
execErrState: Alerting
for: 60s

- uid: ram_usage
title: RAM Usage
condition: A
data:
- refId: A
datasourceUid: "prometheus"
model:
conditions:
- evaluator:
params:
- 50
type: gt
operator:
type: and
query:
params:
- "100 * (1 - avg(rate(node_memory_MemFree_bytes{job='node'}[5m])) by (instance) / avg(rate(node_memory_MemTotal_bytes{job='node'}[5m])) by (instance))"
reducer:
type: last
type: query
datasource:
type: prometheus
uid: "prometheus"
expression: 1==0
intervalMs: 1000
maxDataPoints: 43200
refId: A
type: math
noDataState: Alerting
execErrState: Alerting
for: 60s
1 change: 0 additions & 1 deletion grafana-dashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ apiVersion: 1

providers:
- name: Dashboards
orgId: 1
type: file

updateIntervalSeconds: 10
Expand Down

0 comments on commit 30f369d

Please sign in to comment.