How to make Microprofile Metrics available on multiple paths on Wildfly26?

205 Views Asked by At

I am attempting to migrate from wildfly-18 to wildfly-26. I changed the application to use Microprofile for Metrics and Health Checks. Those are working and I have redirected the /metrics and /health endpoints from the wildfly management port to the https port using the following config:

/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=microprofile-outbound/:add(host="localhost", port="9990")
/subsystem=undertow/configuration=handler/reverse-proxy=metrics-handler:add()
/subsystem=undertow/configuration=handler/reverse-proxy=metrics-handler/host=microprofile-host:add(outbound-socket-binding=microprofile-outbound, scheme=http, instance-id=metricsroute, path=/metrics)
/subsystem=undertow/server=default-server/host=default-host/location="/metrics":add(handler=metrics-handler)
/subsystem=undertow/configuration=handler/reverse-proxy=health-handler:add()
/subsystem=undertow/configuration=handler/reverse-proxy=health-handler/host=microprofile-host:add(outbound-socket-binding=microprofile-outbound, scheme=http, instance-id=healthroute, path=/health)
/subsystem=undertow/server=default-server/host=default-host/location="/health":add(handler=health-handler)

Everything appears as expected at https://hostname:port/metrics. In order to match existing functionality I would like to make the metrics also available at https://hostname:port/applicationContext/resources/metrics but have not been able to figure out how to do that. Is a rewrite rule what I need or is there a way to get the metrics registry provided by wildfly from within my application and expose them on the desired path from within the application?

1

There are 1 best solutions below

0
On

You should first create the filter and then use it with filter-ref:

/subsystem=undertow/configuration=filter/rewrite=metrics-path-rewrite:add(target="/metrics")
/subsystem=undertow/server=default-server/host=default-host/filter-ref=metrics-path-rewrite:add(predicate="path(/applicationContext/resources/metrics)")
reload