client_java icon indicating copy to clipboard operation
client_java copied to clipboard

MapperConfig does not allow : in regex

Open muuki88 opened this issue 3 years ago • 2 comments

Hi,

Thanks for the custom mapper config on the dropwizard export. It makes creating tags really easy :heart:

I found a restriction in the regex that makes it impossible for me to create a certain configuration. : are not allowed and we have metrics that contain ip:port in the metric name.

https://github.com/prometheus/client_java/blob/29dfd0a2bf9b93282764d31447b843a1d36d4f10/simpleclient_dropwizard/src/main/java/io/prometheus/client/dropwizard/samplebuilder/MapperConfig.java#L25

This is what the mapper config would look like

// this port is dynamically set from the outside
final int httpPort = 8080
final MapperConfig vertxServerHttp = new MapperConfig(
     // the IP address is always 0.0.0.0
    "vertx.http.servers.0.0.0.0:" + httpPort + ".*", "vertx.http.servers.${4}",
     ImmutableMap.of("endpoint", "http")
);

So the metric currentely ends up like this in prometheus

vertx_http_servers_0_0_0_0:8080_metric

which gets messy as ports change.

Suggestion

Add : to the global regex.

I don't know what implications this would have

muuki88 avatar Mar 24 '21 14:03 muuki88

Sorry for the delay. I put this on my TODO list, but I would like to get Exemplars done first before I look into Dropwizard. I will get back to this issue.

fstab avatar Apr 26 '21 20:04 fstab

No worries :heart: I would open a pull request with this feature if it helps you and there's a chance this can get merged :smile:

muuki88 avatar Apr 27 '21 07:04 muuki88