MQ

 View Only

Introducing JSON Formatted Error Logging for AMQP and MQTT

By Aman Tewari posted Thu June 20, 2024 06:10 AM

  

We are excited to announce that as of MQ 9.4, AMQP and MQTT now support error logging in the JSON format natively. 

Up until now, AMQP and MQTT error logs have only been available in traditional plain text format. This makes it challenging for 3rd party applications to digest and monitor the information in these logs. We want to make this much easier, and MQ 9.4 makes this possible. Now, applications should be able to parse the logs and generate meaningful summaries.

Currently, this is an opt-in feature. Textual logs will continue to be the default for error logging both for AMQP as well as MQTT. It is to be noted that the error messages themselves remain the same, and the new functionality affects the structured format of the messages that are logged.

What advantages does this bring?
There are several benefits of JSON formatted logs. Some of them include:

  • Compatibility with modern tools- Many modern log management and monitoring systems are designed to ingest JSON logs natively. This allows for seamless integration and more efficient log processing.
  • JSON logs can be used to set up sophisticated alerting mechanisms and generate detailed dashboards with tools like Grafana and Kibana.
  • Enhanced query Capabilities- Users can query logs based on specific fields and values, leading to more effective troubleshooting and monitoring.
  • Interoperability- Makes it easy to integrate with other systems.
  • Structured data
  • Ease of parsing


Enabling the JSON formatted logs:

We’ve made it easy to enable JSON formatted logging and get started quickly. There are currently two ways of doing so:

  1. By modifying the AMQP/MQTT configuration files (amqptraceOff.properties/amqptraceOn.properties, mqxrtraceOn.properties/mqxrtraceOff.properties). 
    Check the detailed simple to follow instructions from IBM documentation here for AMQP and MQTT!

  2. Setting an environment variable AMQ_ADDITIONAL_JSON_LOG with the value 1 prior to running MQ commands, for example starting MQ with strmqm. This will generate JSON formatted logs for AMQP/MQTT as well as separate JSON error log files for each queue manager.

Where can these logs be found?

The new logs are written to the same location where the textual error logs were previously stored: WMQ data directory\qmgrs\qMgrName\errors

The format of the log file is amqp_n.json.

What is contained in a JSON formatted error log?

A sample JSON entry looks like following. It’s displayed using multiple lines to make it more readable, but MQ will typically write it as a single line.

{ "ibm_messageId": "AMQXR0016",

"ibm_datetime": "2024-06-06T09:28:43.379Z",

"type": "mq_amqp_log",

"message": "AMQXR0016I: Channel 'SYSTEM.DEF.AMQP' has started" }

It’s textual equivalent looks something like this:

6/6/24 09:28:43.379  AMQXR0016I: Channel 'SYSTEM.DEF.AMQP' has started

All of the JSON entries:

Below is a table of possible entries that could occur in a AMQP/MQTT JSON error log:

Member name

Type

Description

ibm_messageId

string

The diagnostic message identifier excluding the severity character e.g. AMQXR0016

ibm_datetime

string

An ISO 8601 formatted timestamp indicating when the message was generated. Of the form “YYYY-MM-DDTHH:MM:SS.mmmZ”, always in UTC.

type

string

type of error log currently only: “mq_amqp_log”

message

string

A summary of the message, including the message identifier and the severity code.

Useful links:

0 comments
15 views

Permalink