Closed 2ge closed 1 year ago
Sure you can do anything, as long as you can code it in Lua. That is not something this library should do, as you can already do it in your configuration. You'll need something like
~~ initialization
requests = prometheus:counter("requests_total", "Request counts", {"endpoint", "ua_name", "ua_version"})
~~ logging
local user_agent = ngx.re.match(ngx.var.http_user_agent, "(.*?)[\s_\/]+[v]?(\d+(?:[\.\d\-]|deve?l?|alpha|beta|pre|rc|ga|rtm)*)", "i")
requests:inc(1, {ngx.var.uri, user_agent[1], user_agent[2]})
DISCLAIMER: I did not test the code, netiher your regex. Just put it together from some examples and documentation, so it might contain syntactical or other errors. But the general idea should be clear, I hope.
thank you a lot! this is very helpful.
Thanks @dolik-rce for providing a response here.
Thanks for nice exporter. It would be possible to add exporting HTTP User-Agent ?
In grafana I would like to have pie chart with User-Agents with versions and without versions - I got nice regexp for parsing :)
Thanks for consideration