# Kibana Visualization of Pipeline Aggregation

**URL:** <https://discuss.elastic.co/t/kibana-visualization-of-pipeline-aggregation/241690>\
**Category:** Kibana\
**Created:** [July 17, 2020, 3:52pm UTC](https://discuss.elastic.co/t/kibana-visualization-of-pipeline-aggregation/241690 "2020-07-17T15:52:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![krenaut](https://avatars.discourse-cdn.com/v4/letter/k/f07891/32.png) [@krenaut](https://discuss.elastic.co/u/krenaut)\
**Post date:** [July 17, 2020, 3:52pm UTC](https://discuss.elastic.co/t/kibana-visualization-of-pipeline-aggregation/241690/1 "2020-07-17T15:52:16Z")

</div>

After much pain I was able to create the pipeline aggregation below in the console. But, I can't figure out how I am supposed to get it into a visualization. I just want to create a guage to display the "availabile\_percent"

```auto
POST /app-health/_search
{
  "aggs": {
    "availability_pct": {
      "terms": {
        "field": "entityId.keyword",
        "size": 10
      },
      "aggs": {
        "success_count": {
          "sum": {
            "script": {
              "source": "if (doc['availability.keyword'].size()>0) { if (doc['availability.keyword'].value == 'AVAILABLE') { return 1; } } return 0;"
            }
          }
        },
        "total_count": {
          "value_count": {
            "script": {
              "source": "return 0;"
            }
          }
        },
        "available_percent": {
          "bucket_script": {
            "buckets_path": {
              "success": "success_count",
              "total": "total_count"
            },
            "script": "params.success / params.total * 100"
          }
        }
      }
    }
  }
}

```

---

<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:** [July 17, 2020, 4:17pm UTC](https://discuss.elastic.co/t/kibana-visualization-of-pipeline-aggregation/241690/2 "2020-07-17T16:17:50Z")

</div>

You have two options. One is to try to recreate this query using one of the tools in Kibana, most likely by using TSVB. For example, the TSVB filter ratio function could work:

Numerator: `availability.keyword: AVAILABLE`  
Denominator: `availability.keyword: *`

The most direct way of doing this is to use Vega. It's the only way to use the full Elasticsearch DSL in Kibana. You can follow my new tutorial for your first Vega visualization, which I wrote for the upcoming 7.9 version, but that is pretty close to existing versions: [https://www.elastic.co/guide/en/kibana/7.9/vega-graph.html](https://www.elastic.co/guide/en/kibana/7.9/vega-graph.html)

---

<div class="post-metadata">

**Author:** ![krenaut](https://avatars.discourse-cdn.com/v4/letter/k/f07891/32.png) [@krenaut](https://discuss.elastic.co/u/krenaut)\
**Post date:** [July 17, 2020, 6:13pm UTC](https://discuss.elastic.co/t/kibana-visualization-of-pipeline-aggregation/241690/3 "2020-07-17T18:13:50Z")

</div>

Thanks Wylie, I was able to get this working with one potential problem. I only got the expected results if my selected timeframe equals the interval:

Timeframe: last 24 hours  
Interval: 24h

Does anybody know if there is a way to set your interval equal to the timeframe?

---

<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:** [August 14, 2020, 6:13pm UTC](https://discuss.elastic.co/t/kibana-visualization-of-pipeline-aggregation/241690/4 "2020-08-14T18:13:50Z")

</div>

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