The snmp()
driver sends SNMP traps using the Simple Network Management Protocol version 2c or version 3. Incoming log messages can be converted to SNMP traps, as the fields of the SNMP messages can be customized using syslog-ng PE macros.
|
NOTE:
The |
The snmp()
driver requires the host()
, trap-obj()
, and snmp-obj()
options to be set, as well as the engine-id()
option in case the SNMPv3 protocol is used. For the list of available optional parameters, see the section called “snmp() destination options”.
Declaration:
@module snmp destination d_snmp {snmp(host() trap-obj() snmp-obj() ...);};
By default, syslog-ng PE does not load the snmp()
module. If you want to use the snmp()
destination, include the following line in your syslog-ng PE configuration file before defining the destination to load the snmp()
module. This line is needed only once, even if you use multiple SNMP destinations. For details on modules, see the section called “Loading modules”.
@module snmp
|
Caution:
If syslog-ng PE cannot resolve the destination hostname during startup, it will try to resolve the hostname again when the next message to be sent as an SNMP trap is received. However, if this name resolution fails, the trap will be dropped. |
|
NOTE:
The |
Example 7.31. Using the snmp() destination driver
The following example defines an SNMP destination that uses the SNMPv2c protocol.
@module snmp destination d_snmpv2c{ snmp( version('v2c') host('192.168.1.1') trap-obj('.1.3.6.1.6.3.1.1.4.1.0', 'Objectid', '.1.3.6.1.4.1.18372.3.1.1.1.2.1') snmp-obj('.1.3.6.1.4.1.18372.3.1.1.1.1.1.0', 'Octetstring', 'Test SNMP trap') snmp-obj('.1.3.6.1.4.1.18372.3.1.1.1.1.2.0', 'Octetstring', 'admin') snmp-obj('.1.3.6.1.4.1.18372.3.1.1.1.1.3.0', 'Ipaddress', '192.168.1.1') ); };
The following example defines an SNMP destination that uses the SNMPv3 protocol and uses macros to fill the values of the SNMP objects.
@module snmp destination d_snmpv3{ snmp( version('v3') host('192.168.1.1') port(162) engine-id('0xdeadbeefde') auth-username('myusername') auth-password('password') enc-algorithm('AES') enc-password('password') trap-obj('.1.3.6.1.6.3.1.1.4.1.0', 'Objectid', '.1.3.6.1.4.1.18372.3.1.1.1.2.1') snmp-obj('.1.3.6.1.4.1.18372.3.1.1.1.1.1', 'Octetstring', '${MESSAGE}') snmp-obj('.1.3.6.1.4.1.18372.3.1.1.1.1.2', 'Octetstring', 'admin') snmp-obj('.1.3.6.1.4.1.18372.3.1.1.1.1.3', 'Ipaddress', '${SOURCEIP}') ); };
Starting with version 4 F1, syslog-ng PE can convert the syslog messages sent by Cisco devices to Cisco-specific SNMP traps defined by the CISCO-SYSLOG-MIB (enterprises.cisco.ciscoMgmt.ciscoCiscoMIB
) is also supported (such traps are also referred to as clogMessageGenerated
notifications). That way, the incoming log messages can be forwarded to devices used to process and analyze Cisco-specific SNMP traps. For this to work correctly, the following requirements must be met:
The snmp module of syslog-ng PE must be loaded, that is, the syslog-ng PE configuration file must include the following line:
@module snmp
The syslog-ng Source Configuration Library (SCL) must be included in the syslog-ng PE configuration file:
@include "scl.conf"
The pattern database described in the section called “Parsing Cisco-specific message fields with patterndb” must be used to parse the incoming log messages.
To accomplish this, syslog-ng PE has to use a special pattern database to parse the Cisco-specific syslog messages, because these messages do not comply with the standard syslog formats.
For details on the Cisco-specific SNMP trap format, see CISCO-SYSLOG-MIB on the Cisco website.
The ${PROGRAM}
part of the syslog messages sent by Cisco devices contain not only the program name, but other important protocol information part as well. The ${PROGRAM}
of these messages contains the Facility, Severity, and the Mnemonic (the Cisco name) of the message. The following pattern database parses these values and makes them available as the .cisco.Facility
, .cisco.Severity
, and .cisco.MsgName
, respectively. The actual log message is available as .cisco.MsgText
.
<patterndb version="4" pub_date="2011-05-03"> <ruleset name="cisco snmp ruleset1" xml:id="480de478-d4a6-4a7f-bea4-0c0245d361e3"> <description>Pattern for Cisco messages having BSD timestamps, for example: Jul 01 2010 00:32:59: %SYS-5-CONFIG_I: Configured from console by console</description> <url>http://balabit.com</url> <pattern>%@ESTRING:.cisco.Facility:-@@ESTRING:.cisco.Severity:-@@ANYSTRING:.cisco.MsgName@</pattern> <rules> <rule xml:id="09944c71-95eb-4bc0-8575-936931d85713" provider="balabit" class="system"> <patterns> <pattern> @ANYSTRING:.cisco.MsgText@</pattern> </patterns> </rule> </rules> </ruleset> <ruleset name="cisco snmp ruleset2" xml:id="480de478-d4a6-4a7f-bea4-0c0245d361e3"> <description>Pattern for Cisco messages having cisco-specific timestamps, for example: 18: Jan 22 10:45:44.543: %SYS-5-CONFIG_I: Configured from console by console</description> <url>http://balabit.com</url> <rules> <rule xml:id="09944c71-95eb-4bc0-8575-936931d85714" provider="balabit" class="system"> <patterns> <pattern>%@ESTRING:.cisco.Facility:-@@ESTRING:.cisco.Severity:-@@ESTRING:.cisco.MsgName::@ @ANYSTRING:.cisco.MsgText@</pattern> </patterns> </rule> </rules> </ruleset></patterndb>
To send out clogMessageGenerated SNMP traps, use the cisco_snmp()
destination driver. The cisco-snmp()
destination is actually a modified version of the snmp()
destination driver.
|
NOTE:
The |
The cisco-snmp()
driver has the same requirements and options as the snmp()
destination driver, but automatically fills the clogMessageGenerated-specific fields with the data received from parsing the Cisco-specific syslog messages using the pattern database. For details on the , see the <INSTALLDIR>/ share/include/scl/snmp/plugin.conf
file.
Declaration:
destination d_cisco_snmp {cisco-snmp(host(<hostname>));};
Example 7.32. Defining a Cisco-specific SNMP destination
The following example defines an SNMP destination that sends out clogMessageGenerated messages using the SNMPv3 protocol.
destination d_cisco_snmp {cisco-snmp(host("192.168.1.1") version("v3") engine-id("'0xdeadbeefde'") auth-username('myusername') auth-password('password') enc-password('password'));};
This driver sends SNMP traps using the SNMP v2c or v3 protocol.
The snmp()
destination has the following options:
Type: | SHA|sha |
Default: | SHA |
Description: The authentication method to use. Lowercase values (for example, sha
) can be used as well.
This option is used with the SNMPv3 protocol.
Type: | string |
Default: | empty string |
Description: The password used for authentication. If the auth-username()
option is set but the auth-password()
is empty, syslog-ng PE will try to authenticate with an empty password.
This option is used with the SNMPv3 protocol.
Type: | string |
Default: |
Description: The username used to authenticate on the SNMP server. If this parameter is set, syslog-ng PE will try to authenticate on the SNMP server.
This option is used with the SNMPv3 protocol.
Type: | string |
Default: | public |
Description: The community string used for SNMPv2c authentication.
This option is used with the SNMPv2c protocol.
Type: | AES|aes |
Default: | AES |
Description: The encryption method used to encrypt the SNMP traffic. Lowercase values (for example, aes
) can be used as well.
This option is used with the SNMPv3 protocol.
Type: | string |
Default: |
Description: The password used for the encryption. Encryption is used only if the enc-password()
is not empty.
This option is used with the SNMPv3 protocol.
Type: | number (hexadecimal number) |
Default: |
Description: The engine ID is a hexadecimal number at least 32 digits long, starting with 0x
. For example 0xABABABABABABABABABABABABABABABABABABABAB
.
This option is a required parameter when using the SNMPv3 protocol.
Type: | number (messages) |
Default: | Use global setting. |
Description: The number of messages that the output queue can store.
Type: | <oid_of_the_object>, <type_of_the_object>, <value_of_the_object> |
Default: |
Description: The snmp-obj()
option can be used to create custom SNMP trap elements. To create a trap element, specify the OID, type, and value of the element in the snmp-obj()
option. To send SNMP traps, at least one snmp-obj()
option must be defined. The snmp-obj()
option requires the following parameters. Note that syslog-ng PE does not validate the values of these elements.
<oid_of_the_object>
: The object id of the SNMP object, for example, .1.3.6.1.4.1.18372.3.1.1.1.1.1
.
<type_of_the_object>
: The type of the object specified as an ASN.1 primitive. One of: Integer, Timeticks, Octetstring, Counter32, Ipaddress, Objectid
. The type names are not case sensitive.
<value_of_the_object>
: The value of the object as a string. The macros of syslog-ng PE can be used to set these values, making it possible to transfer the content and other metadata from the the syslog message to the SNMP trap. Note that if the value of an Integer, Counter32
or Timeticks
object is not a number (for example, is an empty string or other not-number string), syslog-ng PE will automatically replace the value with 0. The values of other types of objects are not validated.
Example 7.33. Defining SNMP objects
The following are SNMP object definitions:
snmp-obj('.1.3.6.1.4.1.18372.3.1.1.1.1.3', 'Ipaddress', '192.168.1.1')
snmp-obj('.1.3.6.1.4.1.18372.3.1.1.1.1.2', 'Octetstring', '${MESSAGE}')
Type: | name of the timezone, or the timezone offset |
Default: | unspecified |
Description: Convert timestamps to the timezone specified by this option. If this option is not set, then the original timezone information in the message is used. Converting the timezone changes the values of all date-related macros derived from the timestamp, for example, HOUR
. For the complete list of such macros, see the section called “Date-related macros”.
The timezone can be specified as using the name of the (for example time-zone("Europe/Budapest")
), or as the timezone offset in +/-HH:MM format (for example +01:00
). On Linux and UNIX platforms, the valid timezone names are listed under the /usr/share/zoneinfo
directory.
Type: | <oid_of_the_object>, "Objectid", <value_of_the_object> |
Default: |
Description: The trap-obj()
is a specialized version of the snmp-obj()
option that is used to identify the SNMP trap object. The type of the trap object is always Objectid
. The <oid_of_the_object>
and the <value_of_the_object>
parameters are identical to the respective parameters of the snmp-obj()
option. For details on these parameters, see the section called “snmp-obj()”.
Type: | v2c|v3 |
Default: | v2c |
Description: Specifies which version of the SNMP protocol to use.
The syslog()
driver sends messages to a remote host (for example a syslog-ng server or relay) on the local intranet or internet using the new standard syslog protocol developed by IETF (for details about the new protocol, see the section called “IETF-syslog messages”). The protocol supports sending messages using the UDP, TCP, or the encrypted TLS networking protocols.
The required arguments of the driver are the address of the destination host (where messages should be sent). The transport method (networking protocol) is optional, syslog-ng uses the TCP protocol by default. For the list of available optional parameters, see the section called “syslog() destination options”.
Declaration:
syslog(host transport [options]);
|
NOTE:
Note that the |
The udp
transport method automatically sends multicast packets if a multicast destination address is specified. The tcp
and tls
methods do not support multicasting.
|
NOTE:
The default ports for the different transport protocols are as follows: UDP — 514, TCP — 601, TLS — 6514. |
Example 7.41. Using the syslog() driver
destination d_tcp { syslog("10.1.2.3" transport("tcp") port(1999) localport(999)); };
If name resolution is configured, the hostname of the target server can be used as well.
destination d_tcp { syslog("target_host" transport("tcp") port(1999) localport(999)); };
Send the log messages using TLS encryption and use mutual authentication. For details on the encryption and authentication options, see the section called “TLS options”.
destination d_syslog_tls{ syslog("10.100.20.40" transport("tls") port(6514) tls(peer-verify(required-trusted) ca-dir('/opt/syslog-ng/etc/syslog-ng/keys/ca.d/') key-file('/opt/syslog-ng/etc/syslog-ng/keys/client_key.pem') cert-file('/opt/syslog-ng/etc/syslog-ng/keys/client_certificate.pem') ) ); };
|
NOTE:
If a message uses the IETF-syslog format (RFC5424), only the text of the message can be customized (that is, the $MESSAGE part of the log), the structure of the header is fixed. |
The syslog()
driver sends messages to a remote host (for example a syslog-ng server or relay) on the local intranet or internet using the RFC5424 syslog protocol developed by IETF (for details about the protocol, see the section called “IETF-syslog messages”). The protocol supports sending messages using the RLTP™, UDP, TCP, or the encrypted TLS networking protocols.
These destinations have the following options:
Description: This option enables putting outgoing messages into the disk buffer of the destination to avoid message loss in case of a system failure on the destination side. It has the following options:
reliable() | |
Type: | yes|no |
Default: | no |
Description: If set to |
disk-buf-size() | |
Type: | number (bytes) |
Default: | |
Description: This is a required option. The maximum size of the disk-buffer in bytes. The minimum value is 1048576 bytes. If you set a smaller value, the minimum value will be used automatically. It replaces the old log-disk-fifo-size() option. |
mem-buf-length() | |
Type: | number (messages) |
Default: | 10000 |
Description: Use this option if the option reliable() is set to no . This option contains the number of messages stored in overflow queue. It replaces the old log-fifo-size() option. It inherits the value of the global log-fifo-size() option if provided. If it is not provided, the default value is 10000 messages. Note that this option will be ignored if the option reliable() is set to yes . |
mem-buf-size() | |
Type: | number (bytes) |
Default: | 163840000 |
Description: Use this option if the option reliable() is set to yes . This option contains the size of the messages in bytes that is used in the memory part of the disk buffer. It replaces the old log-fifo-size() option. It does not inherit the value of the global log-fifo-size() option, even if it is provided. Note that this option will be ignored if the option reliable() is set to no . |
quot-size() | |
Type: | number (messages) |
Default: | 64 |
Description: The number of messages stored in the output buffer of the destination. |
Options reliable()
and disk-buf-size()
are required options.
Example 7.42. Examples for using disk-buffer()
In the following case reliable disk-buffer() is used.
destination d_demo { network( "127.0.0.1" port(3333) disk-buffer( mem-buf-size(10000) disk-buf-size(2000000) reliable(yes) dir("/tmp/disk-buffer") ) ); };
In the following case normal disk-buffer() is used.
destination d_demo { network( "127.0.0.1" port(3333) disk-buffer( mem-buf-length(10000) disk-buf-size(2000000) reliable(no) dir("/tmp/disk-buffer") ) ); };
Type: | list of IP addresses and fully-qualified domain names |
Default: | 0 |
Description: Available only in syslog-ng Premium Edition version 3.2 and later. Specifies a secondary destination server where log messages are sent if the primary server becomes unaccessible. To list several failover servers, separate the address of the servers with comma. The time syslog-ng PE waits for the a server before switching to the next failover server is set in the time-reopen()
option. For details about how client-side failover works, see the section called “Client-side failover”.
|
Caution:
The failover servers must be accessible on the same port as the primary server. |
|
NOTE:
This option is not available for the connection-less UDP protocol, because in this case the client does not detect that the destination becomes unaccessible. |
Example 7.43. Specifying failover servers for syslog() destinations
The following example specifies two failover servers for a simple syslog() destination.
destination d_syslog_tcp{ syslog("10.100.20.40" transport("tcp") port(6514) failover-servers("10.2.3.4", "myfailoverserver") );};
The following example specifies a failover server for a network() destination that uses TLS encryption.
destination d_syslog_tls{ network("10.100.20.40" transport("tls") port(6514) failover-servers("10.2.3.4", "myfailoverserver") tls(peer-verify(required-trusted) ca-dir('/opt/syslog-ng/etc/syslog-ng/keys/ca.d/') key-file('/opt/syslog-ng/etc/syslog-ng/keys/client_key.pem') cert-file('/opt/syslog-ng/etc/syslog-ng/keys/client_certificate.pem')) );};
Type: | no_multi_line, syslog-protocol |
Default: | empty set |
Description: Flags influence the behavior of the destination driver.
no-multi-line: The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line.
syslog-protocol: The syslog-protocol
flag instructs the driver to format the messages according to the new IETF syslog protocol standard (RFC5424), but without the frame header. If this flag is enabled, macros used for the message have effect only for the text of the message, the message header is formatted to the new standard. Note that this flag is not needed for the syslog
driver, and that the syslog
driver automatically adds the frame header to the messages.
Type: | number (messages) |
Default: | Use global setting. |
Description: Specifies how many lines are sent to a destination at a time. The syslog-ng PE application waits for this number of lines to accumulate and sends them off in a single batch. Setting this number high increases throughput as fully filled frames are sent to the destination, but also increases message latency.
For optimal performance when sending messages to an syslog-ng PE server, make sure that the flush-lines()
is smaller than the window size set using the log-iw-size()
option in the source of your server.
Type: | time in milliseconds |
Default: | Use global setting. |
Description: This is an obsolete option. Specifies the time syslog-ng waits for lines to accumulate in its output buffer. For details, see the flush-lines()
option.
|
NOTE:
This option will be removed from the list of acceptable options. After that, your configuration will become invalid if it still contains the |
Type: | number (digits of fractions of a second) |
Default: | Value of the global option (which defaults to 0) |
Description: The syslog-ng application can store fractions of a second in the timestamps according to the ISO8601 format. The frac-digits()
parameter specifies the number of digits stored. The digits storing the fractions are padded by zeros if the original timestamp of the message specifies only seconds. Fractions can always be stored for the time the message was received. Note that syslog-ng can add the fractions to non-ISO8601 timestamps as well.
Type: | number (type of service) |
Default: | 0 |
Description: Specifies the Type-of-Service value of outgoing packets.
Type: | yes or no |
Default: | yes |
Description: Specifies whether connections to destinations should be closed when syslog-ng is reloaded. Note that this applies to the client (destination) side of the syslog-ng connections, server-side (source) connections are always reopened after receiving a HUP signal unless the keep-alive
option is enabled for the source.
Type: | number (port number) |
Default: | 0 |
Description: The port number to bind to. Messages are sent from this port.
Type: | number (messages) |
Default: | Use global setting. |
Description: The number of messages that the output queue can store.
Accepted values: | number (seconds) |
Default: | 1200 |
Description: An alias for the obsolete mark()
option, retained for compatibility with syslog-ng version 1.6.x. The number of seconds between two MARK
messages. MARK
messages are generated when there was no message traffic to inform the receiver that the connection is still alive. If set to zero (0
), no MARK
messages are sent. The mark-freq()
can be set for global option and/or every MARK
capable destination driver if mark-mode()
is periodical or dst-idle or host-idle. If mark-freq()
is not defined in the destination, then the mark-freq()
will be inherited from the global options. If the destination uses internal mark-mode()
, then the global mark-freq()
will be valid (does not matter what mark-freq()
set in the destination side).
Accepted values: | internal | dst-idle | host-idle | periodical | none | global |
Default: |
|
Description: The mark-mode()
option can be set for the following destination drivers: file(), program(), unix-dgram(), unix-stream(), network(), pipe(), syslog() and in global option.
internal
: When internal mark mode is selected, internal source should be placed in the log path as this mode does not generate mark by itself at the destination. This mode only yields the mark messages from internal source. This is the mode as syslog-ng PE 3.x worked. MARK
will be generated by internal source if there was NO traffic on local sources:
file()
, pipe()
, unix-stream()
, unix-dgram()
, program()
dst-idle
: Sends MARK
signal if there was NO traffic on destination drivers. MARK
signal from internal source will be dropped.
MARK
signal can be sent by the following destination drivers: network()
, syslog()
, program()
, file()
, pipe()
, unix-stream()
, unix-dgram()
.
host-idle
: Sends MARK
signal if there was NO local message on destination drivers. For example MARK
is generated even if messages were received from tcp. MARK
signal from internal source will be dropped.
MARK
signal can be sent by the following destination drivers: network()
, syslog()
, program()
, file()
, pipe()
, unix-stream()
, unix-dgram()
.
periodical
: Sends MARK
signal perodically, regardless of traffic on destination driver. MARK
signal from internal source will be dropped.
MARK
signal can be sent by the following destination drivers: network()
, syslog()
, program()
, file()
, pipe()
, unix-stream()
, unix-dgram()
.
none
: Destination driver drops all MARK
messages. If an explicit mark-mode() is not given to the drivers where none
is the default value, then none
will be used.
global
: Destination driver uses the global mark-mode()
setting. The syslog-ng interprets syntax error if the global mark-mode()
is global.
|
NOTE:
In case of |
Available in syslog-ng PE 4 LTS and later.
Type: | number (port number) |
Default: |
UDP — 514, TCP — 601, TLS — 6514. |
Description: The port number to connect to.
Type: | yes or no |
Default: | no |
Description: This option controls the SO_BROADCAST
socket option required to make syslog-ng send messages to a broadcast address. For details, see the socket(7) manual page.
Type: | yes or no |
Default: | no |
Description: Enables keep-alive messages, keeping the socket open. This only effects TCP and UNIX-stream sockets. For details, see the socket(7) manual page.
Type: | number (bytes) |
Default: | 0 |
Description: Specifies the size of the socket receive buffer in bytes. For details, see the socket(7) manual page.
Type: | number (bytes) |
Default: | 0 |
Description: Specifies the size of the socket send buffer in bytes. For details, see the socket(7) manual page.
Type: | yes or no |
Default: | no |
Description: Enables source address spoofing. This means that the host running syslog-ng generates UDP packets with the source IP address matching the original sender of the message. This is useful when you want to perform some kind of preprocessing via syslog-ng, then forward messages to your central log management solution with the source address of the original sender. This option only works for UDP destinations, though the original message can be received by TCP as well.
Type: | seconds |
Default: | 0 (disabled) |
Description: If several identical log messages would be sent to the destination without any other messages between the identical messages (for example, an application repeated an error message ten times), syslog-ng can suppress the repeated messages and send the message only once, followed by the Last message repeated n times.
message. The parameter of this option specifies the number of seconds syslog-ng waits for identical messages.
Type: | string |
Default: | A format conforming to the default logfile format. |
Description: Specifies a template defining the logformat to be used in the destination. Macros are described in the section called “Macros of syslog-ng PE”. Please note that for network destinations it might not be appropriate to change the template as it changes the on-wire format of the syslog protocol which might not be tolerated by stock syslog receivers (like syslogd
or syslog-ng itself). For network destinations make sure the receiver can cope with the custom format defined.
|
NOTE:
If a message uses the IETF-syslog format (RFC5424), only the text of the message can be customized (that is, the $MESSAGE part of the log), the structure of the header is fixed. |
Type: | yes or no |
Default: | no |
Description: Turns on escaping for the '
, "
, and backspace characters in templated output files. This is useful for generating SQL statements and quoting string contents so that parts of the log message are not interpreted as commands to the SQL server.
Type: | number (messages per second) |
Default: | 0 |
Description: Sets the maximum number of messages sent to the destination per second. Use this output-rate-limiting functionality only when using disk-buffer as well to avoid the risk of losing messages. Specifying 0
or a lower value sets the output limit to unlimited.
Type: | name of the timezone, or the timezone offset |
Default: | unspecified |
Description: Convert timestamps to the timezone specified by this option. If this option is not set, then the original timezone information in the message is used. Converting the timezone changes the values of all date-related macros derived from the timestamp, for example, HOUR
. For the complete list of such macros, see the section called “Date-related macros”.
The timezone can be specified as using the name of the (for example time-zone("Europe/Budapest")
), or as the timezone offset in +/-HH:MM format (for example +01:00
). On Linux and UNIX platforms, the valid timezone names are listed under the /usr/share/zoneinfo
directory.
Type: | tls options |
Default: | n/a |
Description: This option sets various options related to TLS encryption, for example, key/certificate files and trusted CA locations. TLS can be used only with tcp-based transport protocols. For details, see the section called “TLS options”.
Type: | rltp, udp, tcp, or tls |
Default: | tcp |
Description: Specifies the protocol used to send messages to the destination server.
If you use the udp
transport, syslog-ng PE automatically sends multicast packets if a multicast destination address is specified. The tcp
transport does not support multicasting.
Type: | rfc3164, bsd, rfc3339, iso |
Default: | Use the global option (which defaults to rfc3164) |
Description: Override the global timestamp format (set in the global ts-format()
parameter) for the specific destination. For details, see the section called “A note on timezones and timestamps”.
|
NOTE:
The |
To convert your existing tcp()
, tcp6()
, udp()
, udp6()
source drivers to use the network()
driver, see Procedure 7.8, “Change an old destination driver to the network() driver”.
The tcp()
, tcp6()
, udp()
, and udp6()
drivers send messages to another host (for example a syslog-ng server or relay) on the local intranet or internet using the UDP or TCP protocol. The tcp6()
and udp6()
drivers use the IPv6 network protocol.
|
NOTE:
The |
To convert your existing tcp()
, tcp6()
, udp()
, udp6()
source drivers to use the network()
driver, see Procedure 7.8, “Change an old destination driver to the network() driver”.
Procedure 7.8. Change an old destination driver to the network() driver
To replace your existing tcp()
, tcp6()
, udp()
, udp6()
destinations with a network()
destination, complete the following steps.
Replace the driver with network
. For example, replace udp(
with network(
Set the transport protocol.
If you used TLS-encryption, add the transport("tls")
option, then continue with the next step.
If you used the tcp
or tcp6
driver, add the transport("tcp")
option.
If you used the udp
or udp
driver, add the transport("udp")
option.
If you use IPv6 (that is, the udp6
or tcp6
driver), add the ip-protocol("6")
option.
If you did not specify the port used in the old driver, check the section called “network() destination options” and verify that your clients send the messages to the default port of the transport protocol you use. Otherwise, set the appropriate port number in your source using the port()
option.
All other options are identical. Test your configuration with the syslog-ng --syntax-only command.
The following configuration shows a simple tcp
destination.
destination d_old_tcp { tcp( "127.0.0.1" port(1999) tls( peer-verify("required-trusted") key-file("/opt/syslog-ng/etc/syslog-ng/syslog-ng.key") cert-file('/opt/syslog-ng/etc/syslog-ng/syslog-ng.crt') ) ); };
When replaced with the network()
driver, it looks like this.
destination d_new_network_tcp { network( "127.0.0.1" port(1999) transport("tls") tls( peer-verify("required-trusted") key-file("/opt/syslog-ng/etc/syslog-ng/syslog-ng.key") cert-file('/opt/syslog-ng/etc/syslog-ng/syslog-ng.crt') ) ); };
The unix-stream()
and unix-dgram()
drivers send messages to a UNIX domain socket in either SOCK_STREAM
or SOCK_DGRAM
mode.
Both drivers have a single required argument specifying the name of the socket to connect to. For the list of available optional parameters, see the section called “unix-stream() and unix-dgram() destination options”.
Declaration:
unix-stream(filename [options]); unix-dgram(filename [options]);
Example 7.45. Using the unix-stream() driver
destination d_unix_stream { unix-stream("/var/run/logs"); };
These drivers send messages to a unix socket in either SOCK_STREAM
or SOCK_DGRAM
mode. The unix-stream()
and unix-dgram()
destinations have the following options.
Description: This option enables putting outgoing messages into the disk buffer of the destination to avoid message loss in case of a system failure on the destination side. It has the following options:
reliable() | |
Type: | yes|no |
Default: | no |
Description: If set to |
dir() | |||
Type: | string | ||
Default: | N/A | ||
Description: Defines the folder where the disk-buffer files are stored. This option has priority over
|
disk-buf-size() | |
Type: | number (bytes) |
Default: | |
Description: This is a required option. The maximum size of the disk-buffer in bytes. The minimum value is 1048576 bytes. If you set a smaller value, the minimum value will be used automatically. It replaces the old log-disk-fifo-size() option. |
mem-buf-length() | |
Type: | number (messages) |
Default: | 10000 |
Description: Use this option if the option reliable() is set to no . This option contains the number of messages stored in overflow queue. It replaces the old log-fifo-size() option. It inherits the value of the global log-fifo-size() option if provided. If it is not provided, the default value is 10000 messages. Note that this option will be ignored if the option reliable() is set to yes . |
mem-buf-size() | |
Type: | number (bytes) |
Default: | 163840000 |
Description: Use this option if the option reliable() is set to yes . This option contains the size of the messages in bytes that is used in the memory part of the disk buffer. It replaces the old log-fifo-size() option. It does not inherit the value of the global log-fifo-size() option, even if it is provided. Note that this option will be ignored if the option reliable() is set to no . |
quot-size() | |
Type: | number (messages) |
Default: | 64 |
Description: The number of messages stored in the output buffer of the destination. |
Options reliable()
and disk-buf-size()
are required options.
Example 7.46. Examples for using disk-buffer()
In the following case reliable disk-buffer() is used.
destination d_demo { network( "127.0.0.1" port(3333) disk-buffer( mem-buf-size(10000) disk-buf-size(2000000) reliable(yes) dir("/tmp/disk-buffer") ) ); };
In the following case normal disk-buffer() is used.
destination d_demo { network( "127.0.0.1" port(3333) disk-buffer( mem-buf-length(10000) disk-buf-size(2000000) reliable(no) dir("/tmp/disk-buffer") ) ); };
Type: | no_multi_line, syslog-protocol |
Default: | empty set |
Description: Flags influence the behavior of the destination driver.
no-multi-line: The no-multi-line
flag disables line-breaking in the messages: the entire message is converted to a single line.
syslog-protocol: The syslog-protocol
flag instructs the driver to format the messages according to the new IETF syslog protocol standard (RFC5424), but without the frame header. If this flag is enabled, macros used for the message have effect only for the text of the message, the message header is formatted to the new standard. Note that this flag is not needed for the syslog
driver, and that the syslog
driver automatically adds the frame header to the messages.
Type: | number (messages) |
Default: | Use global setting. |
Description: Specifies how many lines are sent to a destination at a time. The syslog-ng PE application waits for this number of lines to accumulate and sends them off in a single batch. Setting this number high increases throughput as fully filled frames are sent to the destination, but also increases message latency.
For optimal performance when sending messages to an syslog-ng PE server, make sure that the flush-lines()
is smaller than the window size set using the log-iw-size()
option in the source of your server.
Type: | time in milliseconds |
Default: | Use global setting. |
Description: This is an obsolete option. Specifies the time syslog-ng waits for lines to accumulate in its output buffer. For details, see the flush-lines()
option.
|
NOTE:
This option will be removed from the list of acceptable options. After that, your configuration will become invalid if it still contains the |
Type: | number (digits of fractions of a second) |
Default: | Value of the global option (which defaults to 0) |
Description: The syslog-ng application can store fractions of a second in the timestamps according to the ISO8601 format. The frac-digits()
parameter specifies the number of digits stored. The digits storing the fractions are padded by zeros if the original timestamp of the message specifies only seconds. Fractions can always be stored for the time the message was received. Note that syslog-ng can add the fractions to non-ISO8601 timestamps as well.
Type: | number (messages) |
Default: | Use global setting. |
Description: The number of messages that the output queue can store.
Type: | yes or no |
Default: | yes |
Description: Specifies whether connections to destinations should be closed when syslog-ng is reloaded. Note that this applies to the client (destination) side of the syslog-ng connections, server-side (source) connections are always reopened after receiving a HUP signal unless the keep-alive
option is enabled for the source.
Type: | yes or no |
Default: | no |
Description: This option controls the SO_BROADCAST
socket option required to make syslog-ng send messages to a broadcast address. For details, see the socket(7) manual page.
Type: | yes or no |
Default: | no |
Description: Enables keep-alive messages, keeping the socket open. This only effects TCP and UNIX-stream sockets. For details, see the socket(7) manual page.
Accepted values: | number (seconds) |
Default: | 1200 |
Description: An alias for the obsolete mark()
option, retained for compatibility with syslog-ng version 1.6.x. The number of seconds between two MARK
messages. MARK
messages are generated when there was no message traffic to inform the receiver that the connection is still alive. If set to zero (0
), no MARK
messages are sent. The mark-freq()
can be set for global option and/or every MARK
capable destination driver if mark-mode()
is periodical or dst-idle or host-idle. If mark-freq()
is not defined in the destination, then the mark-freq()
will be inherited from the global options. If the destination uses internal mark-mode()
, then the global mark-freq()
will be valid (does not matter what mark-freq()
set in the destination side).
Accepted values: | internal | dst-idle | host-idle | periodical | none | global |
Default: |
|
Description: The mark-mode()
option can be set for the following destination drivers: file(), program(), unix-dgram(), unix-stream(), network(), pipe(), syslog() and in global option.
internal
: When internal mark mode is selected, internal source should be placed in the log path as this mode does not generate mark by itself at the destination. This mode only yields the mark messages from internal source. This is the mode as syslog-ng PE 3.x worked. MARK
will be generated by internal source if there was NO traffic on local sources:
file()
, pipe()
, unix-stream()
, unix-dgram()
, program()
dst-idle
: Sends MARK
signal if there was NO traffic on destination drivers. MARK
signal from internal source will be dropped.
MARK
signal can be sent by the following destination drivers: network()
, syslog()
, program()
, file()
, pipe()
, unix-stream()
, unix-dgram()
.
host-idle
: Sends MARK
signal if there was NO local message on destination drivers. For example MARK
is generated even if messages were received from tcp. MARK
signal from internal source will be dropped.
MARK
signal can be sent by the following destination drivers: network()
, syslog()
, program()
, file()
, pipe()
, unix-stream()
, unix-dgram()
.
periodical
: Sends MARK
signal perodically, regardless of traffic on destination driver. MARK
signal from internal source will be dropped.
MARK
signal can be sent by the following destination drivers: network()
, syslog()
, program()
, file()
, pipe()
, unix-stream()
, unix-dgram()
.
none
: Destination driver drops all MARK
messages. If an explicit mark-mode() is not given to the drivers where none
is the default value, then none
will be used.
global
: Destination driver uses the global mark-mode()
setting. The syslog-ng interprets syntax error if the global mark-mode()
is global.
|
NOTE:
In case of |
Available in syslog-ng PE 4 LTS and later.
Type: | number (bytes) |
Default: | 0 |
Description: Specifies the size of the socket receive buffer in bytes. For details, see the socket(7) manual page.
Type: | number (bytes) |
Default: | 0 |
Description: Specifies the size of the socket send buffer in bytes. For details, see the socket(7) manual page.
Type: | seconds |
Default: | 0 (disabled) |
Description: If several identical log messages would be sent to the destination without any other messages between the identical messages (for example, an application repeated an error message ten times), syslog-ng can suppress the repeated messages and send the message only once, followed by the Last message repeated n times.
message. The parameter of this option specifies the number of seconds syslog-ng waits for identical messages.
Type: | string |
Default: | A format conforming to the default logfile format. |
Description: Specifies a template defining the logformat to be used in the destination. Macros are described in the section called “Macros of syslog-ng PE”. Please note that for network destinations it might not be appropriate to change the template as it changes the on-wire format of the syslog protocol which might not be tolerated by stock syslog receivers (like syslogd
or syslog-ng itself). For network destinations make sure the receiver can cope with the custom format defined.
Type: | yes or no |
Default: | no |
Description: Turns on escaping for the '
, "
, and backspace characters in templated output files. This is useful for generating SQL statements and quoting string contents so that parts of the log message are not interpreted as commands to the SQL server.
Type: | number (messages per second) |
Default: | 0 |
Description: Sets the maximum number of messages sent to the destination per second. Use this output-rate-limiting functionality only when using disk-buffer as well to avoid the risk of losing messages. Specifying 0
or a lower value sets the output limit to unlimited.
Type: | name of the timezone, or the timezone offset |
Default: | unspecified |
Description: Convert timestamps to the timezone specified by this option. If this option is not set, then the original timezone information in the message is used. Converting the timezone changes the values of all date-related macros derived from the timestamp, for example, HOUR
. For the complete list of such macros, see the section called “Date-related macros”.
The timezone can be specified as using the name of the (for example time-zone("Europe/Budapest")
), or as the timezone offset in +/-HH:MM format (for example +01:00
). On Linux and UNIX platforms, the valid timezone names are listed under the /usr/share/zoneinfo
directory.
Type: | rfc3164, bsd, rfc3339, iso |
Default: | Use the global option (which defaults to rfc3164) |
Description: Override the global timestamp format (set in the global ts-format()
parameter) for the specific destination. For details, see the section called “A note on timezones and timestamps”.
© 2024 One Identity LLC. ALL RIGHTS RESERVED. 이용 약관 개인정보 보호정책 Cookie Preference Center