prometheus_exporter icon indicating copy to clipboard operation
prometheus_exporter copied to clipboard

Change prefix on custom metrics

Open blackjid opened this issue 7 years ago • 7 comments

It is possible to change the prefix for a specific metric??

I would like to stay with the standard ruby_ prefix for the built-in metrics, but change it for my custom ones.

blackjid avatar Dec 13 '18 15:12 blackjid

I think we are going to need some sort of PR to support an override here.

SamSaffron avatar Dec 14 '18 06:12 SamSaffron

I think we got to clean up the naming on all the process metrics, heap_free_slots is not a good name, it should be ruby_heap_free_slots and I think it should be prefix immune if we wish, so we need an extra flag to make it prefix immune.

Unfortunately this will be a bit of a breaking change, but it is worth it for consistency sake.

SamSaffron avatar Feb 13 '19 23:02 SamSaffron

We would welcome this feature as it seems that is the only way to get rid of these warnings in Google Cloud logging system: https://github.com/GoogleCloudPlatform/k8s-stackdriver/issues/202

But we can't add a custom metric with the required name due to the global nature of the prefix.

Best regards, Thomas.

thomasbalsloev avatar Mar 23 '21 15:03 thomasbalsloev

not against this in principle, but let's start with API first

What API are your proposing?

SamSaffron avatar Mar 23 '21 23:03 SamSaffron

Hi @SamSaffron

Thanks for getting back on this.

I can image a couple of things to choose from:

  1. On individual custom registered metrics. client = PrometheusExporter::Client.default gauge = client.register(:gauge, "awesome", "amount of awesome", prefix: 'custom_')

  2. Global option for prefix on custom metrics.

Usage: prometheus_exporter [options]
    -p, --port INTEGER               Port exporter should listen on (default: 9394)
    -b, --bind STRING                IP address exporter should listen on (default: localhost)
    -t, --timeout INTEGER            Timeout in seconds for metrics endpoint (default: 2)
        --prefix METRIC_PREFIX       Prefix to apply to all metrics (default: ruby_)
     **--custom-metric-prefix STRING  Prefix to apply to all custom metrics (default: ruby_)**

BR, Thomas.

thomasbalsloev avatar Mar 24 '21 09:03 thomasbalsloev

I like the idea of adding a prefix: ... to the register API, is this is PR you could work on?

SamSaffron avatar Mar 25 '21 04:03 SamSaffron

@SamSaffron

Hi Sam.

Sure, I may not get the time until after Easter though, but I'll give it a shot :)

BR, Thomas.

thomasbalsloev avatar Mar 25 '21 08:03 thomasbalsloev