Hello,
I have two queries. One is counting the number of pods with specific label from K8s datasource and the other one is displaying a gauge from application datasource.
they both have namespace as a common value
sum(metric1{}) by (kubernetes_namespace)
count(kube_pod_container_resource_limits{container=~“container_name.*”,resource=“cpu”}) by ( namespace)
I want the table to look like
namespace number_of_pods metric_1
X Y Z
Note: I was able to get the format by using the following transformations.
- Time series to table
- Concatenate fields
- Group by
- kubernetes_namespace Group_by
- namespace Ignored
- Trend A calculate last
- Trend B calculate last
The problem is that I want to export this table as CSV and the cell type Sparkline is not being exported. I want to have the display as a normal table.
Thank you
You can swap the first transformation to Reduce transformation (Series to Rows, calculation Last) and it should also work.
I have tried “Reduce” calculation. This creates a table with 2 columns. Column A is named fields and combines namespace and kubernetes namespace and one column for value.
If I select “Labels to fields” it splits the namespace into two columns.
The thing that “Time series to tables” did easily is distinguish the value of each query as differenet trend A and B.
I have tried “Reduce” calculation. This creates a table with 2 columns. Column A is named fields and combines namespace and kubernetes namespace and one column for value.
If I select “Labels to fields” it splits the namespace into two columns.
The thing that “Time series to tables” did easily is distinguish the value of each query as differenet trend A and B
Ok, Reduce
won’t work in that case, sorry If what you need is the last value, you can achieve that simpler.
While executing your queries, you can change the query format to Table
and Type to Instant
With that, you’ll have two tables with fields Time
, namespace
/ kubernetes_namespace
, and Value #A
/ Value #B
(depending on the table). What you’ll need to do is use Concatenate fields
transformation (that you’ve already used) to obtain a single table with all the fields. I think you can also replace Group by
transformation with Organize by fields
transformation.
Please notice, that this will only work if you need last value (instant query will take only the last data point), so if you need something like Max
or Mean
it won’t work (unless you do that in query editor with max_over_time
or avg_over_time
functions).
Let me know if that’s what you were looking for
Thanks. That provided what I needed!
1 Like