# Suggestions for visualizing complex query - Kubernetes cpu requested vs available

**URL:** https://discuss.elastic.co/t/suggestions-for-visualizing-complex-query-kubernetes-cpu-requested-vs-available/223416
**Category:** Kibana
**Created:** [March 12, 2020, 8:58pm UTC](https://discuss.elastic.co/t/suggestions-for-visualizing-complex-query-kubernetes-cpu-requested-vs-available/223416 "2020-03-12T20:58:47Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Babadofar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/babadofar/32/44803_2.png) [@Babadofar](https://discuss.elastic.co/u/Babadofar)
#### Post date: [March 12, 2020, 8:58pm UTC](https://discuss.elastic.co/t/suggestions-for-visualizing-complex-query-kubernetes-cpu-requested-vs-available/223416/1 "2020-03-12T20:58:48Z")

</div>

Hi people,  
I'm using metricbeat to gather Kubernetes metrics, and I'm trying to find ways to create the visualizations and insight we need. One metric we need is to know the total amount of cpu which our applications request, compared to the amount of cpu available. I have created an elasticsearch query, but I'm having a hard time figuring out how to visualize it. Any help appreciated. Find the query here: [https://gist.github.com/babadofar/a960cbab8fe7ac235c4c8931b2da6e18](https://gist.github.com/babadofar/a960cbab8fe7ac235c4c8931b2da6e18)

---

<div class="post-metadata">

### Author: ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)
#### Post date: [March 13, 2020, 12:52am UTC](https://discuss.elastic.co/t/suggestions-for-visualizing-complex-query-kubernetes-cpu-requested-vs-available/223416/2 "2020-03-13T00:52:05Z")

</div>

A TSVB visualization with Math aggregation should pretty cover the case.  
Something like in this post:

> [@Percentages per day (per bucket) possible?](https://discuss.elastic.co/t/percentages-per-day-per-bucket-possible/208138/2):
>
> You can try with TSVB and the Math aggregation. Then you should be able to calculate the percentage of spam as "100 \* sum(spam)/sum(total\_volume)". Basically create 2 sum metrics, one for spam, one for total\_volume. Then create a math aggregation with the equivalent of the formula that I added above, and then keep just this line visible on the chart. PS: don't forget to keep the bucket size to 1d.

---

<div class="post-metadata">

### Author: ![Babadofar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/babadofar/32/44803_2.png) [@Babadofar](https://discuss.elastic.co/u/Babadofar)
#### Post date: [March 13, 2020, 8:11am UTC](https://discuss.elastic.co/t/suggestions-for-visualizing-complex-query-kubernetes-cpu-requested-vs-available/223416/3 "2020-03-13T08:11:40Z")

</div>

I need to aggregate on the node.name to get the cpu available, and on the pod.name to get the cpu requested. Which means I need to create two different series, since the TSVB only allows one level of terms aggregation(?). Is it possible to calculate with data from two different series in a script?

---

<div class="post-metadata">

### Author: ![Babadofar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/babadofar/32/44803_2.png) [@Babadofar](https://discuss.elastic.co/u/Babadofar)
#### Post date: [March 13, 2020, 8:31am UTC](https://discuss.elastic.co/t/suggestions-for-visualizing-complex-query-kubernetes-cpu-requested-vs-available/223416/4 "2020-03-13T08:31:33Z")

</div>

this issue? [https://github.com/elastic/kibana/issues/22866](https://github.com/elastic/kibana/issues/22866)

---

<div class="post-metadata">

### Author: ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)
#### Post date: [March 13, 2020, 12:29pm UTC](https://discuss.elastic.co/t/suggestions-for-visualizing-complex-query-kubernetes-cpu-requested-vs-available/223416/5 "2020-03-13T12:29:49Z")

</div>

Yeah, you are going to have multiple charts. one for each node.  
I'd suggest an Input Control Visualization, where you can select the node.name (which will filter to all the data available for that node.name) and then do the calculations in TSVB with just a split by pod.name.

---

<div class="post-metadata">

### Author: ![Babadofar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/babadofar/32/44803_2.png) [@Babadofar](https://discuss.elastic.co/u/Babadofar)
#### Post date: [March 16, 2020, 8:35am UTC](https://discuss.elastic.co/t/suggestions-for-visualizing-complex-query-kubernetes-cpu-requested-vs-available/223416/6 "2020-03-16T08:35:43Z")

</div>

OK that would work somewhat, but ideally, I would like to have unlimited (or more than one at least) nested terms aggregations in TSVB , the ability to inspect queries in TSVB, and of course, if we could have bucket script aggregations in the common Kibana visualizations, that would make it a lot easier.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 13, 2020, 8:35am UTC](https://discuss.elastic.co/t/suggestions-for-visualizing-complex-query-kubernetes-cpu-requested-vs-available/223416/7 "2020-04-13T08:35:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
