quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Auto configure prometheus scraping for lgtm dev service #41944

Closed jtama closed 3 weeks ago

jtama commented 3 months ago

Description

If quarkus-micrometer extensions is used it can be configured to push metrics to prometheus. I think the same could be achieved if quarkus-micrometer-registry-prometheus extension is used.

@melloware already produced a snipet here https://github.com/quarkusio/quarkus/issues/40933#issuecomment-2168344159, (I think there may be an issue with the target.

I guess it could be done only if quarkus-micrometer-registry-prometheus is used.

Implementation ideas

No response

quarkus-bot[bot] commented 3 months ago

/cc @geoand (devservices), @radcortez (config), @stuartwdouglas (devservices)

melloware commented 3 months ago

@jtama in my PR I fixed the pathing issue to look up the proper scrape.

private String getPrometheusConfig() {
        Config runtimeConfig = ConfigProvider.getConfig();
        String rootPath = runtimeConfig.getOptionalValue("quarkus.management.root-path", String.class).orElse("/q");
        String metricsPath = runtimeConfig.getOptionalValue("quarkus.management.metrics.path", String.class).orElse("/metrics");
        int httpPort = runtimeConfig.getOptionalValue("quarkus.http.port", Integer.class).orElse(0);
        PrometheusYamlFile prometheusYamlFile = new PrometheusYamlFile(config.serviceName(), rootPath, metricsPath,
                "host.docker.internal", httpPort);
        return prometheusYamlFile.createPrometheusYamlFile();
    }
jtama commented 3 months ago

this pr would definitely close this issue : https://github.com/quarkusio/quarkus/pull/41264/files

melloware commented 3 months ago

I linked my PR to this ticket.