WARNING: Version 5.6 of Packetbeat has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Elasticsearch Output
editElasticsearch Output
editWhen you specify Elasticsearch for the output, the Beat sends the transactions directly to Elasticsearch by using the Elasticsearch HTTP API.
Example configuration:
output.elasticsearch: hosts: ["http://localhost:9200"] template.enabled: true template.path: "packetbeat.template.json" template.overwrite: false index: "packetbeat" ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] ssl.certificate: "/etc/pki/client/cert.pem" ssl.key: "/etc/pki/client/cert.key"
To enable SSL, just add https
to all URLs defined under hosts.
output.elasticsearch: hosts: ["https://localhost:9200"] username: "admin" password: "s3cr3t"
If the Elasticsearch nodes are defined by IP:PORT
, then add protocol: https
to the yaml file.
output.elasticsearch: hosts: ["localhost"] protocol: "https" username: "admin" password: "s3cr3t"
Compatibility
editThis output works with all compatible versions of Elasticsearch. See "Supported Beats Versions" in the Elastic Support Matrix.
Elasticsearch Output Options
editYou can specify the following options in the elasticsearch
section of the packetbeat.yml
config file:
enabled
editThe enabled config is a boolean setting to enable or disable the output. If set to false, the output is disabled.
The default value is true.
hosts
editThe list of Elasticsearch nodes to connect to. The events are distributed to
these nodes in round robin order. If one node becomes unreachable, the event is
automatically sent to another node. Each Elasticsearch node can be defined as a URL
or IP:PORT
.
For example: http://192.15.3.2
, https://es.found.io:9230
or 192.24.3.2:9300
.
If no port is specified, 9200
is used.
output.elasticsearch: hosts: ["10.45.3.2:9220", "10.45.3.1:9230"] protocol: https path: /elasticsearch
In the previous example, the Elasticsearch nodes are available at https://10.45.3.2:9220/elasticsearch
and
https://10.45.3.1:9230/elasticsearch
.
compression_level
editThe gzip compression level. Setting this value to 0 disables compression. The compression level must be in the range of 1 (best speed) to 9 (best compression).
Increasing the compression level will reduce the network usage but will increase the cpu usage.
The default value is 0.
worker
editThe number of workers per configured host publishing events to Elasticsearch. This is best used with load balancing mode enabled. Example: If you have 2 hosts and 3 workers, in total 6 workers are started (3 for each host).
username
editThe basic authentication username for connecting to Elasticsearch.
password
editThe basic authentication password for connecting to Elasticsearch.
parameters
editDictionary of HTTP parameters to pass within the url with index operations.
protocol
editThe name of the protocol Elasticsearch is reachable on. The options are:
http
or https
. The default is http
. However, if you specify a URL for
hosts, the value of protocol
is overridden by whatever scheme you
specify in the URL.
path
editAn HTTP path prefix that is prepended to the HTTP API calls. This is useful for the cases where Elasticsearch listens behind an HTTP reverse proxy that exports the API under a custom prefix.
headers
editCustom HTTP headers to add to each request created by the Elasticsearch output. Example:
output.elasticsearch.headers: X-My-Header: Header contents
It is generally possible to specify multiple header values for the same header name by separating them with a comma.
proxy_url
editThe URL of the proxy to use when connecting to the Elasticsearch servers. The value may be either a complete URL or a "host[:port]", in which case the "http" scheme is assumed. If a value is not specified through the configuration file then proxy environment variables are used. See the golang documentation for more information about the environment variables.
index
editThe index name to write events to. The default is "packetbeat-%{+yyyy.MM.dd}" (for example, "packetbeat-2015.04.26").
indices
editArray of index selector rules supporting conditionals, format string
based field access and name mappings. The first rule matching will be used to
set the index
for the event to be published. If indices
is missing or no
rule matches, the index
field will be used.
Rule settings:
index
: The index format string to use. If the fields used are missing, the rule fails.
mapping
: Dictionary mapping index names to new names
default
: Default string value if mapping
does not find a match.
when
: Condition which must succeed in order to execute the current rule.
Examples elasticsearch output with indices
:
output.elasticsearch: hosts: ["http://localhost:9200"] index: "logs-%{+yyyy.MM.dd}" indices: - index: "critical-%{+yyyy.MM.dd}" when.contains: message: "CRITICAL" - index: "error-%{+yyyy.MM.dd}" when.contains: message: "ERR"
pipeline
editA format string value that specifies the ingest node pipeline to write events to.
output.elasticsearch: hosts: ["http://localhost:9200"] pipeline: my_pipeline_id
For more information, see Configuring Packetbeat to Use Ingest Node.
pipelines
editSimilar to the indices
array, this is an array of pipeline selector
configurations supporting conditionals, format string based field access
and name mappings. The first rule matching will be used to set the
pipeline
for the event to be published. If pipelines
is missing or
no rule matches, the pipeline
field will be used.
Example elasticsearch output with pipelines
:
filebeat.prospectors: - paths: ["/var/log/app/normal/*.log"] fields: type: "normal" - paths: ["/var/log/app/critical/*.log"] fields: type: "critical" output.elasticsearch: hosts: ["http://localhost:9200"] index: "filebeat-%{+yyyy.MM.dd}" pipelines: - pipeline: critical_pipeline when.equals: fields.type: "critical" - pipeline: normal_pipeline when.equals: fields.type: "normal"
template
editThe index template to use for setting mappings in Elasticsearch. By default, template loading is enabled.
You can adjust the following settings to load your own template or overwrite an existing one:
-
enabled
- Set to false to disable template loading. If set this to false, you must load the template manually.
-
name
-
The name of the template. The default is
packetbeat
. -
path
-
The path to the template file. The default is
packetbeat.template.json
. If a relative path is set, it is considered relative to the config path. See the Directory Layout section for details. -
overwrite
- A boolean that specifies whether to overwrite the existing template. The default is false.
For example:
output.elasticsearch: hosts: ["localhost:9200"] template.name: "packetbeat" template.path: "packetbeat.template.json" template.overwrite: false
template.versions
editIn the default configuration, Packetbeat automatically checks the Elasticsearch version and loads the recommended template file for the particular version. This behaviour can be controlled from the following options:
-
2x.path
-
The path to the template file to load for
Elasticsearch versions 2.x.y. The default is
packetbeat.template-es2x.json
. -
2x.enabled
-
If set to
false
, the2x.path
option is ignored and the default template is loaded regardless of the Elasticsearch version. -
6x.path
-
The path to the template file to load for
Elasticsearch versions 6.x.y. The default is
packetbeat.template-es6x.json
. -
6x.enabled
-
If set to
false
, the6x.path
option is ignored and the default template is loaded regardless of the Elasticsearch version.
For example:
output.elasticsearch: hosts: ["localhost:9200"] template.path: "packetbeat.template.json" template.overwrite: false template.versions.2x.path: "packetbeat.template-es2x.json
max_retries
editThe number of times to retry publishing an event after a publishing failure.
After the specified number of retries, the events are typically dropped.
Some Beats, such as Filebeat, ignore the max_retries
setting and retry until all
events are published.
Set max_retries
to a value less than 0 to retry until all events are published.
The default is 3.
bulk_max_size
editThe maximum number of events to bulk in a single Elasticsearch bulk API index request. The default is 50.
If the Beat sends single events, the events are collected into batches. If the Beat publishes
a large batch of events (larger than the value specified by bulk_max_size
), the batch is
split.
Specifying a larger batch size can improve performance by lowering the overhead of sending events. However big batch sizes can also increase processing times, which might result in API errors, killed connections, timed-out publishing requests, and, ultimately, lower throughput.
Setting bulk_max_size
to values less than or equal to 0 disables buffering in libbeat. When buffering is disabled,
Beats that publish single events (such as Packetbeat) send each event directly to
Elasticsearch. Beats that publish data in batches (such as Filebeat) send events in batches based on the
spooler size.
timeout
editThe http request timeout in seconds for the Elasticsearch request. The default is 90.
flush_interval
editThe number of seconds to wait for new events between two bulk API index requests.
If bulk_max_size
is reached before this interval expires, additional bulk index
requests are made.
save_topology
editDeprecated in 5.0.0.
A Boolean that specifies whether the topology is kept in Elasticsearch. The default is false.
This option is relevant for Packetbeat only.