Skip to content

Configurable Data Plane Log Format #1200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mpstefan opened this issue Oct 25, 2023 · 4 comments
Open

Configurable Data Plane Log Format #1200

mpstefan opened this issue Oct 25, 2023 · 4 comments
Labels
enhancement New feature or request highlight Relates to features that should be promoted despite not being an epic
Milestone

Comments

@mpstefan
Copy link
Member

mpstefan commented Oct 25, 2023

As a user of NGF
I want to have the ability to configure the log format of NGINX's access and error logs
So that I can easily collect logs from NGINX in my logging platform.

Acceptance

  • NGINX's access and error logs' format can be configured during runtime via a CRD as according to NGINX's existing specifications.
@mpstefan mpstefan added the enhancement New feature or request label Oct 25, 2023
@mpstefan mpstefan added this to the v1.3.0 milestone Jan 2, 2024
@mpstefan mpstefan modified the milestones: v1.3.0, v2.0.0 Mar 13, 2024
@mpstefan mpstefan modified the milestones: v1.4.0, v2.3.0, v2.1.0 Jul 24, 2024
@mpstefan mpstefan added the highlight Relates to features that should be promoted despite not being an epic label Dec 18, 2024
@mpstefan mpstefan modified the milestones: v1.6.0, v2.1.0 Dec 18, 2024
@mpstefan mpstefan modified the milestones: v2.1.0, v2.2.0 Jan 16, 2025
@kiyutink
Copy link

Hey, is there a workaround to configure logging right now? e.g. I want to log a specific header for each request, is there a way to achieve this?

@bjee19
Copy link
Contributor

bjee19 commented Apr 29, 2025

Hey @kiyutink, the current workaround to configuring logging would be using SnippetsFilters, which allow you to insert nginx configuration into the configuration that NGF generates. Here's a guide on using them https://docs.nginx.com/nginx-gateway-fabric/how-to/traffic-management/snippets/.

You would then be able to add and configure the nginx directives log_format and access_log to your liking. You should be able to accomplish what you want by using log_format at the http level and access_log at the server level. Here's another guide on configuring logging that I found which might be helpful https://docs.nginx.com/nginx/admin-guide/monitoring/logging/.

Hopefully you can play around with the nginx configuration to get it to work!

@kiyutink
Copy link

Hey @bjee19 , thank you for the detailed reply. Just one thing - is it possible to reference the SnippetsFilter not from a route resource? Ideally, I would like to be able to set one default log format for all routes, without explicitly referencing that format in each HTTPRoute. I understand, that I could set the access_log directive in the server context, for example, but in order to do that I still have to pick one route that will reference the SnippetsFilter.

The best thing I could think of is using a "fake" route that never matches but adds a filter, but perhaps there's something less "hacky"?

@bjee19
Copy link
Contributor

bjee19 commented Apr 29, 2025

@kiyutink Unfortunately it is not currently possible to reference the SnippetsFilter a resource that is not a route.

Ideally in situations like this, we'd have completed the above story hahaha, but since we haven't, SnippetsFilters are the only means to solve this situation and are meant to kind of be a last resort hack job. SnippetsFilters and snippets are designed to be small insertions of configuration into specific areas, so it unfortunately makes sense for it to feel hacky when trying to insert configuration which affects large areas.

Best choice is to either see if that "fake" route works, or just switching the SnippetsFilters between stable routes, which shouldn't be too much of an issue unless you're moving around routes frequently. Sorry that its not the best options, but hopefully once this story gets completed there will be a better option!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request highlight Relates to features that should be promoted despite not being an epic
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants