nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.37k stars 323 forks source link

Nginx unit daemon json logs #1014

Open devel96 opened 10 months ago

devel96 commented 10 months ago

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

tippexs commented 10 months ago

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?

devel96 commented 10 months ago

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 ?

tippexs commented 10 months ago

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.

Neks3s commented 2 weeks ago

any update on that? we are on 1.33 already

callahad commented 1 week ago

We'll do planning for 1.34 this week; expect an update then :)

callahad commented 4 days ago

We'll have JSON formatted logging in 1.34, targeting release in January 2025.

@Neks3s As someone looking for this feature, are there any particular constraints / preferences / structures / designs that you'd hope we follow, beyond just "same info but JSON?" :)