linux - “在这种情况下不允许映射值”Alertmanager.yml
问题描述
我将 Alertmanager 0.20 与 Prometheus 一起使用。alertmanager.yml 的配置没问题,但是如果我尝试在代理后面添加 proxy_url,并且根据文档配置,我们需要在 http_config 下设置 proxy_url。
使用这两个,Alertmanager 开始失败并出现以下错误:
systemd[1]: Stopped Alert Manager.
systemd[1]: Started Alert Manager.
alertmanager[22866]: level=info ts=2020-12-30T17:37:20.679Z caller=main.go:216 msg="Starting Alertmanager" version="(version=0.21.0, branch=HEAD, revision=4c6c03ebfe21009c546e4d1e9b92c371d67c021d)"
alertmanager[22866]: level=info ts=2020-12-30T17:37:20.679Z caller=main.go:217 build_context="(go=go1.14.4, user=root@dee35927357f, date=20200617-08:54:02)"
alertmanager[22866]: level=info ts=2020-12-30T17:37:20.680Z caller=cluster.go:161 component=cluster msg="setting advertise address explicitly" addr=xxx.xxx.xxx.xxx port=9094
alertmanager[22866]: level=info ts=2020-12-30T17:37:20.681Z caller=cluster.go:623 component=cluster msg="Waiting for gossip to settle..." interval=2s
alertmanager[22866]: level=info ts=2020-12-30T17:37:20.705Z caller=coordinator.go:119 component=configuration msg="Loading configuration file" file=/etc/prometheus/alertmanager.yml
alertmanager[22866]: level=error ts=2020-12-30T17:37:20.705Z caller=coordinator.go:124 component=configuration msg="Loading configuration file failed" file=/etc/prometheus/alertmanager.yml err="yaml: **line 4: mapping values are not allowed in this context**"
alertmanager[22866]: level=info ts=2020-12-30T17:37:20.705Z caller=cluster.go:632 component=cluster msg="gossip not settled but continuing anyway" polls=0 elapsed=23.966326ms
systemd[1]: alertmanager.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: alertmanager.service: Failed with result 'exit-code'.
prometheus[14952]: level=error ts=2020-12-30T17:37:20.779Z caller=notifier.go:527 component=notifier alertmanager=http://localhost:9093/api/v1/alerts count=2 msg="Error sending alert" err="Post \"http://localhost:9093/api/v1/alerts\": dial tcp [::1]:9093: connect: connection refused"
systemd[1]: alertmanager.service: Service RestartSec=100ms expired, scheduling restart.
systemd[1]: alertmanager.service: Scheduled restart job, restart counter is at 5.
systemd[1]: Stopped Alert Manager.
systemd[1]: alertmanager.service: Start request repeated too quickly.
systemd[1]: alertmanager.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Alert Manager.
我的警报管理器版本:
alertmanager, version 0.21.0 (branch: HEAD, revision:
4c6c03ebfe21009c546e4d1e9b92c371d67c021d) build user:
root@dee35927357f build date: 20200617-08:54:02 go version:
go1.14.4
我的 alertmanager.yml
global:
http_config:
proxy_url: http://ip:port
smtp_smarthost: smtp_server_name:port
smtp_from: from@email.com
smtp_auth_username: auth@email.com
route:
group_by: [alertname]
repeat_interval: 1m
receiver: live-monitoring
receivers:
- name: live-monitoring
email_configs:
- to: to@email.com
知道如何使 alertmanager 工作并使用代理配置发送电子邮件吗?而且我不能在 route: 或接收者之前设置 http_config 和 proxy_url,否则
field http_config not found in type config.plain
解决方案
缩进在 YAML 中很重要。您似乎在配置中的多个位置损坏了它。正确结构的快速示例:
global:
http_config:
proxy_url: ....
smtp_smarthost:
...
route:
...
receivers:
...
请注意开头的空格以及它们如何表示配置选项的嵌套。
推荐阅读
- r - 在 UI 中的输入之间建立依赖关系
- sql - 从 SQL Server 中的重复行中筛选
- python - 找到余弦相似度后对数组进行重构
- amazon-dynamodb - 使用 DynamoDb 回滚?
- php - 设置 CHMOD 777 后 /bin/node 权限被拒绝
- c# - 使用 C# 关闭网络中的特定计算机
- amazon-web-services - 确定 Amazon DynamoDB 表的读取容量单位
- java - 使用改造将android图像上传到服务器
- javascript - html5自定义元素的自定义方法和属性
- admob - 广告一整天都看不到,只有晚上一定时间为什么?