mqtt(): Send messages from a local network to an MQTT broker

AxoSyslog can use the mqtt() destination to publish messages to MQTT brokers.

The mqtt() destination builds on the MQTT protocol , and uses its “client ” and “broker ” entities.

Prerequisites

Declaration:

Terminal window
   destination d_mqtt { 
      mqtt(
        topic("<topic-name>"), 
        address("tcp://localhost:<port-number>"),   
        fallback_topic("<fallback-topic-name>")
      ); 
    }

Example: Using the mqtt() destination in your configuration

The following example illustrates a mqtt() destination configured to fetch messages from the localhost:4444 address, and send them to the broker running on localhost:4445, using the mqtt test/test topic.

Terminal window
   @version: 3.32
    @include "scl.conf"
    
      source s_net { 
        network(port(4444)
      ); 
    };
    
      destination d_mqtt { 
        mqtt(topic("test/test"), address("tcp://localhost:4445"), fallback_topic("test/test")
      ); 
    };
                    
    log { 
      source(s_net); 
      destination( d_mqtt); 
    };