mcuadros/ofelia

Missing/incomplete information in the email from Ofelia

issrec opened this issue · 1 comments

This configuration:

[global]
smtp-host = xxx
smtp-port = xxx
smtp-user = xxx
smtp-password = xxx
email-from = xxx
email-to = xxx
mail-only-on-error = true

[job-exec "cleanup-logs-directory-without-javamelody"]
schedule = 0 0 20 ? * MON,FRI
container = system
user = tomcat
command = /bin/sh -c 'find /usr/local/tomcat/logs/ -name \"javamelody\" -prune -or ! -type d -mtime ${_RETENTION_DAYS_LOGS} -print0 |sort -z |xargs -0r rm -vf --'
no-overlap = true

Ofelia's container log entries:

...
2024-05-28T02:00:00.04+02:00  common.go:125 ▶ NOTICE [Job "cleanup-logs-directory-without-javamelody" (10790174fcdd)] Started - /bin/sh -c 'find /usr/local/tomcat/logs/ -name "javamelody" -prune -or ! -type d -mtime ${_RETENTION_DAYS_LOGS} -print0 |sort -z |xargs -0r rm -vf --'
2024-05-28T02:00:01.894+02:00  common.go:121 ▶ ERROR [Job "cleanup-logs-directory-without-javamelody" (10790174fcdd)] Finished in "9.569522ms", failed: true, skipped: false, error: error creating exec: API error (409): Container b1d44c9afd7de9a4af0e1f13fd7df0eb7f4f72b3c9d728273fd8fab6ef31ebe5 is not running
...

The attachment cleanup-logs-directory-without-javamelody_10790174fcdd.stderr.json in the email from Ofelia looks like this:

{
  "Execution": {
    "ID": "10790174fcdd",
    "Date": "2024-05-28T02:00:00.040474798+02:00",
    "Duration": 9569522,
    "IsRunning": false,
    "Failed": true,
    "Skipped": false,
    "Error": {}
  },
  "Job": {
    "Schedule": "0 0 2 ? * ?",
    "Name": "cleanup-logs-directory-without-javamelody",
    "Command": "/bin/sh -c 'find /var/logs/ -name \"javamelody\" -prune -or ! -type d -mtime ${_RETENTION_DAYS_LOGS} -print0 |sort -z |xargs -0r rm -vf --'",
    "Container": "system",
    "User": "tomcat",
    "TTY": false,
    "Environment": [],
    "NoOverlap": true,
    "SlackWebhook": "",
    "SlackOnlyOnError": false,
    "SaveFolder": "",
    "SaveOnlyOnError": false,
    "SMTPHost": "",
    "SMTPPort": 0,
    "SMTPUser": "",
    "SMTPPassword": "",
    "SMTPTLSSkipVerify": false,
    "EmailTo": "",
    "EmailFrom": "",
    "MailOnlyOnError": false
  }
}

As you can see, the following information is missing or incorrect in the email from Ofelia:

  • Execution.Error
  • Job.SMTPHost
  • Job.SMTPPort
  • Job.SMTPUser
  • Job.SMTPPassword (for security reasons: anonymized or skipped)
  • Job.EmailTo
  • Job.EmailFrom
  • Job.MailOnlyOnError

Same here - the globally defined values are always missing or incorrect, only the locally defined values are reported correctly.