# Unable to visualize histogram data

**URL:** <https://discuss.elastic.co/t/unable-to-visualize-histogram-data/372300>\
**Category:** Kibana\
**Created:** [December 22, 2024, 10:23am UTC](https://discuss.elastic.co/t/unable-to-visualize-histogram-data/372300 "2024-12-22T10:23:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mudboyzh](https://avatars.discourse-cdn.com/v4/letter/m/c68b51/32.png) [@Mudboyzh](https://discuss.elastic.co/u/Mudboyzh)\
**Post date:** [December 22, 2024, 10:23am UTC](https://discuss.elastic.co/t/unable-to-visualize-histogram-data/372300/1 "2024-12-22T10:23:00Z")

</div>

Hi guys,

I tried to visualize the histogram data from Prometheus

I checked a few topics or GitHub issues, kibana seems to support histogram data.

My Elastic Stack version is 8.15.3.

Here is the simplified data.

```auto
# Set Mapping for histogram type
PUT /prometheus-histogram-index
{
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "prometheus": {
        "properties": {
          "my_metric": {
            "properties": {
              "histogram": {
                "type": "histogram"
              }
            }
          }
        }
      }
    }
  }
}
# Sample Data
POST /prometheus-histogram-index/_doc
{
  "@timestamp": "2024-12-22T08:48:00Z",
  "prometheus.my_metric.histogram": {
    "values": [1, 2, 3, 4],
    "counts": [0, 2, 3, 5]
  }
}
POST /prometheus-histogram-index/_doc
{
  "@timestamp": "2024-12-22T08:49:00Z",
  "prometheus.my_metric.histogram": {
    "values": [1, 2, 3, 4],
    "counts": [1, 3, 7, 4]
  }
}

```

It looks fine when I use elasticsearch search api.

```auto
GET prometheus-histogram-index/_search
{
  "size": 0, 
  "aggs": {
    "time_bucket": {
      "date_histogram": {
        "field": "@timestamp",
        "fixed_interval": "1m"
      },
      "aggs": {
        "hist": {
          "histogram": {
            "field": "prometheus.my_metric.histogram",
            "interval": 0.5
          }
        }
      }
    }
  }
}

```

group by histogram values and sum histogram counts.

```auto
...
"aggregations": {
    "time_bucket": {
      "buckets": [
        {
          "key_as_string": "2024-12-22T08:48:00.000Z",
          "key": 1734857280000,
          "doc_count": 1,
          "hist": {
            "buckets": [
              {
                "key": 2,
                "doc_count": 2
              },
              {
                "key": 2.5,
                "doc_count": 0
              },
              {
                "key": 3,
                "doc_count": 3
              },
              {
                "key": 3.5,
                "doc_count": 0
              },
              {
                "key": 4,
                "doc_count": 5
              }
            ]
          }
        },
        {
          "key_as_string": "2024-12-22T08:49:00.000Z",
          "key": 1734857340000,
          "doc_count": 1,
          "hist": {
            "buckets": [
              {
                "key": 1,
                "doc_count": 1
              },
              {
                "key": 1.5,
                "doc_count": 0
              },
              {
                "key": 2,
                "doc_count": 3
              },
              {
                "key": 2.5,
                "doc_count": 0
              },
              {
                "key": 3,
                "doc_count": 7
              },
              {
                "key": 3.5,
                "doc_count": 0
              },
              {
                "key": 4,
                "doc_count": 4
              }
            ]
          }
        }
      ]
    }
  }
...

```

I want to get similar result on visualization with kibana.

I used the heat map in lens, but it can not set vertical axis for the histogram fields(the values in prometheus.my\_metric.histogram)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/b/7b078ed00fec4d7e9738530c92517c00991ecab7.png)

The cell value looks weird.  
Sum of prometheus.my\_metric.histogram will get sum of values[i] x counts[i]

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/7/b7e47d5b4d670648fa575a0ba046c5a73c7a4b18.png)

Besides lens, I tried the others visualizations(aggregation based heat map and TSVB).

They don’t work as I expect.

Did I miss anything or it just not support for this use case?

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [February 13, 2025, 2:26pm UTC](https://discuss.elastic.co/t/unable-to-visualize-histogram-data/372300/2 "2025-02-13T14:26:13Z")

</div>

Hi @Mudboyzh

currently Lens editor doesn't fully support the histogram field type.  
As stated in this issue [Allow histogram aggregation on histogram field type · Issue #112390 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/112390) it is something we would like to handle via ES|QL in the future.
