2023-07-14 20:06:27 +00:00
---
weight: 3
title: Logstash setup
2023-07-14 20:56:38 +00:00
disableToc: true
2023-07-14 20:06:27 +00:00
menu:
docs:
parent: "victorialogs-data-ingestion"
weight: 3
2023-07-14 20:56:38 +00:00
aliases:
- /VictoriaLogs/data-ingestion/Logstash.html
2023-07-14 20:06:27 +00:00
---
2023-06-21 05:08:19 +00:00
# Logstash setup
Specify [`output.elasticsearch` ](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html ) section in the `logstash.conf` file
2023-10-14 12:41:04 +00:00
for sending the collected logs to [VictoriaLogs ](/VictoriaLogs/ ):
2023-06-21 05:08:19 +00:00
```conf
output {
elasticsearch {
hosts => ["http://localhost:9428/insert/elasticsearch/"]
parameters => {
"_msg_field" => "message"
"_time_field" => "@timestamp"
"_stream_fields" => "host.name,process.name"
}
}
}
```
Substitute `localhost:9428` address inside `hosts` with the real TCP address of VictoriaLogs.
2023-10-14 12:41:04 +00:00
See [these docs ](/VictoriaLogs/data-ingestion/#http-parameters ) for details on the `parameters` section.
2023-06-21 05:08:19 +00:00
2023-10-14 12:41:04 +00:00
It is recommended verifying whether the initial setup generates the needed [log fields ](/VictoriaLogs/keyConcepts.html#data-model )
and uses the correct [stream fields ](/VictoriaLogs/keyConcepts.html#stream-fields ).
This can be done by specifying `debug` [parameter ](/VictoriaLogs/data-ingestion/#http-parameters )
2023-06-21 05:08:19 +00:00
and inspecting VictoriaLogs logs then:
```conf
output {
elasticsearch {
hosts => ["http://localhost:9428/insert/elasticsearch/"]
parameters => {
"_msg_field" => "message"
"_time_field" => "@timestamp"
"_stream_fields" => "host.name,process.name"
"debug" => "1"
}
}
}
```
2023-10-14 12:41:04 +00:00
If some [log fields ](/VictoriaLogs/keyConcepts.html#data-model ) must be skipped
during data ingestion, then they can be put into `ignore_fields` [parameter ](/VictoriaLogs/data-ingestion/#http-parameters ).
2023-06-21 05:08:19 +00:00
For example, the following config instructs VictoriaLogs to ignore `log.offset` and `event.original` fields in the ingested logs:
```conf
output {
elasticsearch {
hosts => ["http://localhost:9428/insert/elasticsearch/"]
parameters => {
"_msg_field" => "message"
"_time_field" => "@timestamp"
"_stream_fields" => "host.hostname,process.name"
"ignore_fields" => "log.offset,event.original"
}
}
}
```
If the Logstash sends logs to VictoriaLogs in another datacenter, then it may be useful enabling data compression via `http_compression: true` option.
This usually allows saving network bandwidth and costs by up to 5 times:
```conf
output {
elasticsearch {
hosts => ["http://localhost:9428/insert/elasticsearch/"]
parameters => {
"_msg_field" => "message"
"_time_field" => "@timestamp"
"_stream_fields" => "host.hostname,process.name"
}
http_compression => true
}
}
```
2023-10-14 12:41:04 +00:00
By default, the ingested logs are stored in the `(AccountID=0, ProjectID=0)` [tenant ](/VictoriaLogs/#multitenancy ).
2023-06-21 05:08:19 +00:00
If you need storing logs in other tenant, then specify the needed tenant via `custom_headers` at `output.elasticsearch` section.
For example, the following `logstash.conf` config instructs Logstash to store the data to `(AccountID=12, ProjectID=34)` tenant:
```conf
output {
elasticsearch {
hosts => ["http://localhost:9428/insert/elasticsearch/"]
custom_headers => {
"AccountID" => "1"
"ProjectID" => "2"
}
parameters => {
"_msg_field" => "message"
"_time_field" => "@timestamp"
"_stream_fields" => "host.hostname,process.name"
}
}
}
```
2023-06-22 01:31:50 +00:00
See also:
2023-06-21 05:08:19 +00:00
2023-10-14 12:41:04 +00:00
- [Data ingestion troubleshooting ](/VictoriaLogs/data-ingestion/#troubleshooting ).
- [How to query VictoriaLogs ](/VictoriaLogs/querying/ ).
2023-06-22 01:31:50 +00:00
- [Logstash `output.elasticsearch` docs ](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html ).
- [Docker-compose demo for Logstash integration with VictoriaLogs ](https://github.com/VictoriaMetrics/VictoriaMetrics/tree/master/deployment/docker/victorialogs/logstash ).