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.14k stars 876 forks source link

How can I get percentage of CPU usage? #366

Closed homi-e closed 4 years ago

homi-e commented 4 years ago

Describe the problem I know there are 2 metrics related to CPU. (cpu_[user|sys]_seconds_total). Is there way to get the CPU utilization in percentiles?

I tried to query through the following query. irate (redis_cpu_sys_seconds_total [1m]) * 100 However, there are times when the maximum value is over 100,

so it does not seem to be the correct query method. How can I query?

What version of redis_exporter are you running? 1.3.5

Screenshots screenshot_20200318

oliver006 commented 4 years ago

Good question. From the redis docs: https://redis.io/commands/info :

    used_cpu_sys: System CPU consumed by the Redis server
    used_cpu_user:User CPU consumed by the Redis server
    used_cpu_sys_children: System CPU consumed by the background processes
    used_cpu_user_children: User CPU consumed by the background processes

these ^^^ redis metrics correspond to the exported metrics

redis_cpu_sys_children_seconds_total
redis_cpu_sys_seconds_total
redis_cpu_user_children_seconds_total
redis_cpu_user_children_seconds_total

The query you posted looks right so it looks like your redis instance uses up to 200% (aka 2 cores) of sys cpu time every so often. Are you doing spikey processing that aligns with the metrics?

homi-e commented 4 years ago

Spike processing is being performed.

By the way, I'm using Redis through AWS on Elasticache, so I compared it to the CPU metrics provided by AWS Cloudwatch, and the graph pattern is similar but the numbers are confusing.

스크린샷 2020-03-19 오전 2 38 25

In my opinion, It should be divided by additional factor. irate (redis_cpu_sys_seconds_total [1m]) * 100 / some_factor

oliver006 commented 4 years ago

Not familiar with what the cloudwatch metrics export but from a quick glance at this page https://aws.amazon.com/elasticache/redis/faqs/ under Q. What is the correct metric to use to measure Redis CPU utilization? it seems like there are (at least) two metrics you could be looking at and it's also not clear if those metrics are on a per-CPU basis (100% == 1 CPU) or on a host basis (100% == all CPUs of the host). How many CPUs does your redis instance have?

homi-e commented 4 years ago

It is up on a 4 core server~~

oliver006 commented 4 years ago

Ok. As I said, I'm not familiar with that those Cloudwatch metrics export exactly so can't really say what or if you need to apply a scaling factor.

homi-e commented 4 years ago

Yes, Thanks. In the future, I will compare the CPU through Redis, which can be self-operated, not SAAS-type Redis, and post here. Thank you for answer.