Skip to content

Monitoring

Tomasz Kowalczewski edited this page Jul 2, 2021 · 2 revisions

Introduction

Tjahzi tracks its operational statistics in many internal counters. It tracks http errors, timeouts and tcp errors in separate counters. It also records exceptions and their stack traces. If you want to get access to them or expose them to your monitoring system this is the instruction on how to do that.

Enable monitoring

  1. First you need to get hold of the appender from Log4j logging system:

    import org.apache.logging.log4j.LogManager;
    import org.apache.logging.log4j.Logger;
    import org.apache.logging.log4j.core.LoggerContext;
    
    ...
    
    LoggerContext context = (LoggerContext) LogManager.getContext(false);
    LokiAppender loki = context.getConfiguration().getAppender("Loki");

    Where "Loki" is the name of the appender you specified in the configuration file:

    <appenders>
            <Loki name="Loki">
            ...
            </Loki>
    </appenders>
  2. Then you can install a new MonitoringModule

    loki.setMonitoringModule(...)
  3. You can use simple StandardMonitoringModule that tracks events in counters that will have access to.

      StandardMonitoringModule monitoringModule = new StandardMonitoringModule()
      loki.setMonitoringModule(monitoringModule)
  4. You can implement your own or use Dropwizard based implementation.

Integration with Dropwizard library

If you are using Dropwizard library for monitoring your application then Tjahzi comes with implmeentation of monitoring module that integrates with MetricRegistry.

    loki.setMonitoringModule(
                new DropwizardMonitoringModule(
                        metricRegistry,
                        "appender.loki"
                )
        );

Where "appender.loki is a prefix added to all metric names that Tjahzi will create.

Clone this wiki locally