Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How do I install Logstash in the Docker container and connect to the Elasticsearch server?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Pull the Logstash image (note that it is consistent with the ES version) docker pull logstash:7.5.12. Launch container docker run-- name logstash-d-p 5044-- net esnet 8b94897b4254

The network set by net in the command should be consistent with ES and kibana.

3. Modify Logstash configuration file

The configuration file is the logstash.yml under the config folder

/ / 0.0.0.0: allow any IP to access http.host: "0.0.0.0" / / configure elasticsearch cluster address xpack.monitoring.elasticsearch.hosts: ["http://192.168.172.131:9200","http://192.168.172.129:9200", "http://192.168.172.128:9200"] / / allow monitoring xpack.monitoring.enabled: true// start-up read configuration file specified path.config: / usr/share/logstash/config/logstash.conf// specified this file can configure Logstash to read some files import ES4.logstash.conf configuration # Sample Logstash configuration for creating a simple# Beats-> Logstash-> Elasticsearch pipeline.input {/ / this port may not be matched Because the default is 5044 port beats {port = > 5044}} output {elasticsearch {/ / configured as ES nodes, the cluster can configure all nodes hosts = > ["http://localhost:9200"] / / can be customized index = >"% {[@ metadata] [beat]} -% {[@ metadata] [version]} -% {+ YYYY.MM.dd} "# user = >" elastic "# password = >" changeme "}}

If you want to import a document when logstash starts

The configuration is as follows:

Input {file {path = > "/ usr/share/logstash/bin/file.csv" start_position = > "beginning" sincedb_path = > "/ dev/null"}} `output {elasticsearch {hosts = > "http://localhost:9200" index = >" file "document_id = >" {id} "} stdout {}}

Of course, version 7.x has only one primary shard and one secondary shard by default. If we want to specify multiple shards, we need to create the index in advance and set the shard allocation when starting logstash.

PUT / file {"settings": {"number_of_shards": 3, "number_of_replicas": 1}}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report