Reputation: 1
I want to execute MQL (metric query language) to get sum of all values from "metric.size" column which have the same "metric.id".
It should be grouped by id, and size column to be the sum of all the size values for matching id, and this within a certain time range.
In SQL it would look something like below: select id, sum(size) from "metric" group by id where ts is bigger X & less than Y
I have tried many variation of the below command; using within, every, window with no luck.
fetch k8s_container | metric 'logging.googleapis.com/user/ingestion-info' | group_by [metric.tenantId], sum(metric.size) | every 13h
Any help would be greatly appreciated. Thank you.
Also i have tried solutions in the below links: Unable to collect data from metric query language MQL - GCP GCP MQL query: getting metrics/minute
Upvotes: 0
Views: 3298
Reputation: 91
I think you need to turn the column you want to aggregate into a value
column. metric
and resource
columns are used in the first argument of group_by
operation.
fetch k8s_container
| metric 'logging.googleapis.com/user/ingestion-info'
| value [value.size: metric.size]
| group_by [metric.tenantId], sum(value.size)
| every 13h
BTW, looks like there is no value exported in your table. If the metric.size
is the info you want to monitor, I recommend you define it as the value of the metric. logging.googleapis.com/user/ingestion_size
or logging.googleapis.com/user/ingestion-info/size
might be more readable as a metric name.
Upvotes: 2