-
Notifications
You must be signed in to change notification settings - Fork 19
Monitoring
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.
-
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>
-
Then you can install a new
MonitoringModule
loki.setMonitoringModule(...)
-
You can use simple
StandardMonitoringModule
that tracks events in counters that will have access to.StandardMonitoringModule monitoringModule = new StandardMonitoringModule() loki.setMonitoringModule(monitoringModule)
-
You can implement your own or use Dropwizard based implementation.
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.