amazon-web-services - 通知警报:超出上下文截止日期(可能的代理问题)
问题描述
我正在尝试将 EC2 AWS 中 ubuntu 上的 Alermanager 服务器连接到 Slack,但我收到此错误:
Apr 14 18:22:26 prometheus-db-v01-01a.myserver.com alertmanager[5854]: level=error ts=2019-04-14T18:22:26.658601495Z caller=dispatch.go:177 component=dispatcher msg="Notify for alerts failed" num_alerts=1 err="Post <redacted>: context deadline exceeded"
我的 alertmanager.yum 看起来像:
templates:
- '/etc/alertmanager/template/slack.tmpl'
route:
receiver: slack_general
repeat_interval: 5m
group_by: [alertname]
routes:
# severity=info alerts will not try to match to any other rule
- match:
severity: info
receiver: slack_general
receivers:
- name: slack_general
slack_configs:
- api_url: https://hooks.slack.com/services/ID
send_resolved: true
username: 'Prometheus-bot'
channel: '#errors'
title: '{{ template "slack.my.title" . }}'
text: '{{ template "slack.my.text" . }}'
我可以看到警报触发我的测试警报:
root@prometheus-db-v01-01a:~# amtool alert --alertmanager.url=http://localhost:9093 -v
Alertname Starts At Summary
Cassandra_yellow 2019-04-14 18:11:56 UTC The cassandra cluster is in yellow state
我用 systemd 启动了 prometheus:
root@prometheus-db-v01-01a:~# cat /etc/systemd/system/alertmanager.service
[Unit]
Description=Prometheus Alertmanager Service
Wants=network-online.target
After=network.target
[Service]
Environment=https_proxy=http://proxy:80/
Environment=http_proxy=http://proxy:80/
User=alertmanager
Group=alertmanager
Type=simple
ExecStart=/usr/local/bin/alertmanager \
--config.file /etc/alertmanager/alertmanager.yml \
--storage.path /var/lib/alertmanager/data
Restart=always
[Install]
WantedBy=multi-user.target
root@prometheus-db-v01-01a:~#
我尝试使用 2Environment
变量设置代理,但结果相同
服务器使用代理与 Slack 通信,我可以通过以下方式对其进行测试:
root@prometheus-db-v01-01a:~# curl -X POST --data-urlencode "payload={\"channel\": \"#errors\", \"username\": \"webhookbot\", \"text\": \"This is posted to #errors and comes from a bot named webhookbot.\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/ID
那行得通,而
root@prometheus-db-v01-01a:~# curl -X POST --noproxy "*" --data-urlencode "payload={\"channel\": \"#errors\", \"username\": \"webhookbot\", \"text\": \"This is posted to #errors and comes from a bot named webhookbot.\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/ID
curl: (7) Failed to connect to hooks.slack.com port 443: Connection timed out
以上所有命令均来自 alertmanger 服务器。
我认为这是代理问题是否正确?我该如何设置?
提前致谢
解决方案
问题已解决:它是代理,需要在alertmanager.yml
文件中设置
templates:
- '/etc/alertmanager/template/slack.tmpl'
global:
http_config:
proxy_url: 'http://proxy:80/'
route:
receiver: slack_general
repeat_interval: 5m
group_by: [alertname]
routes:
- match:
severity: minor
receiver: slack_general
receivers:
- name: slack_general
slack_configs:
[...]
推荐阅读
- node.js - 如何为字体文件/ url 进程配置 postCSS 位置?
- azure - Azure SQL Server 数据库无服务器“自动暂停”:恢复速度有多快?
- r - 设置列表中对象的级别和顺序
- spring-boot - 我们可以使用 spring-websockets 和 spring-boot 消息代理来创建我们自己的聊天应用程序,该应用程序应该针对 1M 用户?
- java - springboot java 1.8项目可以用jdk 13运行吗?
- java - CodenameOne - Android 设备上的侧边菜单主题错误
- sql - 用于将行相互折叠的递归 sql 查询
- python - Python 解决 Dataframe 中的复杂库存
- android - Kotlin 中的接收器类型与 Android 的 `activityViewModels` 不匹配
- javascript - 如何根据屏幕大小更改 window.scrollY 侦听器 React