Openmetrics label truncation
Hello, I'm using dovecot 2.3.18 and want to collect metrics with prometheus via openmetrics. I need to label the metrics with the destination host name. The configuration works fine, but the label value is truncated after 32 chars (and a '...' is added). My config: service stats { inet_listener http { port = 9323 } } metric my_metric { filter = event=smtp_client_transaction_finished group_by = dest_host status_code } I wrote a simple patch, that fixes that for me: diff --git a/src/stats/stats-metrics.c b/src/stats/stats-metrics.c index 877c142546..30126563ff 100644 --- a/src/stats/stats-metrics.c +++ b/src/stats/stats-metrics.c @@ -357,7 +357,7 @@ stats_metric_sub_metric_alloc(struct metric *metric, const char *name, pool_t po array_append_zero(&fields); sub_metric = stats_metric_alloc(pool, metric->name, metric->set, array_idx(&fields, 0)); - sub_metric->sub_name = p_strdup(pool, str_sanitize_utf8(name, 32)); + sub_metric->sub_name = p_strdup(pool, str_sanitize_utf8(name, 63)); array_append(&metric->sub_metrics, &sub_metric, 1); return sub_metric; } Why are labels truncated after 32? Is there a reason I do not see? I found no reasons in the openmetrics specification [1]. Thanks in advance Daniel
On 03/06/2022 11:13 Daniel Sabotta
wrote: Hello,
I'm using dovecot 2.3.18 and want to collect metrics with prometheus via openmetrics.
I need to label the metrics with the destination host name. The configuration works fine, but the label value is truncated after 32 chars (and a '...' is added).
My config:
service stats { inet_listener http { port = 9323 } }
metric my_metric { filter = event=smtp_client_transaction_finished group_by = dest_host status_code }
I wrote a simple patch, that fixes that for me:
diff --git a/src/stats/stats-metrics.c b/src/stats/stats-metrics.c index 877c142546..30126563ff 100644 --- a/src/stats/stats-metrics.c +++ b/src/stats/stats-metrics.c @@ -357,7 +357,7 @@ stats_metric_sub_metric_alloc(struct metric *metric, const char *name, pool_t po array_append_zero(&fields); sub_metric = stats_metric_alloc(pool, metric->name, metric->set, array_idx(&fields, 0)); - sub_metric->sub_name = p_strdup(pool, str_sanitize_utf8(name, 32)); + sub_metric->sub_name = p_strdup(pool, str_sanitize_utf8(name, 63)); array_append(&metric->sub_metrics, &sub_metric, 1); return sub_metric; }
Why are labels truncated after 32? Is there a reason I do not see? I found no reasons in the openmetrics specification [1].
Thanks in advance
Daniel
Can you epxlain us the usecase where you need such long labels? Aki Tuomi
Hi Aki thanks for your reply, I am using some dovecots behind a dovecot smtp proxy. Now I want to use OpenMetrics (with Pormetheus) to get metrics on which destination hosts the mails are delivered to. And my hostnames are longer than 32 characters. I hope that explains my use case enough. On 03.06.22 10:16 Aki Tuomi wrote:
On 03/06/2022 11:13 Daniel Sabotta
wrote: Hello,
I'm using dovecot 2.3.18 and want to collect metrics with prometheus via openmetrics.
I need to label the metrics with the destination host name. The configuration works fine, but the label value is truncated after 32 chars (and a '...' is added).
My config:
service stats { inet_listener http { port = 9323 } }
metric my_metric { filter = event=smtp_client_transaction_finished group_by = dest_host status_code }
I wrote a simple patch, that fixes that for me:
diff --git a/src/stats/stats-metrics.c b/src/stats/stats-metrics.c index 877c142546..30126563ff 100644 --- a/src/stats/stats-metrics.c +++ b/src/stats/stats-metrics.c @@ -357,7 +357,7 @@ stats_metric_sub_metric_alloc(struct metric *metric, const char *name, pool_t po array_append_zero(&fields); sub_metric = stats_metric_alloc(pool, metric->name, metric->set, array_idx(&fields, 0)); - sub_metric->sub_name = p_strdup(pool, str_sanitize_utf8(name, 32)); + sub_metric->sub_name = p_strdup(pool, str_sanitize_utf8(name, 63)); array_append(&metric->sub_metrics, &sub_metric, 1); return sub_metric; }
Why are labels truncated after 32? Is there a reason I do not see? I found no reasons in the openmetrics specification [1].
Thanks in advance
Daniel
Can you epxlain us the usecase where you need such long labels?
Aki Tuomi
participants (2)
-
Aki Tuomi
-
Daniel Sabotta