From f4cf56036720f1a078f6533f6babc420058bb4ef Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Thu, 25 Apr 2024 15:37:07 +0900 Subject: [PATCH] decode_prometheus_remote_write: Detect histogram type of payloads if included Signed-off-by: Hiroshi Hatake --- src/cmt_decode_prometheus_remote_write.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cmt_decode_prometheus_remote_write.c b/src/cmt_decode_prometheus_remote_write.c index cbe394d..1a01f2d 100644 --- a/src/cmt_decode_prometheus_remote_write.c +++ b/src/cmt_decode_prometheus_remote_write.c @@ -515,6 +515,7 @@ static int decode_metrics_entry(struct cmt *cmt, void *instance; int result; int ts_count = 0; + int hist_count = 0; int meta_count = 0; Prometheus__MetricMetadata *metadata = NULL; Prometheus__MetricMetadata__MetricType type; @@ -526,6 +527,7 @@ static int decode_metrics_entry(struct cmt *cmt, for (i = 0; i < ts_count; i++) { ts = write->timeseries[i]; meta_count = write->n_metadata; + hist_count = ts->n_histograms; if (meta_count > 0) { metadata = write->metadata[i]; } @@ -533,6 +535,10 @@ static int decode_metrics_entry(struct cmt *cmt, type = PROMETHEUS__METRIC_METADATA__METRIC_TYPE__GAUGE; metric_description = "-"; } + else if (hist_count > 0) { + type = PROMETHEUS__METRIC_METADATA__METRIC_TYPE__HISTOGRAM; + metric_description = "-"; + } else { type = write->metadata[i]->type; metric_description = write->metadata[i]->help;