exporter-toolkit icon indicating copy to clipboard operation
exporter-toolkit copied to clipboard

Users: Log unauthorized requests

Open networkException opened this issue 4 years ago • 10 comments

This patch adds a new configuration option to the web.config.file which makes it possible to enable logging of unauthorized requests.

If "log_unauthorized" at config file's top level is set to true, any unauthorized request will have the ip as well as the X-Forwarded-For header logged. This way, a program that might parse the logs can determent for itself if the X-Forwarded-For header can be trusted.

networkException avatar Sep 07 '21 13:09 networkException

Seems like a good idea to me.

SuperQ avatar Sep 07 '21 14:09 SuperQ

Can we log to a file? We might also log successful queries, with usernames?

roidelapluie avatar Sep 07 '21 15:09 roidelapluie

I think logging to a file is a bit out of scope of this pr, usually there's always a way to pipe the output somewhere. If people want it I can also implement logging on success

networkException avatar Sep 07 '21 15:09 networkException

We should not mix the two streams together (application / access logs). it is separate things.

roidelapluie avatar Sep 07 '21 15:09 roidelapluie

prometheus also uses json for logging the queries.

roidelapluie avatar Sep 07 '21 16:09 roidelapluie

I have rewritten the implementation to output to a json file

networkException avatar Sep 11 '21 13:09 networkException

I would prefer to avoid multiple log streams. The fact that Prometheus logs queries to a separate file is an anti-pattern for operations.

We separate logging types in our tools like ELK and Loki.

SuperQ avatar Sep 11 '21 13:09 SuperQ

For my usecase it doesn't matter, I'd just like to have some way of outputting failed requests. I'm not able to decide what design would be best for the project but I'll happily implement a different one if that gets agreed on.

networkException avatar Sep 11 '21 14:09 networkException

@networkException Yea, let me have a discussion with @roidelapluie about this policy. I really want to avoid a proliferation of log files in the Prometheus ecosystem. It makes dealing with deployments a lot more work.

SuperQ avatar Sep 11 '21 15:09 SuperQ

You can put /dev/stdout if you don't want a log file

roidelapluie avatar Sep 11 '21 15:09 roidelapluie