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 10 digits long, starting with 0x
. For example 0xABABABABAB
.
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 sql()
driver sends messages into an SQL database. Currently the Microsoft SQL (MSSQL), MySQL, Oracle, PostgreSQL, and SQLite databases are supported.
|
NOTE:
In order to use this destination, syslog-ng Premium Edition must run in server mode. Typically, only the central syslog-ng Premium Edition server uses this destination. For details on the server mode, see the section called “Server mode”. |
Declaration:
sql(database_type host_parameters database_parameters [options]);
The sql()
driver has the following required parameters: type()
, database()
, table()
, columns()
, and values()
.
|
Caution:
The syslog-ng application requires read and write access to the SQL table, otherwise it cannot verify that the destination table exists. Currently the syslog-ng application has default schemas for the different databases and uses these defaults if the database schema (for example columns and column types) is not defined in the configuration file. However, these schemas will be deprecated and specifying the exact database schema will be required in later versions of syslog-ng. |
|
NOTE:
In addition to the standard syslog-ng packages, the The |
The table
and value
parameters can include macros to create tables and columns dynamically (for details, see the section called “Macros of syslog-ng PE”).
|
Caution:
When using macros in table names, note that some databases limit the maximum allowed length of table names. Consult the documentation of the database for details. |
Inserting the records into the database is performed by a separate thread. The syslog-ng application automatically performs the escaping required to insert the messages into the database.
Example 7.34. Using the sql() driver
The following example sends the log messages into a PostgreSQL database running on the logserver
host. The messages are inserted into the logs
database, the name of the table includes the exact date and the name of the host sending the messages. The syslog-ng application automatically creates the required tables and columns, if the user account used to connect to the database has the required privileges.
destination d_sql { sql(type(pgsql) host("logserver") username("syslog-ng") password("password") database("logs") table("messages_${HOST}_${R_YEAR}${R_MONTH}${R_DAY}") columns("datetime", "host", "program", "pid", "message") values("{$R_DATE}", "${HOST}", "${PROGRAM}", "${PID}", "${MSGONLY}") indexes("datetime", "host", "program", "pid", "message")); };
The following example specifies the type of the database columns as well:
destination d_sql { sql(type(pgsql) host("logserver") username("syslog-ng") password("password") database("logs") table("messages_${HOST}_${R_YEAR}${R_MONTH}${R_DAY}") columns("datetime varchar(16)", "host varchar(32)", "program varchar(20)", "pid varchar(8)", "message varchar(200)") values("${R_DATE}", "${HOST}", "${PROGRAM}", "${PID}", "${MSGONLY}") indexes("datetime", "host", "program", "pid", "message")); };
The Oracle sql destination has some special aspects that are important to note.
The hostname of the database server is set in the tnsnames.ora
file, not in the host
parameter of the sql()
destination.
If the tnsnames.ora
file is not located in the /etc directory (or in the /var/opt/oracle directory on Solaris), set the following Oracle-related environment variables, so syslog-ng PE will find the file: ORACLE_BASE
, ORACLE_HOME
, and ORACLE_SID
. For details, see the documentation of the Oracle Instant Client.
You cannot use the same database()
settings in more than one destination, because the database()
option of the SQL driver is just a reference to the connection string of the tnsnames.ora
file. To overcome this problem, you can duplicate the connections in the tnsnames.ora
file under a different name, and use a different table in each Oracle destination in syslog-ng PE.
As certain database versions limit the maximum length of table names, macros in the table names should be used with care.
In the current version of syslog-ng PE, the types of database columns must be explicitly set for the Oracle destination. The column used to store the text part of the syslog messages should be able to store messages as long as the longest message permitted by syslog-ng, therefore it is usually recommended to use the varchar2
or clob
column type. (The maximum length of the messages can be set using the log-msg-size()
option.) For details, see the following example.
The Oracle Instant Client used by syslog-ng PE supports only the following character sets:
Single-byte character sets: US7ASCII, WE8DEC, WE8MSWIN1252, and WE8ISO8859P1
Unicode character sets: UTF8, AL16UTF16, and AL32UTF8
Example 7.35. Using the sql() driver with an Oracle database
The following example sends the log messages into an Oracle database running on the logserver
host, which must be set in the /etc/tnsnames.ora
file. The messages are inserted into the LOGS
database, the name of the table includes the exact date when the messages were sent. The syslog-ng application automatically creates the required tables and columns, if the user account used to connect to the database has the required privileges.
destination d_sql { sql(type(oracle) username("syslog-ng") password("password") database("LOGS") table("msgs_${R_YEAR}${R_MONTH}${R_DAY}") columns("datetime varchar(16)", "host varchar(32)", "program varchar(32)", "pid varchar(8)", "message varchar2") values("${R_DATE}", "${HOST}", "${PROGRAM}", "${PID}", "${MSGONLY}") indexes("datetime", "host", "program", "pid", "message")); };
The Oracle Instant Client retrieves the address of the database server from the /etc/tnsnames.ora
file. Edit or create this file as needed for your configuration. A sample is provided below.
LOGS = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = logserver) (PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = EXAMPLE.SERVICE) ) )
The mssql
database driver can access Microsoft SQL (MSSQL) destinations. This driver has some special aspects that are important to note.
The date format used by the MSSQL database must be explicitly set in the /etc/locales.conf
file of the syslog-ng server. For details, see the following example.
As certain database versions limit the maximum length of table names, macros in the table names should be used with care.
In the current version of syslog-ng PE, the types of database columns must be explicitly set for the MSSQL destination.
|
Caution:
The following column types cannot be used in MSSQL destinations: |
The column used to store the text part of the syslog messages should be able to store messages as long as the longest message permitted by syslog-ng. The varchar
column type can store maximum 4096 bytes-long messages. The maximum length of the messages can be set using the log-msg-size()
option. For details, see the following example.
Remote access for SQL users must be explicitly enabled on the Microsoft Windows host running the Microsoft SQL Server. For details, see Procedure 3.12, “Configuring Microsoft SQL Server to accept logs from syslog-ng”.
Example 7.36. Using the sql() driver with an MSSQL database
The following example sends the log messages into an MSSQL database running on the logserver
host. The messages are inserted into the syslogng
database, the name of the table includes the exact date when the messages were sent. The syslog-ng application automatically creates the required tables and columns, if the user account used to connect to the database has the required privileges.
destination d_mssql { sql(type(mssql) host("logserver") port("1433") username("syslogng") password("syslogng") database("syslogng") table("msgs_${R_YEAR}${R_MONTH}${R_DAY}")columns("datetime varchar(16)", "host varchar(32)", "program varchar(32)", "pid varchar(8)", "message varchar(4096)") values("${R_DATE}", "${HOST}", "${PROGRAM}", "${PID}", "${MSGONLY}") indexes("datetime", "host", "program", "pid")); };
The date format used by the MSSQL database must be explicitly set in the /etc/locales.conf
file of the syslog-ng server. Edit or create this file as needed for your configuration. A sample is provided below.
[default] date = "%Y-%m-%d %H:%M:%S"
Used SQL operations by syslog-ng.
Create table:
If the given table does not exist, syslog-ng tries to create it with the given column types.
The syslog-ng PE application automatically creates the required tables and columns, if the user account used to connect to the database has the required privileges.
If syslog-ng cannot create or alter a table, it tries to do it again when it reaches the next time-reopen()
.
Alter table:
If the table structure is different from given structure in an existing table, syslog-ng tries to add columns in this table but never will delete or modify an existing column.
If syslog-ng PE cannot create or alter a table, it tries to do it again when reach the next time-reopen()
.
The syslog-ng PE application requires read and write access to the SQL table, otherwise it cannot verify that the destination table exists.
Insert table:
Insert new records in a table.
Inserting the records into the database is performed by a separate thread.
The syslog-ng PE application automatically performs the escaping required to insert the messages into the database.
If insert returns with error, syslog-ng tries to insert the message +two times by default, then drops it. Retrying time is the value of time-reopen()
.
Encoding.
The syslog-ng PE application uses UTF-8 by default when writes logs into database.
Start/stop and reload.
Start:
The syslog-ng PE application will connect to database automatically after starting regardless existing incoming messages.
Stop:
The syslog-ng PE application will close the connection to database before shutting down.
Possibility of losing logs:
The syslog-ng PE application cannot lose logs during shutting down if disk buffer was given and it is not full yet.
The syslog-ng PE application cannot lose logs during shutting down if disk buffer was not given.
Reload:
The syslog-ng PE application will close the connection to database if it received SIGHUP signal (reload).
It will reconnect to the database when it tries to send a new message to this database again.
Macros:
The value of ${SEQNUM} macro will be overrided by sql driver regardless of local or relayed incoming message.
It will be grown continously.
To specify the socket to use, set and export the MYSQL_UNIX_PORT
environment variable, for example MYSQL_UNIX_PORT=/var/lib/mysql/mysql.sock; export MYSQL_UNIX_PORT
.
In SQL Server 2005 this restriction is lifted - kind of. The total length of all key columns in an index cannot exceed 900 bytes.
If you are using null()
in your configuration, be sure that the columns allow NULL
to insert. Give the column as the following example: "datetime varchar(16) NULL"
.
The date format used by the MSSQL database must be explicitly set in the /etc/locales.conf
file of the syslog-ng server. [default] date = "%Y-%m-%d %H:%M:%S"
.
Table 7.2. Supported SQL destinations by platform
Platform \ Database | MSSQL | MySQL | PgSQL | SQLite | Oracle |
---|---|---|---|---|---|
AIX | ✔ | ✔ | ✔ | ✔ | - |
Linux (linux_glibc236): CentOS 5 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): CentOS 6 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): CentOS 7 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): Debian 7 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): openSUSE 11 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): Oracle Linux 5 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): Oracle Linux 6 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): Oracle Linux 7 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): SLES 11 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): Red Hat EL 5 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): Red Hat EL 6 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): Red Hat EL 7 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): Ubuntu 12.04 | ✔ | ✔ | ✔ | ✔ | ✔ |
Linux (linux_glibc236): Ubuntu 14.04 | ✔ | ✔ | ✔ | ✔ | ✔ |
FreeBSD 8 | ✔ | ✔ | ✔ | ✔ | - |
FreeBSD 9 | ✔ | ✔ | ✔ | ✔ | - |
FreeBSD 10 | ✔ | ✔ | ✔ | ✔ | - |
HP-UX 11v2_on IA64 | ✔ | ✔ | - | ✔ | ✔ |
Solaris 10 on SPARC and SPARC64 | ✔ | ✔ | ✔ | ✔ | ✔ |
Solaris 11 on SPARC and SPARC64 | ✔ | ✔ | ✔ | ✔ | ✔ |
Solaris 10 on x86_64 | ✔ | ✔ | - | ✔ | ✔ |
Solaris 11 on x86_64 | ✔ | ✔ | - | ✔ | ✔ |
|
NOTE:
In order to use this destination, syslog-ng Premium Edition must run in server mode. Typically, only the central syslog-ng Premium Edition server uses this destination. For details on the server mode, see the section called “Server mode”. |
This driver sends messages into an SQL database. The sql()
destination has the following options:
Type: | string list |
Default: | "date", "facility", "level", "host", "program", "pid", "message" |
Description: Name of the columns storing the data in fieldname [dbtype]
format. The [dbtype]
parameter is optional, and specifies the type of the field. By default, syslog-ng PE creates text
columns. Note that not every database engine can index text fields.
|
Caution:
The following column types cannot be used in MSSQL destinations: |
Type: | string |
Default: | logs |
Description: Name of the database that stores the logs. Macros cannot be used in database name. Also, when using an Oracle database, you cannot use the same database()
settings in more than one destination.
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.37. 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 flags |
Default: | empty string |
Description: Flags related to the sql()
destination.
dont-create-tables: Enable this flag to prevent syslog-ng PE from creating non-existing database tables automatically. The syslog-ng PE application typically has to create tables if you use macros in the table names. Available in syslog-ng PE version 4.0 and later.
explicit-commits: By default, syslog-ng PE commits every log message to the target database individually. When the explicit-commits
option is enabled, messages are committed in batches. This improves the performance, but results in some latency, as the messages are not immediately sent to the database. The size and frequency of batched commits can be set using the flush-lines()
parameter. The explicit-commits
option is available in syslog-ng PE version 4.0 and later.
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: | hostname or IP address |
Default: | n/a |
Description: Hostname of the database server. Note that Oracle destinations do not use this parameter, but retrieve the hostname from the /etc/tnsnames.ora
file.
|
NOTE:
If you specify To specify the socket to use, set and export the |
Type: | string list |
Default: | "date", "facility", "host", "program" |
Description: The list of columns that are indexed by the database to speed up searching. To disable indexing for the destination, include the empty indexes()
parameter in the destination, simply omitting the indexes
parameter will cause syslog-ng to request indexing on the default columns.
The syslog-ng PE application will create the name of indexes automaticaly with the following method:
In case of MsSQL, PostgreSQL, MySQL or SQLite or (Oracle but tablename < 30 characters): {table}_{column}_idx
.
In case of Oracle and tablename > 30 characters: md5sum of {table}_{column}-1
and the first character will be replaced by "i" character and the md5sum will be truncated to 30 characters.
Type: | name of the timezone, or the timezone offset |
Default: | The local timezone. |
Description: Sets the timezone used when expanding filename and tablename templates.
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: | number (messages) |
Default: | Use global setting. |
Description: The number of messages that the output queue can store.
Type: | string |
Default: |
Description: If the content of a column matches the string specified in the null()
parameter, the contents of the column will be replaced with an SQL NULL value. If unset (by default), the option does not match on any string. For details, see the Example 7.39, “Using SQL NULL values”.
Example 7.39. Using SQL NULL values
The null()
parameter of the SQL driver can be used to replace the contents of a column with a special SQL NULL value. To replace every column that contains an empty string with NULL, use the null("")
option, for example
destination d_sql { sql(type(pgsql) host("logserver") username("syslog-ng") password("password") database("logs") table("messages_${HOST}_${R_YEAR}${R_MONTH}${R_DAY}") columns("datetime", "host", "program", "pid", "message") values("${R_DATE}", "${HOST}", "${PROGRAM}", "${PID}", "${MSGONLY}") indexes("datetime", "host", "program", "pid", "message") null("")); };
To replace only a specific column (for example pid
) if it is empty, assign a default value to the column, and use this default value in the null()
parameter:
destination d_sql { sql(type(pgsql) host("logserver") username("syslog-ng") password("password") database("logs") table("messages_${HOST}_${R_YEAR}${R_MONTH}${R_DAY}") columns("datetime", "host", "program", "pid", "message") values("${R_DATE}", "${HOST}", "${PROGRAM}", "${PID:-@@NULL@@}", "${MSGONLY}") indexes("datetime", "host", "program", "pid", "message") null("@@NULL@@")); };
Ensure that the default value you use does not appear in the actual log messages, because other occurrences of this string will be replaced with NULL as well.
Type: | number (port number) |
Default: | 1433 TCP for MSSQL, 3306 TCP for MySQL, 1521 for Oracle, and 5432 TCP for PostgreSQL |
Description: The port number to connect to.
Type: | number (insertion attempts) |
Default: | 3 |
Description: The number of insertion attempts. If syslog-ng PE could not insert a message into the database, it will repeat the attempt until the number of attempts reaches retries
, then drops the connection to the database. For example, syslog-ng PE will try to insert a message maximum three times by default (once for first insertion and twice if the first insertion was failed).
Type: | comma-separated list of SQL statements |
Default: | empty string |
Description: Specifies one or more SQL-like statement which is executed after syslog-ng PE has successfully connected to the database. For example:
session-statements("SET COLLATION_CONNECTION='utf8_general_ci'")
|
Caution:
The syslog-ng PE application does not validate or limit the contents of customized queries. Consequently, queries performed with a user with write-access can potentially modify or even harm the database. Use customized queries with care, and only for your own responsibility. |
Type: | string |
Default: | messages |
Description: Name of the database table to use (can include macros). When using macros, note that some databases limit the length of table names.
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: | mssql, mysql, oracle, pgsql, or sqlite3 |
Default: | mysql |
Description: Specifies the type of the database, that is, the DBI database driver to use. Use the mssql
option to send logs to an MSSQL database. For details, see the examples of the databases on the following sections.
Type: | string list |
Default: | "${R_YEAR}-${R_MONTH}-${R_DAY}, ${R_HOUR}:${R_MIN}:${R_SEC}", "${FACILITY}", "${LEVEL}", "${HOST}", "${PROGRAM}", "${PID}", "${MSGONLY}" |
Description: The parts of the message to store in the fields specified in the columns()
parameter.
It is possible to give a special value calling: default (without quotation marks).It means that the value will be used that is the default of the column type of this value.
Example 7.40. Value: default
columns("date datetime", "host varchar(32)", "row_id serial") values("${R_DATE}", "${HOST}", default)
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 |
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.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') ) ); };
© 2021 One Identity LLC. ALL RIGHTS RESERVED. Feedback Terms of Use Privacy