SMTP with kubernetes (k3s)

Greetings,
I’m trying to configure a mail alert with grafana, but I’m facing an issue: the SMTP is not being configured (note: in the following sections I have put a dot in each link between square brackets to prevent it being detected as link and then blocked - just ignore those [ ]).

What I tried

  • In the file /etc/environment I have set the following variables:
    GF_SMTP_HOST=smtp.xxx[.]net
    GF_SMTP_USER=xxx@xxx[.]net
    GF_SMTP_PASSWORD=xxx
    GF_SMTP_FROM_ADDRESS=xxx@xxx[.]net
    GF_SMTP_FROM_NAME=Monitor
    GF_SMTP_SKIP_VERIFY=true
  • In the deployment yaml:
    env:
    - name: GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH
    value: /var/lib/grafana/dashboards/network-dashboard.json
    - name: GF_INSTALL_PLUGINS
    value: https:[//]grafana[.]com/api/plugins/gowee-traceroutemap-panel/versions/0.2.3/download;gowee-traceroutemap-panel
    - name: GF_SMTP_ENABLED
    value: “true”
    - name: GF_SMTP_HOST
    value: smtp.xxx[.]net
    - name: GF_SMTP_USER
    value: xxx@xxx[.]net
    - name: GF_SMTP_PASSWORD
    value: xxx
    - name: GF_SMTP_FROM_ADDRESS
    value: xxx@xxx[.]net
    - name: GF_SMTP_FROM_NAME
    value: Monitor
    - name: GF_SMTP_SKIP_VERIFY
    value: “true”
  • When running it on docker (with a make file)
    @docker run --network host -v “$(PWD)/docker-compose/grafana:/app” --rm curlimages/curl:7.73.0
    -s --location -XPOST ‘http:[//]admin:admin@127.0.0.1:3000/api/datasources’
    -e “GF_SMTP_ENABLED=true”
    -e “GF_SMTP_HOST=smtp.xxx[.]net”
    -e “GF_SMTP_USER=xxx@xxx[.]net”
    -e “GF_SMTP_PASSWORD=xxx”
    -e “GF_SMTP_FROM_ADDRESS=xxx@xxx[.]net”
    -e “GF_SMTP_FROM_NAME=Monitor”
    -e “GF_SMTP_SKIP_VERIFY=true”
    –header ‘Content-Type: application/json’ -d @/app/datasource.json > /dev/null
  • In the /etc/grafana/grafana.ini’s smtp section:
    [smtp]
    enabled = true
    host = smtp.xxx[.]net
    user = xxx@xxx[.]net
    password = xxx
    ;cert_file =
    ;key_file =
    skip_verify = true
    from_address = xxx@xxx.[.]net
    from_name = Monitor
    ;ehlo_identity = dashboard.example[.]com
    ;startTLS_policy = NoStartTLS

What I expected

  • To be able to send a test email in the alert section
  • To view my configuration in the grafana’s /admin/settings section

What actually happened

  • I get this error while trying to send a test email: “SMTP not configured, check your grafana.ini config file’s [smtp] section”
  • The /admin/settings section has the default configuration

Question

Am I missing something? It seems that grafana does not load the configuration, even if I tried several different methods. I even tried a few times to reboot the computer and reset kubernetes.
Thank you for any help or suggestion

Hi @massimilianomicol

Grafana’s transition from legacy alerting to the Unified Alerting platform represents a big step forward. But, there are many factors that can influence behavior, and it is often hard for the community to troubleshoot issues without a thorough understanding of your unique setup. Try to include the following info:

  • What is your Grafana version?
  • Are you using Grafana Cloud or self-hosted Grafana?
  • Are you using legacy alerting or Unified Alerting?
  • was the alert in question migrated from the legacy platform into Unified Alerting, or did you first create it inside the new platform?
  • Please list ALL configuration options related to alerting. You can find these in the Alerting and Unified Alerting sections of Grafana’s config file. If you are now using or have previously used the beta version of ngalert (released with Grafana 8), please note that too.
    • you can use this table to better understand how configuration options can interact with each other
  • If this is a templating issue on Unified Alerting, check if your alert is using a multi-dimensional rule or not.
  • List the datasource associated with the alert
  • Increase the verbosity of the Grafana server logs to debug and note any errors. For printing to console, set the console logs to debug as well.
  • Search for open issues on GitHub that sound similar to your problem