2023-07-14 22:06:27 +02:00
---
weight: 1
title: Filebeat setup
2023-07-14 22:56:38 +02:00
disableToc: true
2023-07-14 22:06:27 +02:00
menu:
docs:
parent: "victorialogs-data-ingestion"
weight: 1
2023-07-14 22:56:38 +02:00
aliases:
- /VictoriaLogs/data-ingestion/Filebeat.html
2024-06-14 12:32:12 +02:00
- /victorialogs/data-ingestion/Filebeat.html
- /victorialogs/data-ingestion/filebeat.html
2023-07-14 22:06:27 +02:00
---
2023-06-21 07:08:19 +02:00
# Filebeat setup
2024-06-03 10:04:13 +02:00
Specify [`output.elasticsearch` ](https://www.elastic.co/guide/en/beats/filebeat/current/elasticsearch-output.html ) section in the `filebeat.yml`
2024-05-25 00:30:58 +02:00
for sending the collected logs to [VictoriaLogs ](https://docs.victoriametrics.com/victorialogs/ ):
2023-06-21 07:08:19 +02:00
2024-01-27 19:29:11 +01:00
```yaml
2023-06-21 07:08:19 +02:00
output.elasticsearch:
hosts: ["http://localhost:9428/insert/elasticsearch/"]
parameters:
_msg_field: "message"
_time_field: "@timestamp"
_stream_fields: "host.hostname,log.file.path"
```
Substitute the `localhost:9428` address inside `hosts` section with the real TCP address of VictoriaLogs.
2024-05-25 00:30:58 +02:00
See [these docs ](https://docs.victoriametrics.com/victorialogs/data-ingestion/#http-parameters ) for details on the `parameters` section.
2023-06-21 07:08:19 +02:00
2024-05-25 00:30:58 +02:00
It is recommended verifying whether the initial setup generates the needed [log fields ](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model )
and uses the correct [stream fields ](https://docs.victoriametrics.com/victorialogs/keyconcepts/#stream-fields ).
This can be done by specifying `debug` [parameter ](https://docs.victoriametrics.com/victorialogs/data-ingestion/#http-parameters )
2023-06-21 07:08:19 +02:00
and inspecting VictoriaLogs logs then:
2024-01-27 19:29:11 +01:00
```yaml
2023-06-21 07:08:19 +02:00
output.elasticsearch:
hosts: ["http://localhost:9428/insert/elasticsearch/"]
parameters:
_msg_field: "message"
_time_field: "@timestamp"
_stream_fields: "host.hostname,log.file.path"
debug: "1"
```
2024-05-25 00:30:58 +02:00
If some [log fields ](https://docs.victoriametrics.com/victorialogs/keyconcepts/#data-model ) must be skipped
during data ingestion, then they can be put into `ignore_fields` [parameter ](https://docs.victoriametrics.com/victorialogs/data-ingestion/#http-parameters ).
2023-06-21 07:08:19 +02:00
For example, the following config instructs VictoriaLogs to ignore `log.offset` and `event.original` fields in the ingested logs:
2024-01-27 19:29:11 +01:00
```yaml
2023-06-21 07:08:19 +02:00
output.elasticsearch:
hosts: ["http://localhost:9428/insert/elasticsearch/"]
parameters:
_msg_field: "message"
_time_field: "@timestamp"
_stream_fields: "host.name,log.file.path"
ignore_fields: "log.offset,event.original"
```
When Filebeat ingests logs into VictoriaLogs at a high rate, then it may be needed to tune `worker` and `bulk_max_size` options.
For example, the following config is optimized for higher than usual ingestion rate:
2024-01-27 19:29:11 +01:00
```yaml
2023-06-21 07:08:19 +02:00
output.elasticsearch:
hosts: ["http://localhost:9428/insert/elasticsearch/"]
parameters:
_msg_field: "message"
_time_field: "@timestamp"
_stream_fields: "host.name,log.file.path"
worker: 8
bulk_max_size: 1000
```
If the Filebeat sends logs to VictoriaLogs in another datacenter, then it may be useful enabling data compression via `compression_level` option.
This usually allows saving network bandwidth and costs by up to 5 times:
2024-01-27 19:29:11 +01:00
```yaml
2023-06-21 07:08:19 +02:00
output.elasticsearch:
hosts: ["http://localhost:9428/insert/elasticsearch/"]
parameters:
_msg_field: "message"
_time_field: "@timestamp"
_stream_fields: "host.name,log.file.path"
compression_level: 1
```
2024-05-25 00:30:58 +02:00
By default, the ingested logs are stored in the `(AccountID=0, ProjectID=0)` [tenant ](https://docs.victoriametrics.com/victorialogs/#multitenancy ).
2023-06-21 07:08:19 +02:00
If you need storing logs in other tenant, then specify the needed tenant via `headers` at `output.elasticsearch` section.
For example, the following `filebeat.yml` config instructs Filebeat to store the data to `(AccountID=12, ProjectID=34)` tenant:
2024-01-27 19:29:11 +01:00
```yaml
2023-06-21 07:08:19 +02:00
output.elasticsearch:
hosts: ["http://localhost:9428/insert/elasticsearch/"]
headers:
AccountID: 12
ProjectID: 34
parameters:
_msg_field: "message"
_time_field: "@timestamp"
_stream_fields: "host.name,log.file.path"
```
2023-08-11 15:52:57 +02:00
Filebeat checks a version of ElasticSearch on startup and refuses to start sending logs if the version is not compatible.
In order to bypass this check please add `allow_older_versions: true` into `output.elasticsearch` section:
2024-01-27 19:29:11 +01:00
```yaml
2023-08-11 15:52:57 +02:00
output.elasticsearch:
hosts: [ "http://localhost:9428/insert/elasticsearch/" ]
parameters:
_msg_field: "message"
_time_field: "@timestamp"
_stream_fields: "host.name,log.file.path"
allow_older_versions: true
```
Alternatively, is also possible to change version which VictoriaLogs reports to Filebeat by using `-elasticsearch.version`
command-line flag.
2023-06-22 03:31:50 +02:00
See also:
2023-06-21 16:58:43 +02:00
2024-05-25 00:30:58 +02:00
- [Data ingestion troubleshooting ](https://docs.victoriametrics.com/victorialogs/data-ingestion/#troubleshooting ).
- [How to query VictoriaLogs ](https://docs.victoriametrics.com/victorialogs/querying/ ).
2023-06-22 03:31:50 +02:00
- [Filebeat `output.elasticsearch` docs ](https://www.elastic.co/guide/en/beats/filebeat/current/elasticsearch-output.html ).
- [Docker-compose demo for Filebeat integration with VictoriaLogs ](https://github.com/VictoriaMetrics/VictoriaMetrics/tree/master/deployment/docker/victorialogs/filebeat-docker ).