Grafana不通过反向代理发送通知

Grafana不通过反向代理发送通知

我在没有互联网的服务器上使用 Grafana,我需要发送 Telegram 通知,为此我在另一台机器上使用 Nginx 服务器。

服务器 A:

  • Grafana 已安装并在端口 3000 上运行。
  • Grafana 网址:www.example.grafana.com
  • 服务器 IP(示例):10.16.216.122
  • 它使用这个 webhook 发送电报消息:api.telegram.org
  • 我还配置了 /etc/hosts 以将通知发送到我的服务器:
#/etc/hosts
10.16.216.16  api.telegram.org

服务器B:

  • 服务器 IP(示例):10.16.216.16
  • Nginx 安装如下,配置如下:
server {
    listen 80;
    listen [::]:80 http2 ssl;

    server_name http://10.16.216.122;
    location / {
        proxy_pass http://10.16.216.122:3000/;
    }}

当我尝试发送通知时,我在日志中收到以下信息:

t=2021-10-27T17:10:07+0200 lvl=eror msg="Failed to send webhook" logger=alerting.notifier.telegram error="Post https://api.telegram.org/botXXXXXXXXXX/sendMessage: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)" webhook=TelegramTest
t=2021-10-27T17:10:07+0200 lvl=eror msg="failed to send notification" logger=alerting.notifier uid= error="Post https://api.telegram.org/botXXXXXXXXXXXXXX/sendMessage: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
t=2021-10-27T17:10:07+0200 lvl=eror msg="failed to send notification" logger=alerting.notifier uid= error="Post https://api.telegram.org/botXXXXXXXXXXXXXXXXXXX/sendMessage: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
t=2021-10-27T17:10:07+0200 lvl=eror msg="Failed to send alert notifications" logger=context userId=51 orgId=5 uname=XXXX error="Post https://api.telegram.org/botXXXXXXXXXXXXX/sendMessage: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
t=2021-10-27T17:10:07+0200 lvl=eror msg="Request Completed" logger=context userId=51 orgId=5 uname=XXXXX method=POST path=/api/alert-notifications/test status=500 remote_addr=10.26.216.122 time_ms=30006 size=48 referer=http://10.26.216.122/alerting/notification/1/edit

我在 Nginx 上的配置中缺少了什么吗?服务器 A 是否需要其他配置才能正常工作?

答案1

Webhooks 是来自 grafana 的传出连接。反向代理处理传入连接。

如果你还想代理传出连接,则必须配置一个普通的正向代理,配置 Grafana 以将其用于传出请求。

相关内容