如何在 Grafana 的松弛通知中编辑 link

How to edit the link in a slack notification from Grafana

我们正在使用 Grafana 4 并通过 Incoming Webhook 实现了对松弛通道的警报通知。通知按预期发送,除了通知中的 link 指向错误的位置。例如,如果您接受以下测试通知:

然后我希望 [Alerting] Test notification 中的 link 指向 Grafana 服务器。但是,link 中的主机是本地主机。我认为这可能只是测试通知的问题,但实际通知也会发生这种情况:路径是正确的,但主机和端口是错误的(localhost:62033,有关详细信息)。

我试图找到配置此 host/port 的位置,但没有成功。关于如何解决此问题的任何提示?

提前致谢。

您可以在 ini 文件中添加许多选项来告诉 Grafana 如何构建自引用 urls:

#################################### Server ##############################
[server]
# Protocol (http or https)
protocol = http

# The http port  to use
http_port = 3000

# The public facing domain name used to access grafana from a browser
domain = localhost

# The full public facing url
root_url = %(protocol)s://%(domain)s:%(http_port)s/

您应该首先将 protocolhttp_portdomain 设置为正确的值。如果您在端口 80 或 443 上访问 Grafana,并且不想在 url 中明确指定该端口,您可以从 root_url 设置中删除 :%(http_port)

除了编辑 grafana.ini,如果您在 Docker 容器中使用 运行 Grafana,您还可以使用环境变量将其传递到容器中(示例使用默认 grafana/grafana容器)。

docker run \ -d \ -p 3000:3000 \ --name=grafana \ -e "GF_SERVER_ROOT_URL=http://grafana.server.name:3000" \ grafana/grafana