Search in sources :

Example 1 with DropwizardExports

use of io.prometheus.client.dropwizard.DropwizardExports in project vertx-examples by vert-x3.

the class PrometheusMetricsVerticle method start.

@Override
public void start() throws Exception {
    MetricRegistry metricRegistry = SharedMetricRegistries.getOrCreate("exported");
    CollectorRegistry.defaultRegistry.register(new DropwizardExports(metricRegistry));
    // Bind metrics handler to /metrics
    Router router = Router.router(vertx);
    router.get("/metrics").handler(new MetricsHandler());
    // Start httpserver on localhost:8080
    vertx.createHttpServer().requestHandler(router::accept).listen(8080);
    // Increase counter every second
    vertx.setPeriodic(1_000L, e -> metricRegistry.counter("testCounter").inc());
}
Also used : DropwizardExports(io.prometheus.client.dropwizard.DropwizardExports) MetricRegistry(com.codahale.metrics.MetricRegistry) MetricsHandler(io.prometheus.client.vertx.MetricsHandler) Router(io.vertx.ext.web.Router)

Example 2 with DropwizardExports

use of io.prometheus.client.dropwizard.DropwizardExports in project dcos-commons by mesosphere.

the class Metrics method configureMetricsEndpoints.

/**
 * Appends endpoint servlets to the provided {@code context} which will serve codahale-style and prometheus-style
 * metrics.
 */
public static void configureMetricsEndpoints(ServletContextHandler context, String codahaleMetricsEndpoint, String prometheusEndpoint) {
    // Metrics
    ServletHolder codahaleMetricsServlet = new ServletHolder("default", new com.codahale.metrics.servlets.MetricsServlet(metrics));
    context.addServlet(codahaleMetricsServlet, codahaleMetricsEndpoint);
    // Prometheus
    CollectorRegistry collectorRegistry = new CollectorRegistry();
    collectorRegistry.register(new DropwizardExports(metrics));
    ServletHolder prometheusServlet = new ServletHolder("prometheus", new io.prometheus.client.exporter.MetricsServlet(collectorRegistry));
    context.addServlet(prometheusServlet, prometheusEndpoint);
}
Also used : DropwizardExports(io.prometheus.client.dropwizard.DropwizardExports) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) CollectorRegistry(io.prometheus.client.CollectorRegistry)

Example 3 with DropwizardExports

use of io.prometheus.client.dropwizard.DropwizardExports in project copper-cms by PogeyanOSS.

the class AkkaServletContextListener method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent sce) {
    ActorSystem system = ActorSystem.create("GatewaySystem");
    sce.getServletContext().setAttribute("ActorSystem", system);
    String configFilename = sce.getServletContext().getInitParameter(CONFIG_INIT_PARAM);
    if (configFilename == null) {
        configFilename = CONFIG_FILENAME;
    }
    DatabaseServiceFactory.add(MongoClientFactory.createDatabaseService());
    LOG.info("Registering actors to main actor system");
    system.actorOf(Props.create(GatewayActor.class), "gateway");
    system.actorOf(Props.create(LoginActor.class), "login");
    system.actorOf(Props.create(RepositoryActor.class), "repository");
    system.actorOf(Props.create(ObjectActor.class), "object");
    system.actorOf(Props.create(NavigationActor.class), "navigation");
    system.actorOf(Props.create(RelationshipActor.class), "relationships");
    system.actorOf(Props.create(PolicyActor.class), "policy");
    system.actorOf(Props.create(VersioningActor.class), "versioning");
    system.actorOf(Props.create(AclActor.class), "acl");
    system.actorOf(Props.create(DiscoveryActor.class), "discovery");
    LOG.info("Initializing service factory instances");
    try {
        boolean factory = createServiceFactory(sce, configFilename);
        if (!factory) {
            throw new IllegalArgumentException("Repository manager class not initilaized");
        }
    } catch (Exception e) {
        LOG.error("Service factory couldn't be created: {}", e.toString(), e);
    }
    if (externalActorClassMap != null && !externalActorClassMap.isEmpty()) {
        externalActorClassMap.forEach((key, value) -> system.actorOf(Props.create(key), value));
    }
    if (Helpers.isPerfMode()) {
        ConsoleReporter reporter = ConsoleReporter.forRegistry(MetricsInputs.get().getMetrics()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
        reporter.start(10, TimeUnit.SECONDS);
        if (Helpers.isPrometheusMode()) {
            MetricsInputs.collectorRegistry().register(new DropwizardExports(MetricsInputs.get().getMetrics()));
        }
    }
}
Also used : ActorSystem(akka.actor.ActorSystem) ConsoleReporter(com.codahale.metrics.ConsoleReporter) DiscoveryActor(com.pogeyan.cmis.actors.DiscoveryActor) NavigationActor(com.pogeyan.cmis.actors.NavigationActor) GatewayActor(com.pogeyan.cmis.server.GatewayActor) AclActor(com.pogeyan.cmis.actors.AclActor) ObjectActor(com.pogeyan.cmis.actors.ObjectActor) RepositoryActor(com.pogeyan.cmis.actors.RepositoryActor) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) DropwizardExports(io.prometheus.client.dropwizard.DropwizardExports) PolicyActor(com.pogeyan.cmis.actors.PolicyActor) VersioningActor(com.pogeyan.cmis.actors.VersioningActor) LoginActor(com.pogeyan.cmis.auth.LoginActor) RelationshipActor(com.pogeyan.cmis.actors.RelationshipActor)

Aggregations

DropwizardExports (io.prometheus.client.dropwizard.DropwizardExports)3 ActorSystem (akka.actor.ActorSystem)1 ConsoleReporter (com.codahale.metrics.ConsoleReporter)1 MetricRegistry (com.codahale.metrics.MetricRegistry)1 AclActor (com.pogeyan.cmis.actors.AclActor)1 DiscoveryActor (com.pogeyan.cmis.actors.DiscoveryActor)1 NavigationActor (com.pogeyan.cmis.actors.NavigationActor)1 ObjectActor (com.pogeyan.cmis.actors.ObjectActor)1 PolicyActor (com.pogeyan.cmis.actors.PolicyActor)1 RelationshipActor (com.pogeyan.cmis.actors.RelationshipActor)1 RepositoryActor (com.pogeyan.cmis.actors.RepositoryActor)1 VersioningActor (com.pogeyan.cmis.actors.VersioningActor)1 LoginActor (com.pogeyan.cmis.auth.LoginActor)1 GatewayActor (com.pogeyan.cmis.server.GatewayActor)1 CollectorRegistry (io.prometheus.client.CollectorRegistry)1 MetricsHandler (io.prometheus.client.vertx.MetricsHandler)1 Router (io.vertx.ext.web.Router)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)1