简体   繁体   English

如何从不同服务器收集日志到中央服务器(Elasticsearch 和 kibana)

[英]How to collect log from different servers to a central server(Elastic search and kibana)

I am assigned with task to create a central logging server.我被分配了创建中央日志服务器的任务。 In my case there are many web app servers spread across.就我而言,分布着许多 Web 应用程序服务器。 My task is to get logs from these different servers and manage in central server where there will be elastic-search and kibana .我的任务是从这些不同的服务器获取日志并在将有elastic-searchkibana中央服务器中进行管理。

Question

  1. Is it possible to get logs from servers that are having different public IP?是否可以从具有不同公共 IP 的服务器获取日志? If possible how?如果可能怎么办?
  2. How much resource (CPU, Memory, Storage) is required in central server.中央服务器需要多少资源(CPU、内存、存储)。

Things seen看到的东西

  • Saw the examples setups where all logs and applications are on same machine only.查看示例设置,其中所有日志和应用程序仅在同一台机器上。

Looking for way to send logs over public IP to elastic-search.寻找通过公共 IP 将日志发送到弹性搜索的方法。

I would like to differ from the Ishara's Answer.我想与 Ishara 的回答不同。 You can ship logs directly from filebeat to elasticsearch without using logstash, If your logs are generic types(system logs, nginx logs, apache logs), Using this approach You don't need to go into incur extra cost and maintenance of logstash as filebeat provides inbuilt parsing processor.您可以将日志直接从 filebeat 发送到 elasticsearch,而无需使用 logstash,如果您的日志是通用类型(系统日志、nginx 日志、apache 日志),则使用这种方法您不需要花费额外的成本和维护日志作为 filebeat提供内置的解析处理器。

If you have debian based OS on your server, I have prepared a shell script to install and configure filebeat.如果你的服务器上有基于 debian 的操作系统,我已经准备了一个 shell 脚本来安装和配置 filebeat。 You need to change elasticsearch server URL and modify second last line based on the modules that you want to configure.您需要根据要配置的模块更改 elasticsearch 服务器 URL 并修改倒数第二行。

Regarding your first question, Yes, You can run filebeat agent on each server and send data to centralize Elasticsearch.关于您的第一个问题,是的,您可以在每个服务器上运行 filebeat 代理并发送数据以集中 Elasticsearch。 For your second question, It depends on the amount of logs elasticsearch server is going to process and store.对于您的第二个问题,这取决于弹性搜索服务器将要处理和存储的日志量。 It also depends on the where kibana is hosted.它还取决于 kibana 的托管位置。

sudo wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

sudo echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

sudo apt-get update && sudo apt-get install -y filebeat

sudo systemctl enable filebeat

sudo bash -c  "cat >/etc/filebeat/filebeat.yml" <<FBEOL
filebeat.inputs:

filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false

setup.template.name: "filebeat-system"
setup.template.pattern: "filebeat-system-*"
setup.template.settings:
  index.number_of_shards: 1

setup.ilm.enabled: false

setup.kibana:

output.elasticsearch:
  hosts: ["10.32.66.55:9200", "10.32.67.152:9200", "10.32.66.243:9200"]
  indices:
    - index: "filebeat-system-%{+yyyy.MM.dd}"
      when.equals:
        event.module: system

processors:
  - add_host_metadata: ~
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~

logging.level: warning

FBEOL

sudo filebeat modules enable system
sudo systemctl restart filebeat
  1. Yes, it is possible to get logs from servers that are having different public IP.是的,可以从具有不同公共 IP 的服务器获取日志。 You need to setup an agent like filebeat (provided by elastic) to each server which produce logs.您需要为每个生成日志的服务器设置一个像filebeat (由 elastic 提供)这样的代理。

    • You need to setup filebeat instance in each machine.您需要在每台机器上设置filebeat实例。

It will listen to your log files in each machine and forward them to the logstash instance you would mention in filebeat.yml configuration file like below:它会在每台机器上监听你的日志文件,并将它们转发到你在filebeat.yml配置文件中提到的 logstash 实例,如下所示:

#=========================== Filebeat inputs =============================

filebeat.inputs:

- type: log

  # Change to true to enable this input configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    - /path_to_your_log_1/ELK/your_log1.log
    - /path_to_your_log_2/ELK/your_log2.log

#----------------------------- Logstash output --------------------------------
output.logstash:
  # The Logstash hosts
  hosts: ["private_ip_of_logstash_server:5044"]
  • Logstash server listens to port 5044 and stream all logs through logstash configuration files: Logstash 服务器侦听端口 5044 并通过 logstash 配置文件流式传输所有日志:

     input { beats { port => 5044 } } filter { # your log filtering logic is here } output { elasticsearch { hosts => [ "elasticcsearch_server_private_ip:9200" ] index => "your_idex_name" } }
  • In logstash you can filter and split your logs into fields and send them to elasticsearch.在 logstash 中,您可以过滤日志并将其拆分为字段并将它们发送到 elasticsearch。

    1. Resources depend on how much of data you produce, data retention plan, TPS and your custom requirements.资源取决于您生成的数据量、数据保留计划、TPS 和您的自定义要求。 If you can provide some more details, I would be able to provide a rough idea about resource requirement.如果您能提供更多详细信息,我将能够提供有关资源需求的粗略想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从Web站点使用Elastic&Kibana收集日志和收集日志 - How to collect log and gathering log with elastic & kibana from WEBSITE 在Kibana中没有登录的弹性搜索警报 - Elastic Search Alert for No log in Kibana 如何将弹性搜索查询从Kibana 3转换为Kibana 4 - How to convert elastic search queries from Kibana 3 to Kibana 4 是否可以从 Elastic Search 中的日志中收集数据 - 使用 Kibana 并每天触发一封邮件 - Is it possible to collect the data from logs in Elastic Search - Using Kibana and trigger a mail at daily interval 弹性搜索-Kibana-Jenkins Pipeline工作日志 - elastic search - Kibana - Jenkins Pipeline job log 如何从 Kibana 查看 Elastic Search 配置设置 - How to view Elastic Search configuration settings from Kibana 如何从 kibana 知道弹性搜索安装的版本? - How to know elastic search installed version from kibana? fluentd:使用弹性搜索FluentD和Kibana从多个资源进行日志聚合 - fluentd : log aggregation from multiple resources using Elastic search FluentD and Kibana 弹性搜索-如何检查kibana中是否使用了索引 - Elastic search - how to check if index is used in kibana 如何使用 Elastic Search 和 Statsd 配置 Kibana - How to configure Kibana with Elastic Search and Statsd
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM