# Defining ranges but NOT one at a time

**URL:** <https://discuss.elastic.co/t/defining-ranges-but-not-one-at-a-time/326573>\
**Category:** Kibana\
**Created:** [February 27, 2023, 11:39am UTC](https://discuss.elastic.co/t/defining-ranges-but-not-one-at-a-time/326573 "2023-02-27T11:39:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gyannea](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@gyannea](https://discuss.elastic.co/u/gyannea)\
**Post date:** [February 27, 2023, 11:39am UTC](https://discuss.elastic.co/t/defining-ranges-but-not-one-at-a-time/326573/1 "2023-02-27T11:39:21Z")

</div>

I want to create a bar graph of the time a cellular network was down. The y-axis gives the number of times and the x-axis is a set of ranges, 0-100 seconds, 100-200, seconds, in intervals of 100 seconds up to 100000. That's 1000 buckets. I can do this by writing 1000 copies of the range script. AGONY!!!

Is there a way to specify a range as something like:

from 0 to 100000 in groups of 100?

---

<div class="post-metadata">

**Author:** ![philippkahr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philippkahr/32/100137_2.png) [@philippkahr](https://discuss.elastic.co/u/philippkahr)\
**Post date:** [February 27, 2023, 11:46am UTC](https://discuss.elastic.co/t/defining-ranges-but-not-one-at-a-time/326573/2 "2023-02-27T11:46:21Z")

</div>

Maybe a histogram does the trick, with interval set to 100? [Histogram aggregation | Elasticsearch Guide [8.6] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html)

---

<div class="post-metadata">

**Author:** ![gyannea](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@gyannea](https://discuss.elastic.co/u/gyannea)\
**Post date:** [February 27, 2023, 1:05pm UTC](https://discuss.elastic.co/t/defining-ranges-but-not-one-at-a-time/326573/3 "2023-02-27T13:05:12Z")

</div>

Thanks! That is what I need. I still can't get the visualization to work, however. I wanted intervals of 100 but on the x-axis the intervals are in units of 3000 and goes well out beyond 200000. Only the first few bins have values with 95% of them in the first bin. Can't get the display to change regardless of what I enter for parameters. Put in 10, 100, 1000, 10000 same result. If I select show empty bins I get a min an max option but it does not matter what I enter for those parameters. The graph is always the same. But the HISTOGRAM is exactly what I was looking for.

I found the problem. I had one freak document with a value that was well above 250000. I could use the min-max to exclude that document.

By the way, is there a way to get the actual code used by Kibana when you use their tools to create visualizations? That would be a great help in learning the syntax and seeing what does what. I can get the code of the discovery filtering and am able to create my own filters. I see I can enter JSON in the visualization 'advanced' option. Would love to get the JSON of what I created through the interface!!!

---

<div class="post-metadata">

**Author:** ![philippkahr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philippkahr/32/100137_2.png) [@philippkahr](https://discuss.elastic.co/u/philippkahr)\
**Post date:** [February 27, 2023, 2:15pm UTC](https://discuss.elastic.co/t/defining-ranges-but-not-one-at-a-time/326573/4 "2023-02-27T14:15:22Z")

</div>

Use the inspect button, inside a Lens visualisation..

 ![Screenshot 2023-02-27 at 15.14.49](https://us1.discourse-cdn.com/elastic/original/3X/e/9/e9fbe8ee75e4fe8bc055499747fd95763920e766.jpeg)

---

<div class="post-metadata">

**Author:** ![gyannea](https://avatars.discourse-cdn.com/v4/letter/g/71e660/32.png) [@gyannea](https://discuss.elastic.co/u/gyannea)\
**Post date:** [February 27, 2023, 3:26pm UTC](https://discuss.elastic.co/t/defining-ranges-but-not-one-at-a-time/326573/5 "2023-02-27T15:26:17Z")

</div>

Thanks again - just what the doctor ordered!

---

<div class="post-metadata">

**Author:** ![philippkahr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/philippkahr/32/100137_2.png) [@philippkahr](https://discuss.elastic.co/u/philippkahr)\
**Post date:** [February 28, 2023, 9:06am UTC](https://discuss.elastic.co/t/defining-ranges-but-not-one-at-a-time/326573/6 "2023-02-28T09:06:34Z")

</div>

You can ignore most of the stuff inside that inspector. Focus on `aggs` and `query` 🙂

---

<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:** [March 28, 2023, 9:06am UTC](https://discuss.elastic.co/t/defining-ranges-but-not-one-at-a-time/326573/7 "2023-03-28T09:06:57Z")

</div>

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