Openmetrics label truncation

Aki Tuomi aki.tuomi at open-xchange.com
Fri Jun 3 08:16:43 UTC 2022


> On 03/06/2022 11:13 Daniel Sabotta <daniel.sabotta at securepoint.de> 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


More information about the dovecot mailing list