
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
一个轻量级Go Web服务器,可接收来自Prometheus Alert Manager的POST告警消息,并通过传入的webhook URL将其发送到Microsoft Teams频道。
选项1:使用Docker运行
bashdocker run -d -p 2000:2000 \ --name="promteams" \ -e TEAMS_INCOMING_WEBHOOK_URL="https://outlook.office.com/webhook/xxx" \ -e PROMTEAMS_DEBUG="true" \ docker.io/bzon/prometheus-msteams:latest
默认情况下,prometheus-msteams会创建一个请求URI处理器/alertmanager。
yamlroute: group_by: ['alertname'] group_interval: 30s repeat_interval: 30s group_wait: 30s receiver: 'prometheus-msteams' receivers: - name: 'prometheus-msteams' webhook_configs: # https://prometheus.io/docs/alerting/configuration/#webhook_config - send_resolved: true url: 'http://localhost:2000/alertmanager' # prometheus-msteams代理地址
若尚未运行Prometheus并希望尝试该工具,可参考https://github.com/stefanprodan%E7%9A%84https://github.com/stefanprodan/dockprom%EF%BC%8C%E5%BF%AB%E9%80%9F%E5%9C%A8%E5%8D%95%E5%8F%B0%E6%9C%BA%E5%99%A8%E4%B8%8A%E5%AE%89%E8%A3%85%E6%9C%AC%E5%9C%B0Prometheus%E7%8E%AF%E5%A2%83%E3%80%82
创建prom-alert.json文件,内容如下:
json{ "version": "4", "groupKey": "{}:{alertname=\"high_memory_load\"}", "status": "firing", "receiver": "teams_proxy", "groupLabels": { "alertname": "high_memory_load" }, "commonLabels": { "alertname": "high_memory_load", "monitor": "master", "severity": "warning" }, "commonAnnotations": { "summary": "Server High Memory usage" }, "externalURL": "http://docker.for.mac.host.internal:9093", "alerts": [ { "labels": { "alertname": "high_memory_load", "instance": "10.80.40.11:9100", "job": "docker_nodes", "monitor": "master", "severity": "warning" }, "annotations": { "description": "10.80.40.11 reported high memory usage with 23.28%.", "summary": "Server High Memory usage" }, "startsAt": "2018-03-07T06:33:21.873077559-05:00", "endsAt": "0001-01-01T00:00:00Z" } ] }
执行以下命令发送模拟告警:
bashcurl -X POST -d @prom-alert.json http://localhost:2000/alertmanager
Teams频道应会收到告警消息。
创建prometheus-msteams配置文件:
yamlconnectors: - high_priority_channel: "https://outlook.office.com/webhook/xxxx/aaa/bbb" - low_priority_channel: "https://outlook.office.com/webhook/xxxx/aaa/ccc"
注意:high_priority_channel和low_priority_channel为示例处理器名称。
运行Docker容器时,需挂载配置文件并设置CONFIG_FILE环境变量:
bashdocker run -d -p 2000:2000 \ --name="promteams" \ -v /tmp/config.yml:/tmp/config.yml \ -e CONFIG_FILE="/tmp/config.yml" \ -e PROMTEAMS_DEBUG="true" \ docker.io/bzon/prometheus-msteams:latest
若以二进制运行,使用--config参数:
bashPROMTEAMS_DEBUG="true" prometheus-msteams server \ -l localhost \ -p 2000 \ --config /tmp/config.yml
这将创建/high_priority_channel和/low_priority_channel两个请求URI处理器。
结合上述配置文件,Alert Manager配置示例如下:
yamlroute: group_by: ['alertname'] group_interval: 30s repeat_interval: 30s group_wait: 30s receiver: 'low_priority_receiver' # 默认/ fallback请求处理器 routes: - match: severity: critical receiver: high_priority_receiver - match: severity: warning receiver: low_priority_receiver receivers: - name: 'high_priority_receiver' webhook_configs: - send_resolved: true url: 'http://localhost:2000/high_priority_channel' # 请求处理器1 - name: 'low_priority_receiver' webhook_configs: - send_resolved: true url: 'http://localhost:2000/low_priority_channel' # 请求处理器2
为便于调试,设置环境变量PROMTEAMS_DEBUG=true,可查看从Prometheus接收的JSON体及发送至Microsoft Teams的JSON体:
json2018/03/19 11:21:23 Request received from Prometheus Alert Manager { "version": "4", "groupKey": "{}:{alertname=\"high_memory_load\"}", "status": "firing", "receiver": "teams_proxy", "groupLabels": { "alertname": "high_memory_load" }, "commonLabels": { "alertname": "high_memory_load", "monitor": "master", "severity": "warning" }, "commonAnnotations": { "summary": "Server High Memory usage" }, "externalURL": "[***]", "alerts": [ { "labels": { "alertname": "high_memory_load", "instance": "10.80.40.11:9100", "job": "docker_nodes", "monitor": "master", "severity": "warning" }, "annotations": { "description": "10.80.40.11 reported high memory usage with 23.28%.", "summary": "Server High Memory usage" }, "startsAt": "2018-03-07T06:33:21.873077559-05:00", "endsAt": "0001-01-01T00:00:00Z" } ] } 2018/03/19 11:21:23 Created a card for Microsoft Teams { "@type": "MessageCard", "@context": "[***]", "themeColor": "8C1A1A", "summary": "Server High Memory usage", "title": "Prometheus Alert (firing)", "sections": { "activityTitle": "[10.80.40.11 reported high memory usage with 23.28%.", "facts": [ { "name": "description", "value": "10.80.40.11 reported high memory usage with 23.28%." }, { "name": "summary", "value": "Server High Memory usage" }, { "name": "job", "value": "docker_nodes" }, { "name": "monitor", "value": "master" }, { "name": "severity", "value": "warning" }, { "name": "alertname", "value": "high_memory_load" }, { "name": "instance", "value": "10.80.40.11:9100" } ], "markdown": false } ] }
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务