@Brian Candler.,

What Touseef is trying to do is sum all the container CPU and Memory and 
get a counter over a period of time.
For example,  yesterday 5 Pods with 7 containers were spawned. In total, 
the cumulative CPU request and Memory request was 300CPU and 500GB of RAM 
over the last 24h.

This would be useful when you need to calculate the cost for a namespace, 
as you would have the total CPU/uptime usage and add it to a counter that 
you can use for more calculations.

On Thursday, 12 August 2021 at 22:13:38 UTC+3 Brian Candler wrote:

> I'm not sure what you're trying to achieve.  Memory usage is a gauge.  Are 
> you trying to get a usage figure in "megabyte-hours" or somesuch?
> In that case, you can calculate the average memory usage over the period 
> of interest, and then multiply it by the duration of the period.
>
> sum(foo) or average(foo) will give you calculations at a single instant in 
> time, across multiple timeseries.
> average_over_time(foo[range]) will give you calcuations separately across 
> each timeseries, over a given range.
>
> sum_over_time() is almost certainly not what you're looking for, as it 
> will get messed up if any samples in the period are missed.
>
> On Thursday, 12 August 2021 at 11:12:40 UTC+1 [email protected] wrote:
>
>> Hi, I want to calculate the total consumption of memory/cpu usage (with 
>> underlying kubernetes infrastructure) monotonously over a period of 
>> time(lets say 3 months).
>>
>> I tried query like
>>
>> *sum(container_memory_usage_bytes{namespace=~"$namespace",pod=~"$pod"})/1024/1024/1024*
>>
>> I also tried to use the *increase()* and *sum_over_time()* functions to 
>> get the cumulative sum of the total resource consumed.
>> However it doesn’t give me the cumulatively total usage over a selected 
>> duration time.It just gives me sum at that time instant.So the graph 
>> obtained goes up and down based on usage at that time instant.
>>
>>
>> Any suggestion for the alternative function/formulla to achieve a sum 
>> total usage of resource over a selected time would be appreciated.
>>
>> Thanks!
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/ebe42e57-c4f6-4482-8c75-a3efe7084f79n%40googlegroups.com.

Reply via email to