Comments (5)
Hi @WDaan,
Thanks for your issue.
For now there is nothing else to access service name.
What is the issue with the current log/access log implementation?
Why do you want to create a plugin for that?
Could you please explain a bit more your use case?
from traefik.
I want to run Traefik in a microservice architecture, all requests will flow through Traefik.
Instead of having all microservices implement their own logger middleware, I'd like to remove that responsibility from them and move it to a Traefik plugin.
The plugin would parse usefull information from the request, obfuscate headers where needed and log the result so it can be picked up by our logging setup.
On key part of usefull information would be the service the request would get routed to.
(Same for tracking custom metrics)
Does that clarify it enough?
from traefik.
Hi @mmatur
Any further comment?
Thanks
from traefik.
Hi @WDaan,
Why are not using the current access log filtering available in Traefik?
You can use json format and you will have a bunch of field available and the one you are looking for is ServiceName
![image](https://private-user-images.githubusercontent.com/1776972/313135760-6683e07d-2a8a-4a46-a10c-0b3657c11d80.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTQwODU5MDUsIm5iZiI6MTcxNDA4NTYwNSwicGF0aCI6Ii8xNzc2OTcyLzMxMzEzNTc2MC02NjgzZTA3ZC0yYThhLTRhNDYtYTEwYy0wYjM2NTdjMTFkODAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDQyNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA0MjVUMjI1MzI1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YWQ3NmI3OTMyNGZlOTRmNWZlMjIyNTE0OGQxOTVhNzM2Njk5NTRjMDlhMmIzNmYzNjI2MDQ0YWQzM2MzYjdhZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.-RpJs2hAOkDOxYLKH4Efc-WLY-S7lWwXr72eU64cSn4)
from traefik.
Hi @mmatur, thanks for your reply 😄
TLDR; it's great but just not flexible enough. Traefik v3 breaks the above mentioned 'service'-hack
- Can't make fields 'top level'
- x-amzn-trace-id => I want this to be a top level field, because downstream services include this in their log messages and during debugging you can easily filter on this field
- user_id,org_id => Same reason, currently I extract those from the JWT (I can probably set them as headers in the forward-auth middleware, but still cannot get them top level)
- Custom log level => I set a log level based on status code or some other factor, so I can dashboard/report on that
- Custom log format => our Fluentbit setup drops messages that do not adhere to certain rules. So I'd either have to make an exception for Traefik (which would break some dashboards) or massage/reformat it on Fluentbit side to support our format
- No servicename remapping => I remap the service name from
namespace-my-service-80@kubernetes
tomy-service
, so I can see all log messages (app + requests) with the same filter e.g.service=my-service
- No Path/Query Param extraction =>
api/organizations/392dcb9d-d855-4447-97bc-3255eab8e37a/?test=1234
gets remapped toapi/organizations/:org
as path and the params get logged as a separate JSON top level fieldsparams
andquery
. We use this for debugging and dashboarding/analytics use-cases
It was great to be able to use a Traefik middleware to generate this, instead of relying on all downstream dev teams to implement the standard properly in various languages. The middleware removes that pain point altogether.
Similar issues for metrics; the current metrics do not include a 'cleaned' path label (or any path label). We use this label so we can split our SLO's based on paths we expect to be fast/slow. Or on other labels that can be set from within the middleware. We currently export metrics ourselves because the default provided ones are not extensive enough and other labels can only be added from headers. On of the labels we set is the remapped service name.
Now with Traefik v3, this setup is broken because the 'service' field is no longer exists on the http.Handler
I tried to extract the LogData
from the context like the accesslog
-middleware does it but was unable get anything.
func GetLogData(req *http.Request) *LogData {
if ld, ok := req.Context().Value(DataTableKey).(*LogData); ok {
return ld
}
return nil
}
Is there any other way of getting access to the service name from within a middleware?
Thanks for your input 😄
from traefik.
Related Issues (20)
- Latest is still 2.11.1 HOT 3
- v2.11.2 migration guide possibly incomplete HOT 1
- TCP+TLS connection kill in v3.0.0 HOT 18
- Does settings a readTimeout to 0 still protect us against CVE-2024-28869? HOT 5
- Provider icon size is not consistant with the other dashboard icons HOT 1
- Websocket ping/pong timeout not working HOT 5
- Display conflicting configuration in dashboard as failed routes HOT 2
- /metrics sometimes return "has a label named 'service' whose value is not utf8" HOT 3
- Gitlab desktop client connect not found HOT 1
- Switch to Kubernetes EndpointSlices API HOT 2
- Fix UI unit tests HOT 1
- Traefik should prompt for MTLs client certificates in the browser HOT 9
- Enable STARTTLS for origin Postgres server in TLSRoute of Kubernetes Gateway API HOT 2
- Activate tracing by routers HOT 2
- Timeout (499 Client Closed Request) issue introduced with v2.11.2 (working correctly with all previous versions) HOT 1
- grpc bi directional streaming - READTIMEOUT HOT 1
- Middlewares: IpAllowList doesn't work with localhost HOT 1
- upload file > 2G Fail with traefik 2.11 HOT 4
- Traefik does not attach itself to provided docker networks.
- Run Traefik as windows native service
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from traefik.