Chat now with support
Chat with Support

We are currently conducting maintenance on our telephony system. If you are experiencing an issue calling Support and you have a product issue requiring technical assistance, please login to submit or update your Service Request. If additional assistance is needed, please leave a voicemail for a response from Customer Service.

syslog-ng Premium Edition 7.0.24 - Administration Guide

Preface Introduction to syslog-ng The concepts of syslog-ng Installing syslog-ng PE The syslog-ng PE quick-start guide The syslog-ng PE configuration file Collecting log messages — sources and source drivers
How sources work default-network-drivers: Receive and parse common syslog messages internal: Collecting internal messages file: Collecting messages from text files google-pubsub: collecting messages from the Google Pub/Sub messaging service wildcard-file: Collecting messages from multiple text files linux-audit: Collecting messages from Linux audit logs mssql, oracle, sql: collecting messages from an SQL database network: Collecting messages using the RFC3164 protocol (network() driver) office365: Fetching logs from Office 365 osquery: Collect and parse osquery result logs pipe: Collecting messages from named pipes program: Receiving messages from external applications python: writing server-style Python sources python-fetcher: writing fetcher-style Python sources snmptrap: Read Net-SNMP traps syslog: Collecting messages using the IETF syslog protocol (syslog() driver) system: Collecting the system-specific log messages of a platform systemd-journal: Collecting messages from the systemd-journal system log storage systemd-syslog: Collecting systemd messages using a socket tcp, tcp6, udp, udp6: Collecting messages from remote hosts using the BSD syslog protocol udp-balancer: Receiving UDP messages at very high rate unix-stream, unix-dgram: Collecting messages from UNIX domain sockets windowsevent: Collecting Windows event logs
Sending and storing log messages — destinations and destination drivers
elasticsearch2: Sending messages directly to Elasticsearch version 2.0 or higher (DEPRECATED) elasticsearch-http: Sending messages to Elasticsearch HTTP Event Collector file: Storing messages in plain-text files google_pubsub: Sending logs to the Google Cloud Pub/Sub messaging service hdfs: Storing messages on the Hadoop Distributed File System (HDFS) http: Posting messages over HTTP kafka: Publishing messages to Apache Kafka logstore: Storing messages in encrypted files mongodb: Storing messages in a MongoDB database network: Sending messages to a remote log server using the RFC3164 protocol (network() driver) pipe: Sending messages to named pipes program: Sending messages to external applications python: writing custom Python destinations sentinel: Sending logs to the Microsoft Azure Sentinel cloud snmp: Sending SNMP traps smtp: Generating SMTP messages (email) from logs splunk-hec: Sending messages to Splunk HTTP Event Collector sql: Storing messages in an SQL database stackdriver: Sending logs to the Google Stackdriver cloud syslog: Sending messages to a remote logserver using the IETF-syslog protocol syslog-ng(): Forward logs to another syslog-ng node tcp, tcp6, udp, udp6: Sending messages to a remote log server using the legacy BSD-syslog protocol (tcp(), udp() drivers) unix-stream, unix-dgram: Sending messages to UNIX domain sockets usertty: Sending messages to a user terminal — usertty() destination Client-side failover
Routing messages: log paths, flags, and filters Global options of syslog-ng PE TLS-encrypted message transfer Advanced Log Transfer Protocol Reliability and minimizing the loss of log messages Manipulating messages parser: Parse and segment structured messages Processing message content with a pattern database Correlating log messages Enriching log messages with external data Monitoring statistics and metrics of syslog-ng Multithreading and scaling in syslog-ng PE Troubleshooting syslog-ng Best practices and examples The syslog-ng manual pages Glossary

The contents of the Google Pub/Sub Message attributes on the syslog-ng PE (syslog-ng PE) side

The syslog-ng PE application's google-pubsub() source collects Google Pub/Sub messages in a format that has two message parts (Message body and Message attributes) on the Google Cloud Platform side.

NOTE: Google Pub/Sub messages must contain at least one of the Message body and Message attributes message parts.

The contents of the message attributes can be customized with the prefix() option, where the prefix is .pubsub. by default.

The contents of the message attributes message part are key-value pairs, for example, ${.pubsub.attribute_name}.

