Tchater maintenant avec le support
Tchattez avec un ingénieur du support

syslog-ng Open Source Edition 3.38 - Administration Guide

Preface Introduction to syslog-ng The concepts of syslog-ng Installing syslog-ng The syslog-ng OSE quick-start guide The syslog-ng OSE configuration file source: Read, receive, and collect log messages
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 kubernetes: Collecting and parsing the Kubernetes CRI (Container Runtime Interface) format linux-audit: Collecting messages from Linux audit logs mqtt: receiving messages from an MQTT broker network: Collecting messages using the RFC3164 protocol (network() driver) nodejs: Receiving JSON messages from nodejs applications mbox: Converting local email messages to log messages osquery: Collect and parse osquery result logs pipe: Collecting messages from named pipes pacct: Collecting process accounting logs on Linux 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— OBSOLETE unix-stream, unix-dgram: Collecting messages from UNIX domain sockets stdin: Collecting messages from the standard input stream
destination: Forward, send, and store log messages
amqp: Publishing messages using AMQP collectd: sending metrics to collectd discord: Sending alerts and notifications to Discord elasticsearch2: Sending messages directly to Elasticsearch version 2.0 or higher (DEPRECATED) elasticsearch-http: Sending messages to Elasticsearch HTTP Bulk API file: Storing messages in plain-text files graphite: Sending metrics to Graphite Sending logs to Graylog hdfs: Storing messages on the Hadoop Distributed File System (HDFS) Posting messages over HTTP http: Posting messages over HTTP without Java kafka: Publishing messages to Apache Kafka (Java implementation) kafka-c(): Publishing messages to Apache Kafka using the librdkafka client (C implementation) loggly: Using Loggly logmatic: Using Logmatic.io mongodb(): Storing messages in a MongoDB database mqtt() destination: sending messages from a local network to an MQTT broker network: Sending messages to a remote log server using the RFC3164 protocol (network() driver) osquery: Sending log messages to osquery's syslog table pipe: Sending messages to named pipes program: Sending messages to external applications pseudofile() python: writing custom Python destinations redis: Storing name-value pairs in Redis riemann: Monitoring your data with Riemann slack: Sending alerts and notifications to a Slack channel smtp: Generating SMTP messages (email) from logs snmp: Sending SNMP traps Splunk: Sending log messages to Splunk sql: Storing messages in an SQL database stomp: Publishing messages using STOMP Sumo Logic destinations: sumologic-http() and sumologic-syslog() 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) Telegram: Sending messages to Telegram unix-stream, unix-dgram: Sending messages to UNIX domain sockets usertty: Sending messages to a user terminal: usertty() destination Write your own custom destination in Java or Python Client-side failover
log: Filter and route log messages using log paths, flags, and filters Global options of syslog-ng OSE TLS-encrypted message transfer template and rewrite: Format, modify, and manipulate log messages parser: Parse and segment structured messages
Parsing syslog messages Parsing messages with comma-separated and similar values Parsing key=value pairs JSON parser XML parser Parsing dates and timestamps Python parser Parsing tags Apache access log parser Linux audit parser Cisco parser Parsing enterprise-wide message model (EWMM) messages iptables parser Netskope parser panos-parser(): parsing PAN-OS log messages Sudo parser MariaDB parser Websense parser Fortigate parser Check Point Log Exporter parser Regular expression (regexp) parser db-parser: Process message content with a pattern database (patterndb)
Correlating log messages Enriching log messages with external data Statistics of syslog-ng Multithreading and scaling in syslog-ng OSE Troubleshooting syslog-ng Best practices and examples The syslog-ng manual pages Creative Commons Attribution Non-commercial No Derivatives (by-nc-nd) License The syslog-ng Open Source Edition Documentation License Glossary

Configuring syslog-ng relays

This section describes how to configure syslog-ng OSE as a relay.

Configuring syslog-ng on relay hosts

To configure syslog-ng on a relay host, complete the following steps:

  1. Install the syslog-ng application on the host. For details on installing syslog-ng on specific operating systems, see Installing syslog-ng.

  2. Configure the network sources that collect the log messages sent by the clients.

  3. Create a network destination that points to the syslog-ng server.

  4. Create a log statement connecting the network sources to the syslog-ng server.

  5. Configure the local sources that collect the log messages of the relay host.

  6. Create a log statement connecting the local sources to the syslog-ng server.

  7. Enable the keep-hostname() and disable the chain-hostnames() options. (For details on how these options work, see chain-hostnames().)

    NOTE: It is recommended to use these options on your syslog-ng OSE server as well.

  8. Set filters and options (for example, TLS encryption) as necessary.

    NOTE: By default, the syslog-ng server will treat the relayed messages as if they were created by the relay host, not the host that originally sent them to the relay. In order to use the original hostname on the syslog-ng server, use the keep-hostname(yes) option both on the syslog-ng relay and the syslog-ng server. This option can be set individually for every source if needed.

    If you are relaying log messages and want to resolve IP addresses to hostnames, configure the first relay to do the name resolution.

    Example: A simple configuration for relays

    The following is a simple configuration file that collects local and incoming log messages and forwards them to a logserver using the IETF-syslog protocol.

    @version: 3.38
    @include "scl.conf"
    options {
        time-reap(30);
        mark-freq(10);
        keep-hostname(yes);
        chain-hostnames(no);
    };
    source s_local {
        system(); internal();
    };
    source s_network {
        syslog(transport(tcp));
    };
    destination d_syslog_tcp {
        syslog("192.168.1.5" transport("tcp") port(2010));
    };
    log {
        source(s_local); source(s_network);
        destination(d_syslog_tcp);
    };

