Chat now with support
Chat with Support

syslog-ng Premium Edition 7.0.12 - Administration Guide

Preface Introduction to syslog-ng The concepts of syslog-ng Installing syslog-ng 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 wildcard-file: Collecting messages from multiple text files network: Collecting messages using the RFC3164 protocol (network() driver) 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 sun-streams: Collecting messages on Sun Solaris 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 unix-stream, unix-dgram: Collecting messages from UNIX domain sockets windowsevent: Collecting Windows event logs
Sending and storing log messages — destinations and destination drivers
elasticsearch: Sending messages directly to Elasticsearch version 1.x elasticsearch2: Sending messages directly to Elasticsearch version 2.0 or higher file: Storing messages in plain-text files 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 smtp: Generating SMTP messages (e-mail) from logs splunk-hec: Sending messages to Splunk HTTP Event Collector sql: Storing messages in an SQL database syslog: Sending messages to a remote logserver using the IETF-syslog protocol syslog-ng: Forwarding messages and tags 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 About us

The monitoring() source

The monitoring() source allows you to select which statistics of syslog-ng PE you want to monitor. In addition, the statistics are available as structured name-value pairs, so you can format the output similarly to other log messages. That way, you can easily convert the statistics and metrics, for example, into JSON or WELF format. That way, you can send the statistics of your log messages into a monitoring solution.

The monitoring() source queries the statistics (counters) that syslog-ng PE collects, formats them, and optionally resets the counters. The monitoring() source emits only these messages, making it easy to route them to their appropriate destination. The stats-level() global option determines exactly which statistics syslog-ng PE collects.

Declaration:
source s_monitor{
    monitoring(
        query("*")
    );};
Example: Save all statistics into a file in JSON format

The following configuration increases the stats-level() option to 3, and generates a JSON-formatted message every 10 seconds. The generated message contains every available statistics, and is saved into the /var/log/syslog-ng-statistics.log file.

@version: 7.0
options{
    stats-level(3);
    keep-hostname(no);
};
source s_monitor{ monitoring(
    query("*")
    freq(10)
    message-template('$(format-json --scope nv_pairs)')
    );};
destination d_file {
    file("/var/log/syslog-ng-statistics.log");
};
log {
    source(s_monitor);
    destination(d_file);
};

The generated message is similar to this one:

[2017-04-03T14:00:31.786133] Outgoing message; message='Apr  3 14:00:31 example-hostname syslog-ng[12281]: {"src":{"severity":{"7":{"processed":"0"},"6":{"processed":"0"},"5":{"processed":"0"},"4":{"processed":"0"},"3":{"processed":"0"},"2":{"processed":"0"},"1":{"processed":"0"},"0":{"processed":"0"}},"monitoring":{"s_monitor#0":{"stamp":"0","processed":"0"}},"facility":{"other":{"processed":"0"},"9":{"processed":"0"},"8":{"processed":"0"},"7":{"processed":"0"},"6":{"processed":"0"},"5":{"processed":"0"},"4":{"processed":"0"},"3":{"processed":"0"},"23":{"processed":"0"},"22":{"processed":"0"},"21":{"processed":"0"},"20":{"processed":"0"},"2":{"processed":"0"},"19":{"processed":"0"},"18":{"processed":"0"},"17":{"processed":"0"},"16":{"processed":"0"},"15":{"processed":"0"},"14":{"processed":"0"},"13":{"processed":"0"},"12":{"processed":"0"},"11":{"processed":"0"},"10":{"processed":"0"},"1":{"processed":"0"},"0":{"processed":"0"}}},"source":{"s_monitor":{"processed":"0"}},"global":{"sdata_updates":{"processed":"0"},"payload_reallocs":{"processed":"2"},"msg_clones":{"processed":"0"}},"destination":{"d_file":{"processed":"0"}},"center":{"received":{"processed":"0"},"queued":{"processed":"0"}},"PROGRAM":"syslog-ng","PID":"12281"}\x0a'

For reference, the JSON part in a readable format is:

{
  "center" : {
      "queued" : { "processed" : "0" },
      "received" : { "processed" : "0" }
    },
  "destination" : { "d_file" : { "processed" : "0" } },
  "global" : {
      "msg_clones" : { "processed" : "0" },
      "payload_reallocs" : { "processed" : "2" },
      "sdata_updates" : { "processed" : "0" }
    },
  "PID" : "12281",
  "PROGRAM" : "syslog-ng",
  "source" : { "s_monitor" : { "processed" : "0" } },
  "src" : {
      "facility" : {
          "0" : { "processed" : "0" },
          "1" : { "processed" : "0" },
          "2" : { "processed" : "0" },
          "3" : { "processed" : "0" },
          "4" : { "processed" : "0" },
          "5" : { "processed" : "0" },
          "6" : { "processed" : "0" },
          "7" : { "processed" : "0" },
          "8" : { "processed" : "0" },
          "9" : { "processed" : "0" },
          "10" : { "processed" : "0" },
          "11" : { "processed" : "0" },
          "12" : { "processed" : "0" },
          "13" : { "processed" : "0" },
          "14" : { "processed" : "0" },
          "15" : { "processed" : "0" },
          "16" : { "processed" : "0" },
          "17" : { "processed" : "0" },
          "18" : { "processed" : "0" },
          "19" : { "processed" : "0" },
          "20" : { "processed" : "0" },
          "21" : { "processed" : "0" },
          "22" : { "processed" : "0" },
          "23" : { "processed" : "0" },
          "other" : { "processed" : "0" }
        },
      "monitoring" : { "s_monitor#0" : {
              "processed" : "0",
              "stamp" : "0"
            } },
      "severity" : {
          "0" : { "processed" : "0" },
          "1" : { "processed" : "0" },
          "2" : { "processed" : "0" },
          "3" : { "processed" : "0" },
          "4" : { "processed" : "0" },
          "5" : { "processed" : "0" },
          "6" : { "processed" : "0" },
          "7" : { "processed" : "0" }
        }
    }
}
Related Documents