unit icon indicating copy to clipboard operation
unit copied to clipboard

Nginx unit daemon json logs

Open devel96 opened this issue 1 year ago • 6 comments

Hello. Is there a way to get json logs instead of these ? image

devel96 avatar Dec 02 '23 11:12 devel96

Hi @devel96 - Thanks for reaching out! Not by using Units defaults features, BUT I am currently working on an instrumentation framework guide. I am thinking about providing an exporter for fluentd and / or Loki? What that be an option for you?

tippexs avatar Dec 02 '23 15:12 tippexs

Hi @devel96 - Thanks for reaching out! Not by using Units defaults features, BUT I am currently working on an instrumentation framework guide. I am thinking about providing an exporter for fluentd and / or Loki? What that be an option for you?

Hi @tippexs , thanks for answer. I am using loki + promtail + container logs. But it's ok for me to switch off unit daemon's stdout logs and use another tool to send it to loki. So is there an option just to switch off all nginx unit daemon's logs ?

devel96 avatar Dec 03 '23 12:12 devel96

I would suggest configuring UNIT's log to point to a different location then the deault one as this will symlinked to stdout per default. See https://github.com/nginx/unit/blob/846a7f483643a00322f81a7848ca556722e5469a/pkg/docker/template.Dockerfile#L80C1-L80C44

Instead of building everyting new I would suggest using fluentd filter. https://docs.fluentd.org/filter/parser

This will let you scrape the output log of Unit and transformes it into JSON BEFORE it sends the data to the logging backend. These use cases are the things I would like to put in our Logs reference architecture. We will add more about this in 1.33 release.

tippexs avatar Dec 06 '23 15:12 tippexs