Reputation: 4013
I have a simple Google Cloud Monitoring Query Language to show the count of all requests to all containers in kubernetes from log-based metrics. The query is below.
k8s_container::logging.googleapis.com/user/service-api-gateway-prod-request-in-count | sum
The widget will look like below
I would like to rename the long label for the line chart to something shorter like "request count". How do I do it?
Upvotes: 4
Views: 3097
Reputation: 91
The sum
is actually a shortcut to group_by
table operation with sum
aggregator. Using the complete form of group_by
allow you to control the output value column name.
k8s_container::logging.googleapis.com/user/service-api-gateway-prod-request-in-count
| group_by [], [request_count: sum(val())]
Upvotes: 1
Reputation: 98
You can try renaming the value column with | value [request_count: val()]
.
Reference entry for the value operator
Upvotes: 1
Reputation: 4013
So the best I can do is to add a new column to the table and map the column.
In my example, I add add [p: 'error count'] | map [p]
to the line, and become like this.
k8s_container::logging.googleapis.com/user/service-api-gateway-prod-request-in-count | sum | add [p: 'error count'] | map [p]
This works in my case.
Upvotes: 7
Reputation: 298
Instead of using MQL(Monitoring Query Language), try the Advanced tab. Just for an example I will be using a metric name mysite-container-exited, you can name it whatever you want.
Upvotes: 0