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.03k stars 859 forks source link

Ingesting keys with slashes into prometheus #850

Closed WimDeMeester closed 2 months ago

WimDeMeester commented 7 months ago

Describe the problem I'm trying to include a lot of keys which have a name like

/elt/telif/target/coord/velocity_offset_radec

I try to add all the keys using the following command:

redis_exporter --redis.addr=127.0.0.1:6379 --check-keys /elt*

In the output, I can see that all the keys are found:

redis_key_size{db="db0",key="/elt/telif/target/coord/proper_motion_radec"} 39
redis_key_size{db="db0",key="/elt/telif/target/coord/radvel"} 31
redis_key_size{db="db0",key="/elt/telif/target/coord/rshift"} 31

However, I don't see the real values added. So no redis_key_value or redis_key_value_as_string can be seen in the stdout when starting up redis_exporter.

What version of redis_exporter are you running? Please run redis_exporter --version if you're not sure what version you're running. [ ] 0.3x.x [x] 1.x.x

Running the exporter What's the full command you're using to run the exporter? (please remove passwords and other sensitive data)

redis_exporter --redis.addr=127.0.0.1:6379 --check-keys /elt*

Expected behavior What metrics are missing? What metrics are wrong? Is something missing that was present in an earlier version? Did you upgrade from 0.3x.x to 1.0 and are scraping multiple hosts? Have a look here how the configuration changed.

I expect to have all the values for keys which look like /elt/telif/target/coord/velocity_offset_radec.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

oliver006 commented 7 months ago

Not sure why the values don't get picked up. Could you try with the --debug flag?

WimDeMeester commented 7 months ago

I get the following messages:

DEBU[0416] c.Do() - running command: SELECT [0]         
DEBU[0416] c.Do() - done                                
DEBU[0416] c.Do() - running command: TYPE [/elt/met/fcs/devices/wcu-ccdm/lcs/axis_enable] 
DEBU[0416] c.Do() - done                                
DEBU[0416] c.Do() - running command: PFCOUNT [/elt/met/fcs/devices/wcu-ccdm/lcs/axis_enable] 
DEBU[0416] c.Do() - err: WRONGTYPE Key is not a valid HyperLogLog string value. 
DEBU[0416] c.Do() - done                                
DEBU[0416] c.Do() - running command: STRLEN [/elt/met/fcs/devices/wcu-ccdm/lcs/axis_enable] 
DEBU[0416] c.Do() - done                                
DEBU[0416] c.Do() - running command: GET [/elt/met/fcs/devices/wcu-ccdm/lcs/axis_enable] 
DEBU[0416] c.Do() - done                                
DEBU[0416] registerConstMetric( key_value_as_string , 1.00) err: label value "\x9fV%\xf2\xfe\u0097\x17\x00\x00\n\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00" is not valid UTF-8 
oliver006 commented 7 months ago

Interesting, let me try if I can reproduce this locally.

WimDeMeester commented 7 months ago

I had a new look into the problem and it seems that the format of the redis database was also changed. Instead of normal values, they are now writing objects in the database, so I now get

"\x15\x91V\xcbOm\x98\x17\x00\x00\t\x00\x00\x00\x00\b\x00\x00\x00\x00\x00\x00\x00\xdb\xbb\\x\n\xc0b@"

and no longer

0.000463

as value. So I will need to write my own script to put everything in the prometheus database...

I guess this issue can be closed...

oliver006 commented 2 months ago

I just tried this (I know, it's been a LONG time) but couldn't reproduce this.

In Redis I set a key like this:

set /elt/telif/target/coord/sup 0.000463

and then ran

go run . --debug --redis.addr=127.0.0.1:16384 --check-keys "/elt*"

and in the metrics I get:

# HELP redis_key_size The length or size of "key"
# TYPE redis_key_size gauge
redis_key_size{db="db0",key="/elt/telif/target/coord/sup"} 8
redis_key_size{db="db0",key="/elt/telif/target/coord/velocity_offset_radec"} 2
# HELP redis_key_value The value of "key"
# TYPE redis_key_value gauge
redis_key_value{db="db0",key="/elt/telif/target/coord/sup"} 0.000463

I tried this with redis:7.0 and the current version of the redis_exporter.

I'm going to close this but feel free to re-open if you think there is still something wrong