Logging probes

Logging probes can monitor logging messages from Magnolia. While the logging probes can’t understand the log messages themselves, they can count the number of log messages being reported, their log levels and the source.

It may not be very useful to build a dashboard visualizing the measurements captured by the logging probes but they can come in handy if you want to watch for specific messages from a specific source - watching for publication error messages, for example - in order to trigger an alert or notification.

Both Prometheus and Grafana have alerting and notification services:

Metrics collected from the logging probes may not be very interesting to visualize in a dashboard, however, they can be useful in triggering an alert or notification when a specific error is logged.

Log4j configuration

The logging probes are implemented as log4j logging appenders and must be configured through your logging configuration and can’t be configured directly through Magnolia.

When configuring the logging probes in your log4j configuration, you must configure two things:

  • the logging probes as log4j appenders

  • log4j categories to send log messages to the logging probe to be counted

The logging probes can’t get the log messages themselves, they need categories to pass along log messages.

Here’s an example of a SimpleLogCounterProbe configured in log4j for Instrument module v1.3 and Magnolia v5.5:

<appender name="simple-log-probe" class="info.magnolia.services.instrumentation.probes.logging.SimpleLogCounterProbe">
  <param name="ProbeName" value="magnoliaMessagesSimple"/>
  <param name="ProbeDescription" value="this is a test"/>
  <param name="MessagePattern" value=".+"/>
</appender>

Here’s a SimpleLogCounterProbe configuration for instrumentation module v1.4, log4j 2 and Magnolia v5.6:

<SimpleLogCounterProbe name="magnolia-messages-simple" probeName="magnoliaMessagesSimple" probeDescription="this is a test" messagePattern=".+"/>

Both define a metric ("magnoliaMessagesSimple") and a messagePattern to filter the log messages being counted (in this case the message pattern matches any log message).

Here is the root category in log4j:

  • log4j

  • log4j2

<root>
  <priority value="ALL" />
  <appender-ref ref="log-error" />
  <appender-ref ref="log-debug" />
  <appender-ref ref="console" />
 <appender-ref ref="simple-log-probe" />
</root>
<Root level="ALL">
  <AppenderRef ref="log-error"/>
  <AppenderRef ref="log-debug"/>
 <AppenderRef ref="console"/>
 <AppenderRef ref="magnolia-messages-simple" />
</Root>

With this configuration, all logging messages reaching the root category will be sent to simple-log-probe to be counted and monitored.

You can also specify an appender in a category and send log messages to a log probe directly:

<category name="info.magnolia.services.intrumentation">
  <priority value="DEBUG" />
  <appender-ref ref="simple-log-probe" />
</category>

This configuration will send any log messages for the Instrumentation module itself to the log probe to be counted.

SimpleLogCounterProbe

The SimpleLogCounterProbe counts all log messages it receives. A SimpleLogCounterProbe has to be defined in your log4j configuration as an appender and log categories defined to direct log messages to the probe to be counted.

SimpleLogCounterProbe just maintains a count of all the log messages it receives. You can also define a message pattern to exclude messages from being counted.

No additional labels (other than the standard instance and job labels) are provided with the metric.

Configuration properties

Property Description Required

class

Should be info.magnolia.services.instrumentation.probes.logging.SimpleLogCounterProbe.

ProbeName

The name.

ProbeDescription

Description of the metric.

MessagePattern

A Java regular expression. Log messages that match the pattern will be counted in the metric.

If no pattern is defined, all log messages will be counted.

LogCounterProbe

The LogCounterProbe counts all log messages it receives. A LogCounterProbe has to be defined in your log4j configuration as an appender and log categories defined to direct log messages to the probe to be counted.

Unlike SimpleLogCounterProbe, it provide two labels - name and level - to identify the source of the log message and the logging level.

LogCounterProbe just maintains a count of all the log messages it receives. You can also define a message pattern to exclude messages from being counted.

Configuration properties

Property Description Required

class

Should be info.magnolia.services.instrumentation.probes.logging.LogCounterProbe.

ProbeName

The name.

ProbeDescription

Description of the metric.

MessagePattern

A Java regular expression. Log messages that match the pattern will be counted in the metric.

If no pattern is defined, all log messages will be counted.

Labels

Label Metric Description

name

<metric-name>

The source of the log message, usually the Java class name where the log message was created.

level

<metric-name>

The log level of the message, one of:

  • DEBUG

  • ERROR

  • FATAL

  • INFO

  • TRACE

  • WARN

Feedback

Incubators

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the Instrumentation module docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules