We have our web api service running in OpenShift for the past few months
When we deployed this to OpenShift, initially we have given basic request and limits for memory and CPU.
Sometime when the resource limit crossed its threshold we had to increase the limit
We have several services deployed and we have given some random request and limits for the Pod. we are trying to figure out a way to provide resource limits and request based on the past few months that it is running on OpenShift
My idea is to look at the last few months on requests what is POD is receiving and come up with a value to requests and limits
I am thinking PROMQL can help me to provide this value, can someone help me with a query to determine average resource and limits based on past 4 to 5 weeks of requests on the POD ?
CodePudding user response:
Try the below queries which are helpful in your case :
avg (
avg_over_time(container_cpu_usage_seconds_total:rate5m[30d])
) by (pod_name)
The above query is used to determine the average CPU usage of a certain pod for the past 30 days.
avg (
avg_over_time(container_memory_usage_seconds_total:rate5m[30d])
) by (pod_name)
The above query is used to determine the average memory usage of a certain pod for the past 30 days.
In the query avg is used to calculate the average of the sample values in the input series, grouped by their [pod_name]
. avg_over_time
is used for getting the average value of all points in the specified interval, we can get the metrics like cpu and memory usage for the specified interval by using the respective queries.
For more info follow this doc.