1

We have a vertx micro-service for customer authentication in production. We are using dropwizard-metrics to send metrics to graphite and using Graphana to plot the graph for time series data. The service communicates with MySQL db for transactions and we are using C3P0 for connection pooling. The frequency to push data to graphite is 30 seconds. I have attached the code for the same. The maximum requests per minute during peak traffic is 600.

Viewing at the graph we can see the number of connections in use at a given point of time. However, I am unable to understand why the value is negative. If there is no connection in use, I believe the graph should show in-use count as 0.

Can someone please explain what does the negative value mean? Any explanation would be deeply appreciated.

I have attached the screenshot for the same.

Attached is the vertx configuration.

public class ApplicationModule extends AbstractModule {

@Override
protected void configure() {
    VertxOptions vertxOptions = new VertxOptions()
        .setMetricsOptions(new DropwizardMetricsOptions()
            .setEnabled(true)
            .addMonitoredHttpServerUri(new Match().setValue("/*").setType(MatchType.REGEX))
            .setRegistryName(CommonConstants.METRICS_REGISTRY_NAME))
        .setMaxWorkerExecuteTime((long) 1.8e+12); // 30 minutes in nanosecond
    Vertx vertx = Vertx.vertx(vertxOptions);
    bind(Vertx.class).toInstance(vertx);
    bind(MetricRegistry.class).toInstance(SharedMetricRegistries.getOrCreate(CommonConstants.METRICS_REGISTRY_NAME));
}

}

Attached is the code to send metrics to Graphite.

public class MetricsVerticle extends AbstractVerticle {
private static final Logger LOGGER = LoggerFactory.getLogger(MetricsVerticle.class);
private final MetricRegistry registry;
private final String env;
private final Graphite graphite;
private final GraphiteReporter reporter;

@Inject
public MetricsVerticle(MetricRegistry registry, 
    @Named(GRAPHITE_HOST) String host, 
    @Named(GRAPHITE_PORT) String port, 
    @Named(ENVIRONMENT_NAME) String env) {
    this.registry = registry;
    this.env = env;
    this.graphite = new Graphite(new InetSocketAddress(host, Integer.parseInt(port)));
    this.reporter = buildGraphiteReporter();
}

@Override
public void start() throws Exception {
    sendMetricsToGraphite();
    LOGGER.info("Deployed MetricsVerticle");
}

@Override
public void stop() {
    try {
        LOGGER.info("----- Stopping Graphite reporter -----");
        reporter.stop();
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
}

private void sendMetricsToGraphite() {
    LOGGER.info("----- Streaming metrics to Graphite -----");
    reporter.start(30, TimeUnit.SECONDS);
}

private GraphiteReporter buildGraphiteReporter() {
    LOGGER.info("----- Registering Graphite as metrics consumer -----");
    return GraphiteReporter.forRegistry(registry)
        .prefixedWith("in.hopscotch.services.abtest") 
        .convertRatesTo(TimeUnit.SECONDS)
        .convertDurationsTo(TimeUnit.MILLISECONDS)
        .build(graphite);
}

}

Lalit Rao
  • 551
  • 5
  • 22
  • Can you take a [metrics snapshot](https://vertx.io/docs/vertx-dropwizard-metrics/java/#_metrics_service) from time to time? This would help determine if this odd value comes from metric collection or metric reporting. Thanks – tsegismont Sep 12 '18 at 08:14

0 Answers0