Example: incoming Google Pub/Sub Cloud message contents (including message attributes), the resulting $MESSAGE macro contents and key-values, and processed output message contents with a prepended Message header

Incoming message contents on the Google Pub/Sub Cloud side:

<38>Feb 25 14:09:07 testhost testapp: test message - 1

Incoming attribute values to the message on the Google Pub/Sub Cloud side:

* attrib_name1="attrib_value1"
* attrib_name2="attrib_value2"

The contents and key-values of the relevant $MESSAGE macros:

* name='MESSAGE', value='<38>Feb 25 14:09:07 testhost testapp: test message - 1'
* attrib_name1="attrib_value1"
* attrib_name2="attrib_value2"

By default, the syslog-ng PE application prepends a Message header to the $MESSAGE macro contents to form an output with a similar structure:

<13>Sep 29 14:59:28 ubuntu-xenail-amd64 <38>Feb 25 14:09:07 testhost testapp: test message - 1

Processing incoming message contents in raw message format and in .JSON format

Depending on the format of your incoming message contents, and whether you want to forward these contents in .JSON format instead of a raw message format, you may have to filter, parse, or otherwise modify your incoming message contents.

The following examples illustrate what incoming message contents look like in raw message format and in .JSON message format, and how to handle and process message contents in .JSON format.

Processing incoming message contents in raw message format

If your incoming message contents are in a raw message format, and you do not filter or otherwise modify the contents, syslog-ng PE will automatically forward the contents in the same raw message format, and the output will look similar to this:

Example: incoming Google Pub/Sub Cloud message contents (in raw message format), the resulting $MESSAGE macro contents, and the processed output message contents with a prepended Message header

Incoming message contents in raw message format on the Google Pub/Sub Cloud side:

<38>Feb 25 14:09:07 testhost testapp: test message mytestmessage

The contents of the relevant $MESSAGE macros:

* name='MESSAGE', value='{"data":"<38>Feb 25 14:09:07 testhost testapp: test message mytestmessage"}'

By default, the syslog-ng PE application prepends a Message header to the $MESSAGE macro contents to form an output with a similar structure:

<13>Sep 29 17:03:58 ubuntu {"data":"<38>Feb 25 14:09:07 testhost testapp: test message mytestmessage"}\x0a

Processing incoming message contents in .JSON message format

The syslog-ng PE application's google-pubsub() source collects Google Pub/Sub messages in a format that has two message parts (Message body and Message attributes) on the Google Cloud Platform side.

However, depending on how you configure the Google Pub/Sub messaging service on the Platform side, you may receive incoming messages in .JSON format.

Configuring syslog-ng PE to process incoming .JSON message formats

Even if your incoming message contents are originally in .JSON format, syslog-ng PE will store them in a raw message format.

If you want to forward your message contents in a .JSON format along with message attributes, you can use format-json() as a rewrite rule or as a destination template.

Example: configuring syslog-ng PE to transform raw incoming message format to .JSON message format using format-json()

The following configuration example illustrates how you can use format-json() to configure syslog-ng PE to transform the raw message format of the incoming message to a .JSON format message that contains the contents of both the Message body and the Message attributes.

log {
  source {
    google-pubsub(project("syslog-ng-pubsub-src") subscription("sub") credentials("syslog-ng-pubsub-creds.json"));
  };

  if {
    parser { json-parser( prefix(".gpub.data.") template("$MESSAGE")); };
  }
  else {
    rewrite { set("$MESSAGE" value(".gpub.data")); };
  };

  destination {
    file("/tmp/output" template("$(format-json --key .pubsub.* --shift 8  --key .gpub.* --shift  6)\n"));
  };
};

In this case, the incoming message contents on the Google Pub/Sub Platform side are the following:

{"message_body_json_field1": "value1", "message_body_json_field2": "value2"}

The Pub/Sub attributes of the message are the following:

pubsubmsgattribute1
pubsubmsgattribute2

The output message looks like this:

{"pubsubmsgattribute2":"pubsubattrvalue2","pubsubmsgattribute1":"pubsubattrvalue1","data":{"message_body_json_field2":"value2","message_body_json_field1":"value1"}
Related Documents

The document was helpful.

Select Rating

I easily found the information I needed.

Select Rating