首页 > 解决方案 > 当 root_url 设置为 '%(protocol)s://%(domain)s:%(http_port)s/grafana' 时,Grafana 电子邮件没有正确的 url

问题描述

我正在为电子邮件邀请设置 Grafana Smtp。我正在使用 grafana helm chart,我的配置如下所示 -

grafana.ini:
  smtp:
    enabled: true
    host: smtp.sendemail.com:587
    user: 'someuser'
    password: 'somepassword'
    from_address: join-grafana@somewhere.com
    from_name: Join Us At Grafana
  server:
    root_url: '%(protocol)s://%(domain)s:%(http_port)s/grafana'
    serve_from_sub_path: true

当我发送电子邮件邀请时,电子邮件具有指向http://localhost:3000/grafana/的链接...不是我设置的域名;出于各种目的,我可以通过域名使用 grafana url,例如 - https://somedomain.com/grafana

什么可能是错的?

标签: grafana

解决方案


您需要实际定义所有变量,否则它们将使用默认值,这就是您在电子邮件中看到的;如果您像我一样通过代理服务器运行,您可能需要更改 URL 模板:

[server]
# Protocol (http, https, h2, socket)
protocol = http

# The http port  to use
http_port = 3030

# The public facing domain name used to access grafana from a browser
domain = metrics.example.com

# The full public facing url you use in browser, used for redirects and emails
# If you use reverse proxy and sub path specify full url (with sub path)
root_url = 'https://%(domain)s/grafana/'

推荐阅读