|
|
c17bfd |
diff --git a/source/configuration/modules/omelasticsearch.rst b/source/configuration/modules/omelasticsearch.rst
|
|
|
c17bfd |
index 914fd67..4aee1ac 100644
|
|
|
c17bfd |
--- a/source/configuration/modules/omelasticsearch.rst
|
|
|
c17bfd |
+++ b/source/configuration/modules/omelasticsearch.rst
|
|
|
c17bfd |
@@ -208,18 +208,354 @@ readability):
|
|
|
c17bfd |
reconfiguration (e.g. dropping the mandatory attribute) a resubmit may
|
|
|
c17bfd |
be succesful.
|
|
|
c17bfd |
|
|
|
c17bfd |
-**Samples:**
|
|
|
c17bfd |
+.. _tls.cacert:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+tls.cacert
|
|
|
c17bfd |
+^^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. csv-table::
|
|
|
c17bfd |
+ :header: "type", "default", "mandatory", "obsolete legacy directive"
|
|
|
c17bfd |
+ :widths: auto
|
|
|
c17bfd |
+ :class: parameter-table
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ "word", "none", "no", "none"
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+This is the full path and file name of the file containing the CA cert for the
|
|
|
c17bfd |
+CA that issued the Elasticsearch server cert. This file is in PEM format. For
|
|
|
c17bfd |
+example: `/etc/rsyslog.d/es-ca.crt`
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _tls.mycert:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+tls.mycert
|
|
|
c17bfd |
+^^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. csv-table::
|
|
|
c17bfd |
+ :header: "type", "default", "mandatory", "obsolete legacy directive"
|
|
|
c17bfd |
+ :widths: auto
|
|
|
c17bfd |
+ :class: parameter-table
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ "word", "none", "no", "none"
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+This is the full path and file name of the file containing the client cert for
|
|
|
c17bfd |
+doing client cert auth against Elasticsearch. This file is in PEM format. For
|
|
|
c17bfd |
+example: `/etc/rsyslog.d/es-client-cert.pem`
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _tls.myprivkey:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+tls.myprivkey
|
|
|
c17bfd |
+^^^^^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. csv-table::
|
|
|
c17bfd |
+ :header: "type", "default", "mandatory", "obsolete legacy directive"
|
|
|
c17bfd |
+ :widths: auto
|
|
|
c17bfd |
+ :class: parameter-table
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ "word", "none", "no", "none"
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+This is the full path and file name of the file containing the private key
|
|
|
c17bfd |
+corresponding to the cert `tls.mycert` used for doing client cert auth against
|
|
|
c17bfd |
+Elasticsearch. This file is in PEM format, and must be unencrypted, so take
|
|
|
c17bfd |
+care to secure it properly. For example: `/etc/rsyslog.d/es-client-key.pem`
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _omelasticsearch-bulkid:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+bulkid
|
|
|
c17bfd |
+^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. csv-table::
|
|
|
c17bfd |
+ :header: "type", "default", "mandatory", "obsolete legacy directive"
|
|
|
c17bfd |
+ :widths: auto
|
|
|
c17bfd |
+ :class: parameter-table
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ "word", "none", "no", "none"
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+This is the unique id to assign to the record. The `bulk` part is misleading - this
|
|
|
c17bfd |
+can be used in both bulk mode or in index
|
|
|
c17bfd |
+(record at a time) mode. Although you can specify a static value for this
|
|
|
c17bfd |
+parameter, you will almost always want to specify a *template* for the value of
|
|
|
c17bfd |
+this parameter, and set `dynbulkid="on"` :ref:`omelasticsearch-dynbulkid`. NOTE:
|
|
|
c17bfd |
+you must use `bulkid` and `dynbulkid` in order to use `writeoperation="create"`
|
|
|
c17bfd |
+:ref:`omelasticsearch-writeoperation`.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _omelasticsearch-dynbulkid:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+dynbulkid
|
|
|
c17bfd |
+^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. csv-table::
|
|
|
c17bfd |
+ :header: "type", "default", "mandatory", "obsolete legacy directive"
|
|
|
c17bfd |
+ :widths: auto
|
|
|
c17bfd |
+ :class: parameter-table
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ "binary", "off", "no", "none"
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+If this parameter is set to `"on"`, then the `bulkid` parameter :ref:`omelasticsearch-bulkid`
|
|
|
c17bfd |
+specifies a *template* to use to generate the unique id value to assign to the record. If
|
|
|
c17bfd |
+using `bulkid` you will almost always want to set this parameter to `"on"` to assign
|
|
|
c17bfd |
+a different unique id value to each record. NOTE:
|
|
|
c17bfd |
+you must use `bulkid` and `dynbulkid` in order to use `writeoperation="create"`
|
|
|
c17bfd |
+:ref:`omelasticsearch-writeoperation`.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _omelasticsearch-writeoperation:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+writeoperation
|
|
|
c17bfd |
+^^^^^^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. csv-table::
|
|
|
c17bfd |
+ :header: "type", "default", "mandatory", "obsolete legacy directive"
|
|
|
c17bfd |
+ :widths: auto
|
|
|
c17bfd |
+ :class: parameter-table
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ "word", "index", "no", "none"
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+The value of this parameter is either `"index"` (the default) or `"create"`. If `"create"` is
|
|
|
c17bfd |
+used, this means the bulk action/operation will be `create` - create a document only if the
|
|
|
c17bfd |
+document does not already exist. The record must have a unique id in order to use `create`.
|
|
|
c17bfd |
+See :ref:`omelasticsearch-bulkid` and :ref:`omelasticsearch-dynbulkid`. See
|
|
|
c17bfd |
+:ref:`omelasticsearch-writeoperation-example` for an example.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _omelasticsearch-retryfailures:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+retryfailures
|
|
|
c17bfd |
+^^^^^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. csv-table::
|
|
|
c17bfd |
+ :header: "type", "default", "mandatory", "obsolete legacy directive"
|
|
|
c17bfd |
+ :widths: auto
|
|
|
c17bfd |
+ :class: parameter-table
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ "binary", "off", "no", "none"
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+If this parameter is set to `"on"`, then the module will look for an
|
|
|
c17bfd |
+`"errors":true` in the bulk index response. If found, each element in the
|
|
|
c17bfd |
+response will be parsed to look for errors, since a bulk request may have some
|
|
|
c17bfd |
+records which are successful and some which are failures. Failed requests will
|
|
|
c17bfd |
+be converted back into records and resubmitted back to rsyslog for
|
|
|
c17bfd |
+reprocessing. Each failed request will be resubmitted with a local variable
|
|
|
c17bfd |
+called `$.omes`. This is a hash consisting of the fields from the response.
|
|
|
c17bfd |
+See below :ref:`omelasticsearch-retry-example` for an example of how retry
|
|
|
c17bfd |
+processing works.
|
|
|
c17bfd |
+*NOTE* The retried record will be resubmitted at the "top" of your processing
|
|
|
c17bfd |
+pipeline. If your processing pipeline is not idempotent (that is, your
|
|
|
c17bfd |
+processing pipeline expects "raw" records), then you can specify a ruleset to
|
|
|
c17bfd |
+redirect retries to. See :ref:`omelasticsearch-retryruleset` below.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+`$.omes` fields:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+* writeoperation - the operation used to submit the request - for rsyslog
|
|
|
c17bfd |
+ omelasticsearch this currently means either `"index"` or `"create"`
|
|
|
c17bfd |
+* status - the HTTP status code - typically an error will have a `4xx` or `5xx`
|
|
|
c17bfd |
+ code - of particular note is `429` - this means Elasticsearch was unable to
|
|
|
c17bfd |
+ process this bulk record request due to a temporary condition e.g. the bulk
|
|
|
c17bfd |
+ index thread pool queue is full, and rsyslog should retry the operation.
|
|
|
c17bfd |
+* _index, _type, _id - the metadata associated with the request
|
|
|
c17bfd |
+* error - a hash containing one or more, possibly nested, fields containing
|
|
|
c17bfd |
+ more detailed information about a failure. Typically there will be fields
|
|
|
c17bfd |
+ `$.omes!error!type` (a keyword) and `$.omes!error!reason` (a longer string)
|
|
|
c17bfd |
+ with more detailed information about the rejection. NOTE: The format is
|
|
|
c17bfd |
+ apparently not described in great detail, so code must not make any
|
|
|
c17bfd |
+ assumption about the availability of `error` or any specific sub-field.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+There may be other fields too - the code just copies everything in the
|
|
|
c17bfd |
+response. Here is an example of a detailed error response, in JSON format, from
|
|
|
c17bfd |
+Elasticsearch 5.6.9:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. code-block:: json
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ {"omes":
|
|
|
c17bfd |
+ {"writeoperation": "create",
|
|
|
c17bfd |
+ "_index": "rsyslog_testbench",
|
|
|
c17bfd |
+ "_type": "test-type",
|
|
|
c17bfd |
+ "_id": "92BE7AF79CD44305914C7658AF846A08",
|
|
|
c17bfd |
+ "status": 400,
|
|
|
c17bfd |
+ "error":
|
|
|
c17bfd |
+ {"type": "mapper_parsing_exception",
|
|
|
c17bfd |
+ "reason": "failed to parse [msgnum]",
|
|
|
c17bfd |
+ "caused_by":
|
|
|
c17bfd |
+ {"type": "number_format_exception",
|
|
|
c17bfd |
+ "reason": "For input string: \"x00000025\""}}}}
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+Reference: https://www.elastic.co/guide/en/elasticsearch/guide/current/bulk.html#bulk
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _omelasticsearch-retryruleset:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+retryruleset
|
|
|
c17bfd |
+^^^^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. csv-table::
|
|
|
c17bfd |
+ :header: "type", "default", "mandatory", "obsolete legacy directive"
|
|
|
c17bfd |
+ :widths: auto
|
|
|
c17bfd |
+ :class: parameter-table
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ "word", "", "no", "none"
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+If `retryfailures` is not `"on"` (:ref:`omelasticsearch-retryfailures`) then
|
|
|
c17bfd |
+this parameter has no effect. This parameter specifies the name of a ruleset
|
|
|
c17bfd |
+to use to route retries. This is useful if you do not want retried messages to
|
|
|
c17bfd |
+be processed starting from the top of your processing pipeline, or if you have
|
|
|
c17bfd |
+multiple outputs but do not want to send retried Elasticsearch failures to all
|
|
|
c17bfd |
+of your outputs, and you do not want to clutter your processing pipeline with a
|
|
|
c17bfd |
+lot of conditionals. See below :ref:`omelasticsearch-retry-example` for an
|
|
|
c17bfd |
+example of how retry processing works.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _omelasticsearch-ratelimit.interval:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ratelimit.interval
|
|
|
c17bfd |
+^^^^^^^^^^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. csv-table::
|
|
|
c17bfd |
+ :header: "type", "default", "mandatory", "obsolete legacy directive"
|
|
|
c17bfd |
+ :widths: auto
|
|
|
c17bfd |
+ :class: parameter-table
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ "integer", "600", "no", "none"
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+If `retryfailures` is not `"on"` (:ref:`omelasticsearch-retryfailures`) then
|
|
|
c17bfd |
+this parameter has no effect. Specifies the interval in seconds onto which
|
|
|
c17bfd |
+rate-limiting is to be applied. If more than ratelimit.burst messages are read
|
|
|
c17bfd |
+during that interval, further messages up to the end of the interval are
|
|
|
c17bfd |
+discarded. The number of messages discarded is emitted at the end of the
|
|
|
c17bfd |
+interval (if there were any discards).
|
|
|
c17bfd |
+Setting this to value zero turns off ratelimiting.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _omelasticsearch-ratelimit.burst:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ratelimit.burst
|
|
|
c17bfd |
+^^^^^^^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. csv-table::
|
|
|
c17bfd |
+ :header: "type", "default", "mandatory", "obsolete legacy directive"
|
|
|
c17bfd |
+ :widths: auto
|
|
|
c17bfd |
+ :class: parameter-table
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ "integer", "20000", "no", "none"
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+If `retryfailures` is not `"on"` (:ref:`omelasticsearch-retryfailures`) then
|
|
|
c17bfd |
+this parameter has no effect. Specifies the maximum number of messages that
|
|
|
c17bfd |
+can be emitted within the ratelimit.interval interval. For futher information,
|
|
|
c17bfd |
+see description there.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _omelasticsearch-statistic-counter:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+Statistic Counter
|
|
|
c17bfd |
+=================
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+This plugin maintains global statistics ,
|
|
|
c17bfd |
+which accumulate all action instances. The statistic is named "omelasticsearch".
|
|
|
c17bfd |
+Parameters are:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+- **submitted** - number of messages submitted for processing (with both
|
|
|
c17bfd |
+ success and error result)
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+- **fail.httprequests** - the number of times a http request failed. Note
|
|
|
c17bfd |
+ that a single http request may be used to submit multiple messages, so this
|
|
|
c17bfd |
+ number may be (much) lower than fail.http.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+- **fail.http** - number of message failures due to connection like-problems
|
|
|
c17bfd |
+ (things like remote server down, broken link etc)
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+- **fail.es** - number of failures due to elasticsearch error reply; Note that
|
|
|
c17bfd |
+ this counter does NOT count the number of failed messages but the number of
|
|
|
c17bfd |
+ times a failure occured (a potentially much smaller number). Counting messages
|
|
|
c17bfd |
+ would be quite performance-intense and is thus not done.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+The following counters are available when `retryfailures="on"` is used:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+- **response.success** - number of records successfully sent in bulk index
|
|
|
c17bfd |
+ requests - counts the number of successful responses
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+- **response.bad** - number of times omelasticsearch received a response in a
|
|
|
c17bfd |
+ bulk index response that was unrecognized or unable to be parsed. This may
|
|
|
c17bfd |
+ indicate that omelasticsearch is attempting to communicate with a version of
|
|
|
c17bfd |
+ Elasticsearch that is incompatible, or is otherwise sending back data in the
|
|
|
c17bfd |
+ response that cannot be handled
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+- **response.duplicate** - number of records in the bulk index request that
|
|
|
c17bfd |
+ were duplicates of already existing records - this will only be reported if
|
|
|
c17bfd |
+ using `writeoperation="create"` and `bulkid` to assign each record a unique
|
|
|
c17bfd |
+ ID
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+- **response.badargument** - number of times omelasticsearch received a
|
|
|
c17bfd |
+ response that had a status indicating omelasticsearch sent bad data to
|
|
|
c17bfd |
+ Elasticsearch. For example, status `400` and an error message indicating
|
|
|
c17bfd |
+ omelasticsearch attempted to store a non-numeric string value in a numeric
|
|
|
c17bfd |
+ field.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+- **response.bulkrejection** - number of times omelasticsearch received a
|
|
|
c17bfd |
+ response that had a status indicating Elasticsearch was unable to process
|
|
|
c17bfd |
+ the record at this time - status `429`. The record can be retried.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+- **response.other** - number of times omelasticsearch received a
|
|
|
c17bfd |
+ response not recognized as one of the above responses, typically some other
|
|
|
c17bfd |
+ `4xx` or `5xx` http status.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+**The fail.httprequests and fail.http counters reflect only failures that
|
|
|
c17bfd |
+omelasticsearch detected.** Once it detects problems, it (usually, depends on
|
|
|
c17bfd |
+circumstances) tell the rsyslog core that it wants to be suspended until the
|
|
|
c17bfd |
+situation clears (this is a requirement for rsyslog output modules). Once it is
|
|
|
c17bfd |
+suspended, it does NOT receive any further messages. Depending on the user
|
|
|
c17bfd |
+configuration, messages will be lost during this period. Those lost messages will
|
|
|
c17bfd |
+NOT be counted by impstats (as it does not see them).
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+Note that some previous (pre 7.4.5) versions of this plugin had different counters.
|
|
|
c17bfd |
+These were experimental and confusing. The only ones really used were "submits",
|
|
|
c17bfd |
+which were the number of successfully processed messages and "connfail" which were
|
|
|
c17bfd |
+equivalent to "failed.http".
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+How Retries Are Handled
|
|
|
c17bfd |
+=======================
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+When using `retryfailures="on"` (:ref:`omelasticsearch-retryfailures`), the
|
|
|
c17bfd |
+original `Message` object (that is, the original `smsg_t *msg` object) **is not
|
|
|
c17bfd |
+available**. This means none of the metadata associated with that object, such
|
|
|
c17bfd |
+as various timestamps, hosts/ip addresses, etc. are not available for the retry
|
|
|
c17bfd |
+operation. The only thing available is the original JSON string sent in the
|
|
|
c17bfd |
+original request, and whatever data is returned in the error response, which
|
|
|
c17bfd |
+will contain the Elasticsearch metadata about the index, type, and id, and will
|
|
|
c17bfd |
+be made available in the `$.omes` fields. For the message to retry, the code
|
|
|
c17bfd |
+will take the original JSON string and parse it back into an internal `Message`
|
|
|
c17bfd |
+object. This means you **may need to use a different template** to output
|
|
|
c17bfd |
+messages for your retry ruleset. For example, if you used the following
|
|
|
c17bfd |
+template to format the Elasticsearch message for the initial submission:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. code-block:: none
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ template(name="es_output_template"
|
|
|
c17bfd |
+ type="list"
|
|
|
c17bfd |
+ option.json="on") {
|
|
|
c17bfd |
+ constant(value="{")
|
|
|
c17bfd |
+ constant(value="\"timestamp\":\"") property(name="timereported" dateFormat="rfc3339")
|
|
|
c17bfd |
+ constant(value="\",\"message\":\"") property(name="msg")
|
|
|
c17bfd |
+ constant(value="\",\"host\":\"") property(name="hostname")
|
|
|
c17bfd |
+ constant(value="\",\"severity\":\"") property(name="syslogseverity-text")
|
|
|
c17bfd |
+ constant(value="\",\"facility\":\"") property(name="syslogfacility-text")
|
|
|
c17bfd |
+ constant(value="\",\"syslogtag\":\"") property(name="syslogtag")
|
|
|
c17bfd |
+ constant(value="\"}")
|
|
|
c17bfd |
+ }
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+You would have to use a different template for the retry, since none of the
|
|
|
c17bfd |
+`timereported`, `msg`, etc. fields will have the same values for the retry as
|
|
|
c17bfd |
+for the initial try.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+Examples
|
|
|
c17bfd |
+========
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+Example 1
|
|
|
c17bfd |
+^^^^^^^^^
|
|
|
c17bfd |
|
|
|
c17bfd |
The following sample does the following:
|
|
|
c17bfd |
|
|
|
c17bfd |
- loads the omelasticsearch module
|
|
|
c17bfd |
- outputs all logs to Elasticsearch using the default settings
|
|
|
c17bfd |
|
|
|
c17bfd |
-::
|
|
|
c17bfd |
+.. code-block:: none
|
|
|
c17bfd |
|
|
|
c17bfd |
module(load="omelasticsearch")
|
|
|
c17bfd |
*.* action(type="omelasticsearch")
|
|
|
c17bfd |
|
|
|
c17bfd |
+Example 2
|
|
|
c17bfd |
+^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
The following sample does the following:
|
|
|
c17bfd |
|
|
|
c17bfd |
- loads the omelasticsearch module
|
|
|
c17bfd |
@@ -246,7 +582,7 @@ The following sample does the following:
|
|
|
c17bfd |
- retry indefinitely if the HTTP request failed (eg: if the target
|
|
|
c17bfd |
server is down)
|
|
|
c17bfd |
|
|
|
c17bfd |
-::
|
|
|
c17bfd |
+.. code-block:: none
|
|
|
c17bfd |
|
|
|
c17bfd |
module(load="omelasticsearch")
|
|
|
c17bfd |
template(name="testTemplate"
|
|
|
c17bfd |
@@ -274,6 +610,87 @@ The following sample does the following:
|
|
|
c17bfd |
queue.dequeuebatchsize="300"
|
|
|
c17bfd |
action.resumeretrycount="-1")
|
|
|
c17bfd |
|
|
|
c17bfd |
+.. _omelasticsearch-writeoperation-example:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+Example 3
|
|
|
c17bfd |
+^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+The following sample shows how to use :ref:`omelasticsearch-writeoperation`
|
|
|
c17bfd |
+with :ref:`omelasticsearch-dynbulkid` and :ref:`omelasticsearch-bulkid`. For
|
|
|
c17bfd |
+simplicity, it assumes rsyslog has been built with `--enable-libuuid` which
|
|
|
c17bfd |
+provides the `uuid` property for each record:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. code-block:: none
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ module(load="omelasticsearch")
|
|
|
c17bfd |
+ set $!es_record_id = $uuid;
|
|
|
c17bfd |
+ template(name="bulkid-template" type="list") { property(name="$!es_record_id") }
|
|
|
c17bfd |
+ action(type="omelasticsearch"
|
|
|
c17bfd |
+ ...
|
|
|
c17bfd |
+ bulkmode="on"
|
|
|
c17bfd |
+ bulkid="bulkid-template"
|
|
|
c17bfd |
+ dynbulkid="on"
|
|
|
c17bfd |
+ writeoperation="create")
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. _omelasticsearch-retry-example:
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+Example 4
|
|
|
c17bfd |
+^^^^^^^^^
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+The following sample shows how to use :ref:`omelasticsearch-retryfailures` to
|
|
|
c17bfd |
+process, discard, or retry failed operations. This uses
|
|
|
c17bfd |
+`writeoperation="create"` with a unique `bulkid` so that we can check for and
|
|
|
c17bfd |
+discard duplicate messages as successful. The `try_es` ruleset is used both
|
|
|
c17bfd |
+for the initial attempt and any subsequent retries. The code in the ruleset
|
|
|
c17bfd |
+assumes that if `$.omes!status` is set and is non-zero, this is a retry for a
|
|
|
c17bfd |
+previously failed operation. If the status was successful, or Elasticsearch
|
|
|
c17bfd |
+said this was a duplicate, the record is already in Elasticsearch, so we can
|
|
|
c17bfd |
+drop the record. If there was some error processing the response
|
|
|
c17bfd |
+e.g. Elasticsearch sent a response formatted in some way that we did not know
|
|
|
c17bfd |
+how to process, then submit the record to the `error_es` ruleset. If the
|
|
|
c17bfd |
+response was a "hard" error like `400`, then submit the record to the
|
|
|
c17bfd |
+`error_es` ruleset. In any other case, such as a status `429` or `5xx`, the
|
|
|
c17bfd |
+record will be resubmitted to Elasticsearch. In the example, the `error_es`
|
|
|
c17bfd |
+ruleset just dumps the records to a file.
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+.. code-block:: none
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ module(load="omelasticsearch")
|
|
|
c17bfd |
+ module(load="omfile")
|
|
|
c17bfd |
+ set $!es_record_id = $uuid;
|
|
|
c17bfd |
+ template(name="bulkid-template" type="list") { property(name="$!es_record_id") }
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ ruleset(name="error_es") {
|
|
|
c17bfd |
+ action(type="omfile" template="RSYSLOG_DebugFormat" file="es-bulk-errors.log")
|
|
|
c17bfd |
+ }
|
|
|
c17bfd |
+
|
|
|
c17bfd |
+ ruleset(name="try_es") {
|
|
|
c17bfd |
+ if strlen($.omes!status) > 0 then {
|
|
|
c17bfd |
+ # retry case
|
|
|
c17bfd |
+ if ($.omes!status == 200) or ($.omes!status == 201) or (($.omes!status == 409) and ($.omes!writeoperation == "create")) then {
|
|
|
c17bfd |
+ stop # successful
|
|
|
c17bfd |
+ }
|
|
|
c17bfd |
+ if ($.omes!writeoperation == "unknown") or (strlen($.omes!error!type) == 0) or (strlen($.omes!error!reason) == 0) then {
|
|
|
c17bfd |
+ call error_es
|
|
|
c17bfd |
+ stop
|
|
|
c17bfd |
+ }
|
|
|
c17bfd |
+ if ($.omes!status == 400) or ($.omes!status < 200) then {
|
|
|
c17bfd |
+ call error_es
|
|
|
c17bfd |
+ stop
|
|
|
c17bfd |
+ }
|
|
|
c17bfd |
+ # else fall through to retry operation
|
|
|
c17bfd |
+ }
|
|
|
c17bfd |
+ action(type="omelasticsearch"
|
|
|
c17bfd |
+ ...
|
|
|
c17bfd |
+ bulkmode="on"
|
|
|
c17bfd |
+ bulkid="bulkid-template"
|
|
|
c17bfd |
+ dynbulkid="on"
|
|
|
c17bfd |
+ writeoperation="create"
|
|
|
c17bfd |
+ retryfailures="on"
|
|
|
c17bfd |
+ retryruleset="try_es")
|
|
|
c17bfd |
+ }
|
|
|
c17bfd |
+ call try_es
|
|
|
c17bfd |
|
|
|
c17bfd |
This documentation is part of the `rsyslog <http://www.rsyslog.com/>`_
|
|
|
c17bfd |
project.
|