I have another question related to the MicrometerM...
# ktor
s
I have another question related to the MicrometerMetrics we are using in our ktor server. Is there a way to configure particular http routes to skip sending a metric?
a
You can configure the
MeterRegistry
to filter out entries with the specified tag value. Here is an example:
Copy code
embeddedServer(Netty, port = 8081) {
        val appMicrometerRegistry = PrometheusMeterRegistry(PrometheusConfig.DEFAULT).apply {
            config()
                .meterFilter(MeterFilter.deny { id ->
                    id.name == "ktor.http.server.requests" && id.getTag("route") == "/skip"
                })
        }
        install(MicrometerMetrics) {
            registry = appMicrometerRegistry
        }

        routing {
            get("/metrics") {
                call.respond(appMicrometerRegistry.scrape())
            }

            get("/skip") {
                call.respondText { "OK" }
            }

            get("/test") {
                call.respondText { "OK" }
            }
        }
    }.start(wait = true)
s
Thanks! This is perfect!