How relaying log messages works

Depending on your exact needs about relaying log messages, there are many scenarios and syslog-ng OSE options that influence how the log message will look like on the logserver. Some of the most common cases are summarized in the following example:

Consider the following example: client-host > syslog-ng-relay > syslog-ng-server, where the IP address of client-host is 192.168.1.2. The client-host device sends a syslog message to syslog-ng-relay. Depending on the settings of syslog-ng-relay, the following can happen.

  • By default, the keep-hostname() option is disabled, so syslog-ng-relay writes the IP address of the sender host (in this case, 192.168.1.2) to the HOST field of the syslog message, discarding any IP address or hostname that was originally in the message.

  • If the keep-hostname() option is enabled on syslog-ng-relay, but name resolution is disabled (the use-dns() option is set to no), syslog-ng-relay uses the HOST field of the message as-is, which is probably 192.168.1.2.

  • To resolve the 192.168.1.2 IP address to a hostname on syslog-ng-relay using a DNS server, use the keep-hostname(no) and use-dns(yes) options. If the DNS server is properly configured and reverse DNS lookup is available for the 192.168.1.2 address, syslog-ng OSE will rewrite the HOST field of the log message to client-host.

    NOTE: It is also possible to resolve IP addresses locally, without relying on the DNS server. For details on local name resolution, see Resolving hostnames locally.

  • The above points apply to the syslog-ng OSE server (syslog-ng-server) as well, so if syslog-ng-relay is configured properly, use the keep-hostname(yes) option on syslog-ng-server to retain the proper HOST field. Setting keep-hostname(no) on syslog-ng-server would result in syslog-ng OSE rewriting the HOST field to the address of the host that sent the message to syslog-ng-server, which is syslog-ng-relay in this case.

  • If you cannot or do not want to resolve the 192.168.1.2 IP address on syslog-ng-relay, but want to store your log messages on syslog-ng-server using the IP address of the original host (that is, client-host), you can enable the spoof-source() option on syslog-ng-relay. However, spoof-source() works only under the following conditions:

    • The syslog-ng OSE binary has been compiled with the --enable-spoof-source option.

    • The log messages are sent using the highly unreliable UDP transport protocol. (Extremely unrecommended.)

Managing and checking syslog-ng OSE service on Linux

This section describes how to start, stop and check the status of syslog-ng Open Source Edition (syslog-ng OSE) service on Linux.

Starting syslog-ng OSE

To start syslog-ng OSE, execute the following command as root.

Example: starting syslog-ng OSE

systemctl start syslog-ng

If the service starts successfully, no output will be displayed.

The following message indicates that syslog-ng OSE can not start (see Checking syslog-ng OSE status):

Job for syslog-ng.service failed because the control process exited with error code. See systemctl status syslog-ng.service and journalctl -xe for details.

Stopping syslog-ng OSE

To stop syslog-ng OSE

  1. Execute the following command as root.
    Example: command for stopping syslog-ng OSE

    systemctl stop syslog-ng

  2. Check the status of syslog-ng OSE service (see Checking syslog-ng OSE status).

Restarting syslog-ng OSE

To restart syslog-ng OSE, execute the following command as root.

Example: command for restarting syslog-ng OSE

systemctl restart syslog-ng

Reloading configuration file without restarting syslog-ng OSE

To reload the configuration file without restarting syslog-ng OSE, execute the following command as root.

Example: command for reloading the configuration file without restarting syslog-ng OSE

systemctl reload syslog-ng

Checking syslog-ng OSE status

