# Show different Metrics in one Visualization

**URL:** https://discuss.elastic.co/t/show-different-metrics-in-one-visualization/260226
**Category:** Kibana
**Created:** [January 5, 2021, 3:27pm UTC](https://discuss.elastic.co/t/show-different-metrics-in-one-visualization/260226 "2021-01-05T15:27:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![grra](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@grra](https://discuss.elastic.co/u/grra)
#### Post date: [January 5, 2021, 3:27pm UTC](https://discuss.elastic.co/t/show-different-metrics-in-one-visualization/260226/1 "2021-01-05T15:27:30Z")

</div>

Hi,

in my document I have a JSON `metrics` field like that:

```auto
{
  "task": "task1",
  "size": 2048
},
{
  "task": "task2",
  "size": 1000
}

```

As Buckets I have another field called `number` (lets say `number: 1, 2`)

A field `number` can have different `tasks` with a corresponding `size`.

Is it possible to Display that in one Visualization? I can not figure out the correct Metrics Aggregation for that.

I have already set the buckets correctly by `metrics.task.keyword`, but in the moment I am using the `max` Aggregation, which returns me just the highest `size` in the document.  
What I actually need is the `size` for the `task` in the correct JSON block.

Thanks in advance.

---

<div class="post-metadata">

### Author: ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)
#### Post date: [January 5, 2021, 3:37pm UTC](https://discuss.elastic.co/t/show-different-metrics-in-one-visualization/260226/2 "2021-01-05T15:37:39Z")

</div>

Are you saying that your documents contain an array of tasks, such as:

```auto
{
  number: 1
  tasks: [{ ... }, { ... }]
}

```

If so, then you can't build this visualization using the standard tools in Kibana- it is only possible to build using Vega. This is because [array types are not supported in Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html), and Kibana built-in tools don't support the `nested` mapping which would otherwise be a good workaround.

So you have two options here:

1. Change the way your documents are organized. Instead of having an array of tasks, create a separate document for each task- this can be visualized.
2. [Use Vega](https://www.elastic.co/guide/en/kibana/current/vega-lite-tutorial-create-your-first-visualizations.html), which is fully custom

---

<div class="post-metadata">

### Author: ![grra](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@grra](https://discuss.elastic.co/u/grra)
#### Post date: [January 5, 2021, 3:52pm UTC](https://discuss.elastic.co/t/show-different-metrics-in-one-visualization/260226/3 "2021-01-05T15:52:37Z")

</div>

Thanks for quick reply!

I have not an array of tasks, but something like this.

```auto
{
  "task": "task_1",
  "percent": 20,
  "size": 2048,
  "used": 604
},
{
  "task": "task2",
  "percent": 10,
  "size": 200,
  "used": 212
},
{
  "task": "task3",
  "percent": 6.8,
  "size": 4050,
  "used": 140
},
.....

```

This is how my `metrics` field looks like.  
Is it even like that not possible? (Without Vega) 🙂

---

<div class="post-metadata">

### Author: ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)
#### Post date: [January 5, 2021, 3:55pm UTC](https://discuss.elastic.co/t/show-different-metrics-in-one-visualization/260226/4 "2021-01-05T15:55:55Z")

</div>

Is each task a separate document? And what type of visualization would you want?

---

<div class="post-metadata">

### Author: ![grra](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@grra](https://discuss.elastic.co/u/grra)
#### Post date: [January 5, 2021, 4:14pm UTC](https://discuss.elastic.co/t/show-different-metrics-in-one-visualization/260226/5 "2021-01-05T16:14:39Z")

</div>

1. The tasks are collected in one document.
2. I would like to use a line Graph.

Above I just copied the fields ( `metrics` ) values (in JSON format)

---

<div class="post-metadata">

### Author: ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)
#### Post date: [January 5, 2021, 4:15pm UTC](https://discuss.elastic.co/t/show-different-metrics-in-one-visualization/260226/6 "2021-01-05T16:15:51Z")

</div>

Okay, so if they are collected in a single document then you must use Vega. If you split these tasks into separate documents, you could build this visualization using any of the line charts in Kibana.

---

<div class="post-metadata">

### Author: ![grra](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@grra](https://discuss.elastic.co/u/grra)
#### Post date: [January 5, 2021, 4:19pm UTC](https://discuss.elastic.co/t/show-different-metrics-in-one-visualization/260226/7 "2021-01-05T16:19:56Z")

</div>

Okay great, thanks for help 🙏

---

<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: [February 2, 2021, 4:20pm UTC](https://discuss.elastic.co/t/show-different-metrics-in-one-visualization/260226/8 "2021-02-02T16:20:03Z")

</div>

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