supercronic icon indicating copy to clipboard operation
supercronic copied to clipboard

structured logging

Open ctcjab opened this issue 1 year ago • 3 comments

Adding support for json structured logging would enable supercronic users to easily have logs consumed by Datadog (and similar platforms) such that the data in each log message is properly preserved as separate fields (log level, time, message, any extra params).

I read the https://github.com/aptible/supercronic#logging docs but didn't see anything about structured logging (or otherwise customizing the log format). See also #183.

ctcjab avatar Dec 04 '24 19:12 ctcjab

Note, not having things like the log level picked up properly means that downstream things like monitoring and alerting are harder to set up as well (e.g. when a threshold of error logs is reached).

ctcjab avatar Dec 04 '24 19:12 ctcjab

Supercronic already supports structured logging.

For json use -json CLI flag.

root@container:/var/www# /usr/local/bin/supercronic -json -test /crontab 
{"level":"warning","msg":"process reaping disabled, not pid 1","time":"2025-01-28T20:34:44+01:00"}
{"level":"info","msg":"read crontab: /crontab","time":"2025-01-28T20:34:44+01:00"}
{"level":"info","msg":"crontab is valid","time":"2025-01-28T20:34:44+01:00"}

And it appears that when using -split-logs flag, the output is formatted using logfmt. But this seems like a side effect.

root@container:/var/www# /usr/local/bin/supercronic -split-logs -test /crontab 
time="2025-01-28T20:34:47+01:00" level=warning msg="process reaping disabled, not pid 1"
time="2025-01-28T20:34:47+01:00" level=info msg="read crontab: /crontab"
time="2025-01-28T20:34:47+01:00" level=info msg="crontab is valid"

jannst avatar Jan 28 '25 19:01 jannst

A number of messages have asked about logging from supercronic. I see the example in the README.md file. What I have not seen is an example on how to leverage the output to produce a log file within a working docker container. I'm having to build/rebuild/test my docker image trying different combinations of configuration costing me huge amounts of time.

I have gotten supercronic to launch and capture the -debug messages. But at the expense of many hours when a clear example would have been a time saver.

The other thing I would like to see is clear step-by-step instructions to compile supercronic from scratch. Current availability of supercronic is flagged by Docker Hub as having old libraries which have severe vulnerabilities in the'golang' libraries. BY compiling from scratch, I can insure the latest golang libraries are used to eliminate the vulnerabilities.

tkocou avatar Jul 21 '25 22:07 tkocou