How to Visualize Prometheus Histogram Percentiles in Kibana (Metricbeat to Elasticsearch)

I'm using the Prometheus Metricbeat module to scrape /metrics endpoints from a Go service running in EKS, and ship the metrics to Elasticsearch. Everything works fine and the data is available in Kibana.

I'm particularly interested in visualizing response time percentiles based on histogram data emitted by the application. The histogram metrics are stored in Elasticsearch as multiple documents, one per bucket, with a le (less than or equal to) label. For example:

json

CopyEdit

{
  "_id": "dOcFZocBqL_gAwhbb8g5",
  "prometheus": {
    "labels": {
      "job": "prometheus",
      "api_latency_status": "Success",
      "api_latency_orgID": "1670749265",
      "le": "500",
      "instance": "<masked>:15020"
    },
    "metrics": {
      "api_latency_response_time_histogram_bucket": 14
    }
  }
}

json

CopyEdit

{
  "_id": "eecFZocBqL_gAwhbb8g6",
  "prometheus": {
    "labels": {
      "job": "prometheus",
      "api_latency_status": "Success",
      "api_latency_orgID": "1670749265",
      "le": "1000",
      "instance": "<masked>:15020"
    },
    "metrics": {
      "api_latency_response_time_histogram_bucket": 34
    }
  }
}

This means 14 events had response times ≤ 500ms, and 34 events had response times ≤ 1000ms—so 20 events fell between 500ms and 1000ms.

I want to know how to visualize percentiles like p50, p90, and p99 from this histogram data in Kibana (Lens or TSVB). Since the histogram is already bucketed by le, is there a way to compute percentiles using this format directly in Elasticsearch.

Any help or guidance would be appreciated.

Hi @Kanchan_Karjee Welcome to the community.

Please share
You Elasticsearch, Kibana and Metricbeat versions
Please share the Metricbeat Prometheus module configuration

Also did you read this?