Skip to content

Log

Publish TenXSummary instance values as metric counters to a target log4j2 appender.

The specified appender can write values to any log4j2 destination as INFO messages using micrometer's simple format.

Configuration

To configure the Log4j2 metrics output module, Edit these settings.

Below is the default configuration from: log/config.yaml.

Edit Online

Edit config.yaml Locally

# 🔟❎ 'run' Log4j2 metric output configuration

# Configure log4j2 metric counter outputs.
# To learn more see https://doc.log10x.com/run/output/metric/log/

# Set the 10x pipeline to 'run'
tenx: run

# =============================== Dependencies ================================

include: run/modules/output/metric/log

# ============================== Log4j2 Options ===============================

# Define multiple log4j2 metric outputs below
simple:

    # 'loggerName' sets the log4j2 logger to which registry metric data is periodically logged
    #  metric are logged a 'INFO' messages using micrometer's default 'simple' format.
    #  To learn more see: https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-core/src/main/java/io/micrometer/core/instrument/simple/SimpleMeterRegistry.java
  - loggerName: consoleOut

    # ---------------------------- Counter Options ----------------------------

    # 'nameField' sets the TenXSummary field whose value identifies the micrometer counter to increment. 
    #  The 'inputName' field returns the name of the aggregator that produced the target TenXSummary instance.
    #  To learn more see https://doc.log10x.com/run/aggregate
    nameField: inputName

    # 'counterFields' specifies the TenXSummary fields whose values are used to increment the counter.
    #  To learn more see https://doc.log10x.com/run/aggregate/#summary-fields
    counterFields:
      - summaryVolume
      - summaryBytes
      - summaryTotals

    # 'tagFields' sets the TenXSummary fields used as the counter tag dimension values.
    #  Defaults to https://doc.log10x.com/run/initialize/#enrichmentFields
    tagFields:
      - $=yield TenXEnv.get("enrichmentFields")

    # 'tagFieldNames' allows setting custom names to aggregated fields for metrics reporting.
    #  Defaults to https://doc.log10x.com/run/initialize/#metricFieldNames
    tagFieldNames:
      - $=yield TenXEnv.get("metricFieldNames")

    # 'filter' sets a JavaScript expression that TenXSummaries must evaluate as truthy to write to the output.
    #  To learn more see https://doc.log10x.com/run/output/regulate/#filter-expressions
    filter: isSummary

    # ---------------------------- Publish Options ----------------------------

    # 'step' sets the frequency in which metrics are logged to 'loggerName' in
    # ISO-8601 format. To learn more see:
    # https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html#parse-java.lang.CharSequence-
    step: PT1S

Options

Specify the options below to configure multiple Log4j2 metrics output:

Name Description Category
simpleEnabled Enable this output General
simpleNameField Name of the TenXSummary field identifying the metric Counter
simpleCounterFields Names of the TenXSummary fields used to increment the metric counter value Counter
simpleTagFields List of TenXSummary fields to use as metric tag values Counter
simpleTagFieldNames List of custom names to use for TenXSummary fields. Counter
simpleFilter A JavaScript expression an TenXSummary must evaluate as 'truthy' against to be written to this output Counter
simpleMaxCardinality Maximum number of unique metric combinations allowed Counter
simpleStep The interval at which to publish metrics to output Counter
simpleLoggerName Name of log4j2 logger to which registry metric data is periodically logged Log4j2

General

simpleEnabled

Enable this output.

Type Default Category
Boolean true General

Enable or disable this output.

Counter

simpleNameField

Name of the TenXSummary field identifying the metric.

Type Default Category
String summaryValues Counter

Defines the name of the TenXSummary field whose value identifies a metric counter. Defaults to the summaryValues field which holds the value(s) by which TenXObjects are grouped into the current TenXSummary instance. To learn more see micrometer counters.

simpleCounterFields

Names of the TenXSummary fields used to increment the metric counter value.

Type Default Category
List summaryVolume Counter

Defines the name of the TenXSummary field by whose value to increment the counter.

simpleTagFields

List of TenXSummary fields to use as metric tag values.

Type Default Category
List [] Counter

Defines the TenXSummary field names to use as tag values. Tags are dimensions that enable slicing a particular named metric to drill down to reason about its value. To learn more see micrometer tags.

simpleTagFieldNames

List of custom names to use for TenXSummary fields.

Type Default Category
List [] Counter

Defines the a list of custom names to give fields when reporting them. Format as a list of name1, custom1, name2, custom2.

For example, to set a custom name of 'My-Custom-Field' to an existing 'intrinsic-field':

simple:
  tagFieldNames:
    - intrinsic-field
    - My-Custom-Field.

simpleFilter

A JavaScript expression an TenXSummary must evaluate as 'truthy' against to be written to this output.

Type Default Category
String "" Counter

Specifies a JavaScript expression that an TenXSummary must evaluate as truthy to write its instance/template field values to the target counter.

For example, to only emit TenXSummaries produced by the 'myMetric' aggregator, specify:

simple:
  filter: this.inputName == "myMetric"

To learn more see inputName.

simpleMaxCardinality

Maximum number of unique metric combinations allowed.

Type Default Category
Number 500 Counter

Sets the maximum number of unique metric combinations (cardinality) allowed for this output. When exceeded, metrics will be dropped to prevent excessive cardinality.

simpleStep

The interval at which to publish metrics to output.

Type Default Category
String 1min Counter

Sets the interval at which to publish metrics to the time-series destination (e.g., '1m'). To learn more see rate-aggregation.

Log4j2

simpleLoggerName

Name of log4j2 logger to which registry metric data is periodically logged.

Type Required Category
String Log4j2

Sets the log4j2 logger to which registry metric data is periodically logged metric are logged as 'INFO' messages using the Micrometer default 'simple' format. To learn more see: SimpleMeterRegistry.


This module is defined in log/module.yaml.