Chatta subito con l'assistenza
Chat con il supporto

syslog-ng Premium Edition 7.0.33 - 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 google_pubsub-managedaccount(): Sending logs to the Google Cloud Pub/Sub messaging service authenticated by Google Cloud managed service account hdfs: Storing messages on the Hadoop Distributed File System (HDFS) http: Posting messages over HTTP kafka(): Publishing messages to Apache Kafka (Java implementation) (DEPRECATED) kafka-c(): Publishing messages to Apache Kafka using the librdkafka client (C implementation) 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 Transport 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

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"}

google-pubsub() source options

The google-pubsub() source has the following options.

Required parameters
  • credentials()

  • project()

  • subscription()

Optional parameters
  • ack-tracker-batch-size()

  • ack-tracker-timeout()

  • log-fetch-limit()

  • prefix()

  • time-reopen()

  • workers()

The google-pubsub() source options, in more detail:

ack-tracker-batch-size()
Type: string
Default: 100
Required: no

Description: Optional parameter.

The syslog-ng PE application retains acknowledgements on the source side and either acknowledges an ack-tracker-batch-size() number of messages in a batch, or sends acknowledgements after the ack-tracker-timeout() expires. If the value of your ack-tracker-timeout() is larger than the value of your Acknowledgement deadline, it may result in message duplication.

ack-tracker-timeout()
Type: time [milliseconds]
Default: 3000
Required: no

Description: Optional parameter.

The syslog-ng PE application retains acknowledgements on the source side and either acknowledges an ack-tracker-batch-size() number of messages in a batch, or sends acknowledgements after the ack-tracker-timeout() expires. If the value of your ack-tracker-timeout() is larger than the value of your Acknowledgement deadline, it may result in message duplication.

credentials()
Type: string
Default: n/a
Required: yes

Description: Required parameter.

The credentials of your Google Pub/Sub project.

log-fetch-limit()
Type: number
Default: 100
Required: no

Description: Optional parameter.

The maximum number of messages fetched from a source during a single poll loop.

prefix()
Type: string
Default: .pubsub.
Required: no

Description: Optional parameter.

This prefix will be added to the name of the macros created from the message attributes of the Google Pub/Sub message.

project()
Type: string
Default: n/a
Required: yes

Description: Required parameter.

The ID of your Google Pub/Sub project.

subscription()
Type: string
Default: n/a
Required: yes

Description: Required parameter.

The ID of your Google Pub/Sub subscription.

time-reopen()
Type: number (seconds)
Default: 60
Required: no

Description: Optional parameter.

The time to wait in seconds before a broken connection is reestablished.

workers()
Type: integer
Default: 1
Required: no

Description: Optional parameter.

Specifies the number of worker threads (at least 1) that syslog-ng PE uses to receive messages from the Google Pub/Sub messaging service. Increasing the number of worker threads can drastically improve the performance of the destination.

Related Documents

The document was helpful.

Seleziona valutazione

I easily found the information I needed.

Seleziona valutazione