• General information
  • Installation
  • Configuration
  • Usage/admin
  • Troubleshooting
  • PQL - Puppet Query Language
  • API
  • Query API version 4
  • Extensions API version 1 (PE-only)
  • Admin API version 1
  • Command API version 1
  • Status API version 1
  • Metadata API version 1
  • Metrics API version 1
  • Wire formats

Logging configuration

Sections

Structured logging

PuppetDB uses logback, a standard Java logging library. In certain subsystems, namely HA, we provide extended structured logging information. By configuring logback appropriately, you get JSON-formatted log messages with event-specific fields in each message.

Common fields

If you use the recommended logger configuration, as described below, you will see the following fields in each JSON log message:

  • @timestamp
  • message
  • logger_name
  • thread_name
  • level
  • level_value (numeric, suitable for sorting)
  • stack_trace

Additional relevant fields may be added in any given message, but this base set will always be present.

JSON text

If you want to log JSON data where you would otherwise log regular text, replace the ‘encoder’ element in your logback.xml with this one:

<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
  <providers>
    <timestamp/>
    <message/>
    <loggerName/>
    <threadName/>
    <logLevel/>
    <logLevelValue/>
    <stackTrace/>
    <logstashMarkers/>
  </providers>
</encoder>

Even though this says ‘logstash’ on it, it works completely independently from any log aggregation system. The final <logstashMarkers/> element inserts our custom properties into each JSON message.

Logback integration

You can also log directly to logstash with an appender configured like this:

<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
  <remoteHost>logging.dev</remoteHost>
  <port>4560</port>

  <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
    <providers>
      <timestamp/>
      <message/>
      <loggerName/>
      <threadName/>
      <logLevel/>
      <logLevelValue/>
      <stackTrace/>
      <logstashMarkers/>
    </providers>
  </encoder>
</appender>

You will also need to add a reference to the appender from the <root> element:

<root>
  ...
  <appender-ref ref="stash" />
</root>

References

These example configurations should get you started. For more advanced scenarios, the respective tools have good documentation.

  • Logstash Appender: https://github.com/logstash/logstash-logback-encoder#tcp

  • JSON Encoder: https://github.com/logstash/logstash-logback-encoder#composite_encoder

  • Logback configuration: http://logback.qos.ch/manual/configuration.html

Puppet sites use proprietary and third-party cookies. By using our sites, you agree to our cookie policy.