Log sent alerts from alert manager to file
Feature request It should be possible to configure alertmanager to log alerts to a file including the complete alert content. I.e. something like a file receiver. I.e. to avoid having to create a webhook service that stores received alerts in a file. Each alert should be stored as a one-liner-json string.
The log file could then be retrieved by a log collection tool to be processed further.
The solution would need to be able to handle that another process rotates/deletes/clears the log file between write attempts. We also would not want to lock the log file when alerts are not actively being written.
Config of alert manager could be something like:
file_configs:
[ send_resolved: <boolean> | default = true ]
file: <path to log file>
Another option could be to rewrite the current webhook_configs: to allow the url: parameter to specify a file: url...
Even if we're not actively adding new receivers and are recommended to implement custom notification integrations via the webhook receiver, we believe this feature request makes sense.
It's recommended to handle logging via a webhook reciever. There's many different formats and rotation strategies that a user could want, so I think that's best left up to an external component.
Hm, what about an "alerts" level logging mode (or something) to stdout, with a single format? It wouldn't be a great burden to implement, and I think most log daemons are happy to integrate that way. I really only have experience with syslogd, so my understanding is biased.
That'd be mixing request logging with the application logging of the alertmanager itself. And still leaves us with format questions.
I know this is old, but exactly something described here is something I am looking for (and is not as directly handled in #2304) I specifically am looking to integrate alert manager alerts into a CLI (interactive shell) running on the same host and a file would be a convenient i/o for that.