summaryrefslogtreecommitdiffstats
path: root/source/configuration/modules/ommongodb.rst
blob: f048aa107def1ea6297ccb891668862102322372 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
********************************
ommongodb: MongoDB Output Module
********************************

===========================  ===========================================================================
**Module Name:**             **ommongodb**
**Author:**                  `Rainer Gerhards <https://rainer.gerhards.net/>`_ <rgerhards@adiscon.com>
===========================  ===========================================================================


Purpose
=======

This module provides native support for logging to MongoDB.


Configuration Parameters
========================

.. note::

   Parameter names are case-insensitive.


Action Parameters
-----------------

UriStr
^^^^^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "word", "none", "no", "none"

MongoDB connexion string, as defined by the MongoDB String URI Format (See: https://docs.mongodb.com/manual/reference/connection-string/). If uristr is defined, following directives will be ignored: server, serverport, uid, pwd.


SSL_Cert
^^^^^^^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "word", "none", "no", "none"

Absolute path to the X509 certificate you want to use for TLS client authentication. This is optional.


SSL_Ca
^^^^^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "word", "none", "no", "none"

Absolute path to the trusted X509 CA certificate that signed the mongoDB server certificate. This is optional.


db
^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "word", "syslog", "no", "none"

Database to use.


Collection
^^^^^^^^^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "word", "log", "no", "none"

Collection to use.


Allowed_Error_Codes
^^^^^^^^^^^^^^^^^^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "array", "no", "no", "none"

The list of error codes returned by MongoDB you want ommongodb to ignore.
Please use the following format: allowed_error_codes=["11000","47"].


Template
^^^^^^^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "word", "OMSR_TPL_AS_MSG", "no", "none"

Template to use when submitting messages.

Note rsyslog contains a canned default template to write to the MongoDB.
It will be used automatically if no other template is specified to be
used. This template is:

.. code-block:: none

   template(name="BSON" type="string" string="\\"sys\\" : \\"%hostname%\\",
   \\"time\\" : \\"%timereported:::rfc3339%\\", \\"time\_rcvd\\" :
   \\"%timegenerated:::rfc3339%\\", \\"msg\\" : \\"%msg%\\",
   \\"syslog\_fac\\" : \\"%syslogfacility%\\", \\"syslog\_server\\" :
   \\"%syslogseverity%\\", \\"syslog\_tag\\" : \\"%syslogtag%\\",
   \\"procid\\" : \\"%programname%\\", \\"pid\\" : \\"%procid%\\",
   \\"level\\" : \\"%syslogpriority-text%\\"")


This creates the BSON document needed for MongoDB if no template is
specified. The default schema is aligned to CEE and project lumberjack.
As such, the field names are standard lumberjack field names, and
**not** `rsyslog property names <property_replacer.html>`_. When
specifying templates, be sure to use rsyslog property names as given in
the table. If you would like to use lumberjack-based field names inside
MongoDB (which probably is useful depending on the use case), you need
to select fields names based on the lumberjack schema. If you just want
to use a subset of the fields, but with lumberjack names, you can look
up the mapping in the default template. For example, the lumberjack
field "level" contains the rsyslog property "syslogpriority-text".


Examples
========


Write to Database
-----------------

The following sample writes all syslog messages to the database "syslog"
and into the collection "log" on mongoserver.example.com. The server is
being accessed under the account of "user" with password "pwd". Please note
that this syntax is deprecated by the "uristr" directive, as shown below.

.. code-block:: none

   module(load="ommongodb")
   action(type="ommongodb"
          server="mongoserver.example.com" db="syslog" collection="log"
          uid="user" pwd="pwd")


Write to mongoDB server with TLS and client authentication
----------------------------------------------------------

Another sample that uses the new "uristr" directives to connect to a TLS mongoDB server with TLS and client authentication.

.. code-block:: none

   module(load="ommongodb")
   action(type="ommongodb"
         uristr="mongodb://vulture:9091,vulture2:9091/?replicaset=Vulture&ssl=true"
         ssl_cert="/var/db/mongodb/mongod.pem"
         ssl_ca="/var/db/mongodb/ca.pem"
         db="logs" collection="syslog")


Deprecated Parameters
=====================

.. note::

   While these parameters are still accepted, they should no longer be used for newly created configurations.


Action Parameters
-----------------

Server
^^^^^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "word", "127.0.0.1", "no", "none"

Name or address of the MongoDB server.


ServerPorted
^^^^^^^^^^^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "word", "27017", "no", "none"

Permits to select a non-standard port for the MongoDB server. The
default is 0, which means the system default port is used. There is
no need to specify this parameter unless you know the server is
running on a non-standard listen port.


UID
^^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "word", "none", "no", "none"

Logon userid used to connect to server. Must have proper permissions.


PWD
^^^

.. csv-table::
   :header: "type", "default", "mandatory", "|FmtObsoleteName| directive"
   :widths: auto
   :class: parameter-table

   "word", "none", "no", "none"

The user's password.