To check the following status-related components, observe the suggestions below.

  • Checking the status of syslog-ng OSE service

    To check the status of syslog-ng OSE service

    1. Execute the following command as root.

      Example: command for checking the status of syslog-ng OSE service

      systemctl --no-pager status syslog-ng

    2. Check the Active: field, which shows the status of syslog-ng OSE service. The following statuses are possible:

      • active (running) - syslog-ng OSE service is up and running

        Example: syslog-ng OSE service active
        syslog-ng.service - System Logger Daemon
        Loaded: loaded (/lib/systemd/system/syslog-ng.service; enabled; vendor preset: enabled)
        Active: active (running) since Tue 2019-06-25 08:58:09 CEST; 5s ago
        Main PID: 6575 (syslog-ng)
        Tasks: 3
        Memory: 13.3M
        CPU: 268ms
        CGroup: /system.slice/syslog-ng.service
        6575 /opt/syslog-ng/libexec/syslog-ng -F --no-caps --enable-core
      • inactive (dead) - syslog-ng service is stopped

        Example: syslog-ng OSE status inactive
        syslog-ng.service - System Logger Daemon
        Loaded: loaded (/lib/systemd/system/syslog-ng.service; enabled; vendor preset: enabled)
        Active: inactive (dead) since Tue 2019-06-25 09:14:16 CEST; 2min 18s ago
        Process: 6575 ExecStart=/opt/syslog-ng/sbin/syslog-ng -F --no-caps --enable-core $SYSLOGNG_OPTIONS (code=exited, status=0/SUCCESS)
        Main PID: 6575 (code=exited, status=0/SUCCESS)
        Status: "Shutting down... Tue Jun 25 09:14:16 2019"
        Jun 25 09:14:31 as-syslog-srv systemd: Stopped System Logger Daemon.
  • Checking the process of syslog-ng OSE

    To check the process of syslog-ng OSE, execute one of the following commands.

    • Example: command ps u `pidof syslog-ng`

      ps u `pidof syslog-ng`

      Expected output example:

      USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND

      syslogng 6709 0.0 0.6 308680 13432 ? Ss 09:17 0:00 /opt/syslog-ng/libexec/syslog-ng -F --no-caps --enable-core

    • Example: command ps axu | grep syslog-ng | grep -v grep

      ps axu | grep syslog-ng | grep -v grep

      Expected output example:

      syslogng 6709 0.0 0.6 308680 13432 ? Ss 09:17 0:00 /opt/syslog-ng/libexec/syslog-ng -F --no-caps --enable-core

  • Checking the internal logs of syslog-ng OSE

    The internal logs of syslog-ng OSE contains informal, warning and error messages.

    By default, syslog-ng OSE log messages (generated on the internal() source) are written to /var/log/messages.

    Check the internal logs of syslog-ng OSE for any issue.

  • Message processing

    The syslog-ng OSE application collects statistics about the number of processed messages on the different sources and destinations.

    NOTE: When using syslog-ng-ctl stats, consider that while the output is generally consistent, there is no explicit ordering behind the command. Consequently, One Identity does not recommend creating parsers that depend on a fix output order.

    If needed, you can sort the output with an external application, for example, | sort.

    • Central statistics

      To check the central statistics, execute the following command to see the number of received and queued (sent) messages by syslog-ng OSE.

      Example: command for checking central statistics

      watch "/opt/syslog-ng/sbin/syslog-ng-ctl stats | grep ^center"

      The output will be updated in every 2 seconds.

      If the numbers are changing, syslog-ng OSE is processing the messages.

      Example: output example
      Every 2.0s: /opt/syslog-ng/sbin/syslog-ng-ctl stats | grep ^center       Tue Jun 25 10:33:25 2019
      center;;queued;a;processed;112
      center;;received;a;processed;28
    • Source statistics

      To check the source statistics, execute the following command to see the number of received messages on the configured sources.

      Example: command for checking central statistics

      watch "/opt/syslog-ng/sbin/syslog-ng-ctl stats | grep ^source"

      The output will be updated in every 2 seconds.

      If the numbers are changing, syslog-ng OSE is receiving messages on the sources.

      Example: output example
      Every 2.0s: /opt/syslog-ng/sbin/syslog-ng-ctl stats | grep ^source      Tue Jun 25 10:40:50 2019
      source;s_null;;a;processed;0
      source;s_net;;a;processed;0
      source;s_local;;a;processed;90
    • Destination statistics

      To check the source statistics, execute the following command to see the number of received messages on the configured sources.

      Example: command for checking destination statistics

      watch "/opt/syslog-ng/sbin/syslog-ng-ctl stats | grep ^source"

      The output will be updated in every 2 seconds.

      If the numbers are changing, syslog-ng OSE is receiving messages on the sources.

      Example: output example
      Every 2.0s: /opt/syslog-ng/sbin/syslog-ng-ctl stats | grep ^destination      Tue Jun 25 10:41:02 2019
      destination;d_logserver2;;a;processed;90
      destination;d_messages;;a;processed;180
      destination;d_logserver;;a;processed;90
      destination;d_null;;a;processed;0

NOTE:If you find error messages in the internal logs, messages are not processed by syslog-ng OSE or you encounter any issue, you have the following options:

Documents connexes

The document was helpful.

Sélectionner une évaluation

I easily found the information I needed.

Sélectionner une évaluation