[英]Alertmanager container can't send SMTP email because the connection refused from web hook
[英]Can not send email through alertmanager
docker-compose.yml:服務已啟動並正在運行。
version: '3'
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
ports:
- 9090:9090
volumes:
- ./prometheus/conf:/etc/prometheus
# - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./alertmanager/alert_rules.yml:/alertmanager/alert.rules.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
alertmanager:
image: prom/alertmanager:latest
container_name: alertmanager
ports:
- 9093:9093
volumes:
- ./alertmanager/:/etc/alertmanager/
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
- '--storage.path=/alertmanager'
prometheus.yml:帶有目標和警報目標集的 Prometheus 配置文件。 警報管理器目標 url 工作正常。
global:
scrape_interval: 15s
scrape_timeout: 10s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets:
- 10.10.5.14:9093
scheme: http
timeout: 10s
api_version: v1
rule_files:
- "/alertmanager/alert.rules:/alertmanager/alert.rules"
scrape_configs:
- job_name: 'blackbox'
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets:
- "google.com"
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: localhost:9115
alert.rules:標准警報規則。
groups:
- name: example
rules:
# Alert for any instance that is unreachable for >1 minutes.
- alert: InstanceDown
expr: up == 0
for: 1m
alertmanager.yml:通過 gmail smtp 發送警報的代碼。
route:
group_by: [Alertname]
# Send all notifications to me.
receiver: email-me
receivers:
- name: email-me
email_configs:
- to: anyemail.com
from: senderlogin@gmail.com
smarthost: smtp.gmail.com:587
auth_username: "senderlogin@gmail.com"
auth_identity: "senderlogin@gmail.com"
auth_password: "password"
問題:所有容器都在工作,但普羅米修斯規則中沒有規則。 而且這些字母也不是相應的。 我無法理解我錯過了什么。 歡迎任何提示。 謝謝。 在此處輸入圖像描述 在此處輸入圖像描述
從 prometheus 容器的角度來看,Alertmanager 不在 localhost 上,網絡在容器中命名空間,因此您需要使用 DNS 發現聯系 alertmanager 以找到當前容器 IP。 使用 compose,DNS 會自動配置為服務名稱,在本例中alertmanager
:
alerting:
alertmanagers:
- static_configs:
- targets:
- alertmanager:9093
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.