BrunoBonacci / mulog

μ/log is a micro-logging library that logs events and data, not words!
https://cljdoc.org/d/com.brunobonacci/mulog/
Apache License 2.0
490 stars 48 forks source link

AWS Cloudwatch logs are not generally "discoverable" #113

Closed cch1 closed 1 year ago

cch1 commented 1 year ago

Based on my experience, the cloudwatch publisher generates JSON logs that are not discoverable when using namespaced keys. This is a serious impediment to to idiomatic Clojure usage and the usefulness of the logs.

I believe the problem stems from the JSON serialization of the keys of logged attributes. A key like :my.qualified/key would be idiomatic in Clojure, but the serialized JSON object appears to be my.qualified/key which is apparently not discovered by Cloudwatch Log insights. Furthermore, the key names are so foreign to Cloudwatch logs that even specifying them (e.g. in a filter) is not possible without special quote-escaping syntax.

Cloudwatch logs should adhere to the "dot notation" convention outlined in this spec in order to facilitate insights, queries and discoverability. I think a reasonable solution would be to aggregate keys of a namespace into a subordinate JSON object:

{"my": {"qualified": {"key": 123}}}

If this approach is deemed too radical, perhaps allowing for a customization of the publisher would be appropriate.

BrunoBonacci commented 1 year ago

Hi Chris,

I use µ/log in conjunction with CloudWatch Insights for many of my projects own projects. I don't personally find the namespaced keywords do be much of an issue. However, there are a number of things you can do to achieve the desired behaviour.

Consider the following:

The objective of µ/log is to capture the data and dispatch it to one or more destinations. However, I tried my best to give the users control over which data is published and, at some extent, in which shape.

I hope this help.

cch1 commented 1 year ago

It does -I should have realized that I can transform the keys as well as filter the events. That will suffice nicely since foregoing namespaced keys is a non-starter for me.