Segui todas as configurações descritas para emitir o alerta no slack mas não os recebo. Estou executando o docker num MAC M1.
alertmanager.yml
global:
slack_api_url: 'https://hooks.slack.com/services/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'
templates:
- '/etc/alertmanager/template/*.tmpl'
route:
group_by: [app, group, env]
receiver: 'OPRTS-DEUPETCH'
group_wait: 15s
group_interval: 15s
repeat_interval: 1m
receivers:
- name: 'OPRTS-DEUPETCH'
slack_configs:
- channel: '#alerts-testes'
send_resolved: true
icon_url: https://avatars3.githubusercontent.com/u/3380462
title: |-
[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .CommonLabels.alertname }} for {{ .CommonLabels.app }}
{{- if gt (len .CommonLabels) (len .GroupLabels) -}}
{{" "}}(
{{- with .CommonLabels.Remove .GroupLabels.Names }}
{{- range $index, $:label := .SortedPairs -}}
{{ if $index }}, {{ end }}
{{- $label.Name }}="{{ $label.Value -}}"
{{- end }}
{{- end -}}
)
{{- end }}
text: >-
{{ range .Alerts -}}
*Alert:* {{ .Annotations.title }}{{ if .Labels.severity }} - `{{ .Labels.severity }}`{{ end }}
*Summary:* {{ .Annotations.summary }}
*Description:* {{ .Annotations.description }}
*Details:*
{{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
{{ end }}
{{ end }}
prometheus.yml
global:
scrape_interval: 5s
rule_files:
- alert.rules
alerting:
alertmanagers:
- static_configs:
- targets:
- alertmanager-forum-api:9093
scrape_configs:
- job_name: prometheus-forum-api
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
scheme: http
static_configs:
- targets:
- prometheus-forum-api:9090
- job_name: app-forum-api
metrics_path: /actuator/prometheus
static_configs:
- targets:
- app-forum-api:8080
alert.rules
groups:
- name: OPRTS-DEUPETCH
rules:
- alert: 'QUEBRA DE SLO'
expr: (histogram_quantile(0.90, sum(rate(http_server_requests_seconds_bucket{job="app-forum-api",uri!="/actuator/prometheus"}[1m])) by (le))) >= 0.5
for: 1m
labels:
app: 'api-forum-alura'
severity: 'critical'
group: 'OPRTS-DEUPETCH'
env: 'production'
annotations:
title: 'QUEBRA DE SLO'
summary: '...'
description: '...'
- alert: 'ERRO 500'
expr: (sum(rate(http_server_requests_seconds_count{job="app-forum-api", status="500", uri!="/actuator/prometheus"}[1m]))/sum(rate(http_server_requests_seconds_count{job="app-forum-api", uri!="/actuator/prometheus"}[1m]))) >= 0.01
for: 1m
labels:
app: 'api-forum-alura'
severity: 'critical'
group: 'OPRTS-DEUPETCH'
env: 'production'
annotations:
title: 'ERRO 500'
summary: '...'
description: '...'
docker-compose.yml
version: '3'
networks:
database:
internal: true
cache:
internal: true
api:
internal: true
monit:
proxy:
services:
...
prometheus-forum-api:
image: prom/prometheus:latest
container_name: prometheus-forum-api
restart: unless-stopped
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus/alert.rules:/etc/prometheus/alert.rules
- ./prometheus/prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--web.enable-lifecycle'
ports:
- 9090:9090
networks:
- monit
- api
alertmanager-forum-api:
image: prom/alertmanager
container_name: alertmanager-forum-api
volumes:
- ./alertmanager:/etc/alertmanager/:ro
ports:
- 9093:9093
command:
- --config.file=/etc/alertmanager/alertmanager.yml
networks:
- monit
depends_on:
- prometheus-forum-api
grafana-forum-api:
image: grafana/grafana
container_name: grafana-forum-api
volumes:
- ./grafana:/var/lib/grafana
restart: unless-stopped
ports:
- 3000:3000
networks:
- monit
depends_on:
- alertmanager-forum-api
...