conkw documentation - SpecificEmailCheckGrabber

This is the specific email check grabber. It fetches an IMAP folder and look for emails following a defined pattern. It will then expose the date of the latest email it could find.

Use cases

Configuration

{
    "implementation":"net.pieroxy.conkw.webapp.grabbers.email.SpecificEmailCheckGrabber",
    "config": {
        "ttl": "1h",
        "folder": "Backups",
        "subjectRegexp": ".Backup of the NAS.*",
        "bodyRegexp": ".*Backup and Prune finished successfully.*",
        "senderRegexp": "pieroxy@my-server-live",
        "imapConf": {
            "server": "imap.googlemail.com",
            "port": 993,
            "credentialsRef": "myusercreds"
        }
    }
}

Metrics

Here is the metric this grabber outputs:

Usage with borg backup

Borg backup ?

borg is a program that runs, deduplicate, compress, encrypt and keep a history of your backups. I'm not going to go into details here, but here is how I operate it:

So, my script, running every three hours, looks something like:

#!/bin/bash

sh /somewhere/borg-run.sh > /tmp/backup.log 2>&1
cat /tmp/backup.log | mail -a "Content-Type: text/plain; charset=UTF-8" -s "Backups `date`" my_email@gmail.com

How to use SpecificEmailCheckGrabber for this ?

Here is my configuration for the SpecificEmailCheckGrabber:

{
    "implementation":"net.pieroxy.conkw.webapp.grabbers.email.SpecificEmailCheckGrabber",
    "implementation":"net.pieroxy.conkw.webapp.grabbers.email.SpecificEmailCheckGrabber",
    "config": {
        "ttl": "1h",
        "folder": "technicalStuff/Backups",
        "subjectRegexp": "Backups .*",
        "bodyRegexp": ".*Backup and Prune finished successfully.*",
        "senderRegexp": "email@sending-address",
        "imapConf": {
            "server": "imap.googlemail.com",
            "port": 993,
            "credentialsRef": "myUserCreds"
        }
    }
}

What do I get from this ?

These conditions all need some attention on my part, so it's good I get an alert.

This is insane! There are alternatives!

Yes it is. Yes there are. This example just showcases a workflow. That said, it's not as bad as it looks.

You could very well just call the /emi endpoint on backup completion in the borg script. That would directly ingest the date of the last completed backup into your conkw. That would be more direct, but:

You could have a local instance of conkw that would look inside the log file for a pattern and report back to the central instance. Yes. But both last bullets points above still hold true. And the GrabberFilePattern is still not released.

To sum it up, there is no good or bad workflow. A workflow that is stable, reliable and don't produce false positives is a workflow that works. That's what you need. A workflow that works.