This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-08
Channels
- # adventofcode (9)
- # announcements (5)
- # babashka (3)
- # beginners (46)
- # calva (21)
- # cider (15)
- # clj-kondo (20)
- # cljs-dev (57)
- # cljsrn (10)
- # clojure (147)
- # clojure-dev (6)
- # clojure-europe (3)
- # clojure-france (2)
- # clojure-italy (8)
- # clojure-nl (18)
- # clojure-norway (5)
- # clojure-spec (16)
- # clojure-uk (63)
- # clojuredesign-podcast (7)
- # clojurescript (65)
- # clojurex (42)
- # cursive (12)
- # datomic (10)
- # fulcro (47)
- # graalvm (102)
- # graphql (2)
- # jobs (5)
- # joker (12)
- # off-topic (33)
- # pedestal (6)
- # re-frame (6)
- # reagent (8)
- # reitit (6)
- # remote-jobs (4)
- # rewrite-clj (10)
- # shadow-cljs (86)
- # sql (45)
- # testing (4)
- # tools-deps (43)
- # vim (8)
- # xtdb (3)
I'm running Pedestal under Elastic Beanstalk. Is there a way to configure the Logback logger to emit CloudWatch-friendly JSON?
I've found this: https://github.com/osiegmar/logback-awslogs-json-encoder which seems to be what I want but I'm not certain if that's the level of abstraction I should be using.
I'd also like to enhance the logs with various other stuff (e.g. Host, user-id, etc etc)
I saw that I can do something like :io.pedestal.log/formatter cheshire/encode
when calling io.pedestal.log/log
, and cloudwatch is smart enough to pick that JSON up
But not in insights, sigh. Perhaps it's better if the whole log is JSON (as opposed to prefixed by other logback things)
@orestis I’ve not used the logback-awslogs-json-encoder lib but if you do produce JSON formatted logs and use io.pedestal.log/log
with a JSON formatter, then your log message will be a string albeit in JSON format. You could parse that string in CloudWatch Insights using the parse
function it provides in order to create virtual fields which can be filtered on. That being said, info like Host, user-id seems better suited for MDC usage. You can use Pedestal’s io.pedestal.log/with-context
impl to set a map of data in the MDC but it will be a single value under the io.pedestal
key. You could format as JSON and parse as I described above, though. Alternatively, you can use the MDC directly. All values put into the MDC become separate fields prefixed by mdc
in Insights which makes log analysis easy.