oliver006 / redis_exporter

Prometheus Exporter for ValKey & Redis Metrics. Supports ValKey and Redis 2.x, 3.x, 4.x, 5.x, 6.x, and 7.x
https://github.com/oliver006/redis_exporter
MIT License
3.04k stars 860 forks source link

include user info in redis_connected_clients_details #776

Closed misTrasteos closed 1 year ago

misTrasteos commented 1 year ago

Related to issue #775, redis_connected_clients_details don't show user info.

This is still a WIP as there are no test yet. But it tries to follow comment

Please let me know if this approach and code changes are likely to be merged, and I will finish it. Otherwise feel free to reject it.

parseClientListString now returns a map containing the parsed output of the client list reply extractConnectedClientMetrics now creates the metric description. Instead during startup at exporter.go

Maybe this is not somehow very efficient as they are created at every scrape.

oliver006 commented 1 year ago

Check the tests: https://drone-github.21zoo.com/oliver006/redis_exporter/66

They're failing: vet: exporter/clients_test.go:95:23: cannot range over lbls (variable of type *ClientInfo)

I think in the tests you can just replace expectedLbls with the ClientInfo that matches the expected return from the parseClientListString() function

oliver006 commented 1 year ago

Have a look at the tests, there are still errors: https://drone-github.21zoo.com/oliver006/redis_exporter/76/1/16

=== RUN   TestParseClientListString

    clients_test.go:105: TestParseClientListString( id=11 addr=127.0.0.1:63508 fd=8 name= age=6321 idle=6320 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=setex ) error. Given: &{  1678807654 1678807655 N 0 0 setex 127.0.0.1 63508 } Wanted: {  1678807654 1678807655 N 0 0 setex 127.0.0.1 63508 }

    clients_test.go:105: TestParseClientListString( id=14 addr=127.0.0.1:64958 fd=9 name=foo age=5 idle=0 flags=N db=1 sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=32742 obl=0 oll=0 omem=0 events=r cmd=client ) error. Given: &{foo  1678813970 1678813975 N 1 0 client 127.0.0.1 64958 } Wanted: {foo  1678813970 1678813975 N 1 0 client 127.0.0.1 64958 }

    clients_test.go:105: TestParseClientListString( id=14 addr=127.0.0.1:64959 fd=9 name= age=5 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=26 qbuf-free=32742 obl=0 oll=0 omem=0 events=r cmd=client user=default resp=3 ) error. Given: &{ default 1678813970 1678813975 N 0 0 client 127.0.0.1 64959 3} Wanted: { default 1678813970 1678813975 N 0 0 client 127.0.0.1 64959 3}

--- FAIL: TestParseClientListString (0.00s)
coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 85


Changes Missing Coverage Covered Lines Changed/Added Lines %
exporter/clients.go 53 55 96.36%
<!-- Total: 53 55 96.36% -->
Totals Coverage Status
Change from base Build 63: 0.06%
Covered Lines: 1899
Relevant Lines: 2052

💛 - Coveralls
misTrasteos commented 1 year ago

I think everything should be OK by now. I had some problems running the tests.

Any feedback is really welcome, thanks !