# Setting tdigest compression for percentile aggregations in visualisations \[Kibana 6.5\]

**URL:** <https://discuss.elastic.co/t/setting-tdigest-compression-for-percentile-aggregations-in-visualisations-kibana-6-5/224661>\
**Category:** Kibana\
**Created:** [March 23, 2020, 11:44am UTC](https://discuss.elastic.co/t/setting-tdigest-compression-for-percentile-aggregations-in-visualisations-kibana-6-5/224661 "2020-03-23T11:44:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![imacpherson](https://avatars.discourse-cdn.com/v4/letter/i/9d8465/32.png) [@imacpherson](https://discuss.elastic.co/u/imacpherson)\
**Post date:** [March 23, 2020, 11:44am UTC](https://discuss.elastic.co/t/setting-tdigest-compression-for-percentile-aggregations-in-visualisations-kibana-6-5/224661/1 "2020-03-23T11:44:16Z")

</div>

Hi there,  
I'm running Kibana 6.5 and I have a data table visualisation where I'm showing the 95th percentile of a field, however the value is too inconsistent due to the approximation calculation for percentiles. I've seen that you can set the compression value for the tdigest approximation algorithm in an Elasticsearch query to improve the accuracy at the cost of more memory usage.

I'm looking to see the following included in the visualisation's query to Elasticsearch:

```auto
{
    "aggs": {
        ...
        "3": {
            "percentiles": {
                "field": "x",
                "tdigest": {
                    "compression": 1000
                },
                "percents": [
                    95
                ],
                "keyed": false
            }
        }
    }
    ...
}
```

On a guess, I tried adding the tdigest setting to the visState JSON for the visualisation in a way that seemed like it would correlate to the desired Elasticsearch query:

```auto
{
    ...
    "aggs": [
        ...
        {
            "id": "3",
            "enabled": true,
            "type": "percentiles",
            "schema": "metric",
            "params": {
                "field": "x",
                "tdigest": {
                    "compression": 1000
                },
                "percents": [
                    95
                ],
                "customLabel": "X Value"
            }
        }
    ]
}
```

However, when I inspected the query it sent to Elastic, the tdigest parameters weren't included.

```auto
{
    "aggs": {
        ...
        "3": {
            "percentiles": {
                "field": "x",
                "percents": [
                    95
                ],
                "keyed": false
            }
        }
    }
    ...
}
```

How can I set the tdigest compression value for a visualisation? Is this even possible to do?

Thanks

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [March 23, 2020, 1:57pm UTC](https://discuss.elastic.co/t/setting-tdigest-compression-for-percentile-aggregations-in-visualisations-kibana-6-5/224661/2 "2020-03-23T13:57:52Z")

</div>

You should be able to put that in the "JSON Input" text area (hidden in the collapsed "Advanced" section):

 ![Screenshot 2020-03-23 at 14.56.27](https://us1.discourse-cdn.com/elastic/original/3X/1/8/1834433e24d035fb9c810f7d8d38a6806fe7ee1b.png)

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [March 23, 2020, 2:07pm UTC](https://discuss.elastic.co/t/setting-tdigest-compression-for-percentile-aggregations-in-visualisations-kibana-6-5/224661/3 "2020-03-23T14:07:40Z")

</div>

Hi @imacpherson

Unfortunately we are no longer maintaining the 6.5 version of Kibana, the last maintained is 6.8.x  
I've checked on 6.8 and using the following in the Advanced JSON configuration it worked correctly:

```auto
{
    "tdigest": {
        "compression": 1000
    }
}

```

---

<div class="post-metadata">

**Author:** ![imacpherson](https://avatars.discourse-cdn.com/v4/letter/i/9d8465/32.png) [@imacpherson](https://discuss.elastic.co/u/imacpherson)\
**Post date:** [March 23, 2020, 5:00pm UTC](https://discuss.elastic.co/t/setting-tdigest-compression-for-percentile-aggregations-in-visualisations-kibana-6-5/224661/4 "2020-03-23T17:00:54Z")

</div>

That's done the trick! Thank you 😃

---

<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 20, 2020, 5:01pm UTC](https://discuss.elastic.co/t/setting-tdigest-compression-for-percentile-aggregations-in-visualisations-kibana-6-5/224661/5 "2020-04-20T17:01:03Z")

</div>

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