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.
# 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.
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.
...
"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)
The cell value looks weird.
Sum of prometheus.my_metric.histogram will get sum of values[i] x counts[i]
Besides lens, I tried the others visualizations(aggregation based heat map and TSVB).
They all not work like I expect.
Do I missing anything or it just not support?