IzakMarais / reporter

Service that generates a PDF report from a Grafana dashboard
Apache License 2.0
946 stars 304 forks source link

The API try to send an email to 'postmaster@grafana' every time is called #341

Closed giuliomagnifico closed 1 year ago

giuliomagnifico commented 1 year ago

Hi and thanks for this, it is very useful, I've also customized it using some other font and dark theme, and other things (screenshot), but I have one issue that I can't resolve alone:

Everytime cron call the API (or I do it via the Link/URL in the dashboard), for some reasons Grafana try to send an email to postmaster@Grafana, that obviously fails, and Google send me the Delivery Status Notification (Failure) mail every time. I have neve configured the smtp in Grafana.ini, now I also disabled it, but this weird behavior still happens.

This is not triggered by the mail -s command in cron, but is triggered by the API/curl, indeed I'm receving the mail at 00:07 and not 05:07.

Example of my crontab

#OpenWrt morning report 
00 07 * * * curl -J -L 'http://192.168.1.6:8686/api/v5/report/fLi0yXAWk?apitoken=xxx==&theme=dark&from=now-12h&to=now&var-job=prometheus&var-name=R4S&var-node=192.168.1.2&var-port=9100' --output OpenWRT.pdf
05 07 * * * echo "" | mail -s "Daily OpenWrt stats" giuliomagnifico@gmail.com --attach=OpenWRT.pdf

Screenshot 2022-11-11 at 08 43 48

See the time:

Screenshot 2022-11-11 at 08 44 01

With this message (the shell output)

[...]
From: root <giuliomagnifico@gmail.com>
X-Google-Original-From: root (Cron Daemon)
Received: by Grafana (sSMTP sendmail emulation); Fri, 11 Nov 2022 08:20:28 +0100
Date: Fri, 11 Nov 2022 08:20:28 +0100
To: root
Subject: Cron <root@Grafana> curl -J -L 'http://192.168.1.6:8686/api/v5/report/fLi0yXAWk?apitoken=xxx==&theme=dark&from=now-12h&to=now&var-job=prometheus&var-name=R4S&var-node=192.168.1.2&var-port=9100' --output OpenWRT.pdf
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>

It's an issue with the API or I have to change something? I also don't know where to look, I've nevere enabled the mail alerts (only Pushover) nor this mail address (postmaster@Grafana) somewhere.

Because every 12h I get in my inbox the mail from Grafana/cron with my pdf plus the "Delivery Status Notification (Failure)" mail, and this is annoying.

Thanks for the help!

IzakMarais commented 1 year ago

I’m afraid I have no idea. there was no mention of email being triggered by the grafana API calls made by the reporter.

On 11 Nov 2022, at 09:45, giuliomagnifico @.***> wrote:

Hi and thanks for this, it is very useful, I've also customized it using some other font and dark theme, and other things (screenshot https://user-images.githubusercontent.com/1975176/201290393-00262041-a90a-4f76-b877-31c558e1107f.jpg), but I have one issue that I can't resolve alone:

Everytime cron call the API (or I do it via the Link/URL in the dashboard), for some reasons Grafana try to send an email to @.***, that obviously fails, and Google send me the Delivery Status Notification (Failure) mail every time. I have neve configured the smtp in Grafana.ini, now I also disabled it, but this weird behavior still happens.

This is not triggered by the mail -s command in cron, but is triggered by the API/curl, indeed I'm receving the mail at 00:07 and not 05:07.

Example of my crontab

OpenWrt morning report

00 07 curl -J -L 'http://192.168.1.6:8686/api/v5/report/fLi0yXAWk?apitoken=xxx==&theme=dark&from=now-12h&to=now&var-job=prometheus&var-name=R4S&var-node=192.168.1.2&var-port=9100' --output OpenWRT.pdf 05 07 echo "" | mail -s "Daily OpenWrt stats" @.*** --attach=OpenWRT.pdf https://user-images.githubusercontent.com/1975176/201291194-b57419e4-4936-41ff-b2ce-9a8134aae5ec.png See the time:

https://user-images.githubusercontent.com/1975176/201291208-60d4a431-9ada-493b-9cfa-77b853a3b342.png With this message (the shell output)

[...] From: root @.> X-Google-Original-From: root (Cron Daemon) Received: by Grafana (sSMTP sendmail emulation); Fri, 11 Nov 2022 08:20:28 +0100 Date: Fri, 11 Nov 2022 08:20:28 +0100 To: root Subject: Cron @.> curl -J -L 'http://192.168.1.6:8686/api/v5/report/fLi0yXAWk?apitoken=xxx==&theme=dark&from=now-12h&to=now&var-job=prometheus&var-name=R4S&var-node=192.168.1.2&var-port=9100' --output OpenWRT.pdf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Cron-Env: X-Cron-Env: X-Cron-Env: X-Cron-Env: It's an issue with the API or I have to change something? I also don't know where to look, I've nevere enabled the mail alerts (only Pushover) nor this mail address @.***) somewhere.

Because every 12h I get in my inbox the mail from Grafana/cron with my pdf plus the "Delivery Status Notification (Failure)" mail, and this is annoying.

Thanks for the help!

— Reply to this email directly, view it on GitHub https://github.com/IzakMarais/reporter/issues/341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB7CHEB7TW4M5HSBR77YVEDWHX2TJANCNFSM6AAAAAAR5K3XPM. You are receiving this because you are subscribed to this thread.

giuliomagnifico commented 1 year ago

Thanks for the reply, yes I'm not sure that's triggered by the Grafana API, it's my deduction since it's the only thing that is called via CURL, I also tried to ask on the Grafana community and they said that maybe could be an issue with the API.

Screenshot 2022-11-12 at 07 54 12

https://community.grafana.com/t/grafana-sends-an-email-automatically-to-postmaster-grafana-but-ive-never-configured-it/75537/7

giuliomagnifico commented 1 year ago

Solved adding an automatic deletion of all the mails from postmaster@grafana. Not the best way but it works...