【问题标题】:Grafana email does not have the right url when root_url is set to '%(protocol)s://%(domain)s:%(http_port)s/grafana'当 root_url 设置为 '%(protocol)s://%(domain)s:%(http_port)s/grafana' 时,Grafana 电子邮件没有正确的 url
【发布时间】:2020-05-19 19:13:44
【问题描述】:

我正在为电子邮件邀请设置 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


    【解决方案1】:

    您需要实际定义所有变量,否则它们将使用默认值,即您在电子邮件中看到的值;如果您像我一样通过代理服务器运行,您可能需要更改 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/'
    

    【讨论】:

    • 我已经通过 nginx 入口控制器暴露了 grafana,这就是为什么 grafana.ini 除了 root_url 的子路径和标志 serve_from_sub_path 设置为 true 之外具有默认值的原因。除了这个 smtp 部分,我的 grafana 工作得很好;我认为,Grafana 没有看到电子邮件的入口部分,TBH 不需要看到 - 有没有办法可以修改/自定义发送的电子邮件内容?
    • 电子邮件是根据服务器配置动态生成的,如果您阅读root_url 行上方的 cmets,它明确指出这是用于电子邮件的内容。在当前版本(v6.5.3)上对我来说工作正常尝试完全变量:root_url = 'https://metrics.example.com/grafana/'
    • 我找到了邮件内容模板所在的地方,但是不能自定义;我想,会有人有我使用 ingress/nginx 来公开 grafana 的用例,并且希望有一个自定义电子邮件内容的选项。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-09
    • 2011-04-23
    • 2019-01-28
    • 2014-11-02
    • 2014-08-30
    • 2010-10-30
    • 2014-09-26
    相关资源
    最近更新 更多