centos7搭建ELK之linux安装Logstash7.7图文教程(二)

1.Logstash简介

  • Logstash是一个用来搜集、分析、过滤日志的工具。它支持几乎任何类型的日志,包括系统日志、错误日志和自定义应用程序日志。它可以从许多来源接收日志,这些来源包括 syslog、消息传递(例如 RabbitMQ)和JMX,它能够以多种方式输出数据,包括电子邮件、websockets和Elasticsearch。

2.官网地址

3.下载Logstash地址

4.linux安装Logstash

下载logstash

  • yum -y install wget----------------------------(未安装wget请先安装)

解压logstash

  • tar -zxvf logstash-7.7.0.tar.gz

启动logstash(控制台输出)

  • ./logstash -e 'input {stdin {}} output {stdout {}}'------------------------------(bin目录下)

5.logstash案例实战之读取日志输出到elasticsearch

编写配置文件es_log.conf

  • touch es_log.conf----------------------------(config目录下)
  • vim es_log.conf
input{
  file{
    # 日志文件路径
    path => "/home/temp/elasticsearch7.x/elasticsearch-7.6.2-node1/logs/elasticsearch.log"
    type => "elasticsearch"
    start_position => "beginning" #从文件开始处读写
  }
}

output{
  elasticsearch{
    hosts => ["127.0.0.1:9200"] # es地址
    index => "es-message-%{+YYYY.MM.dd}"
  }
  stdout{
    codec => rubydebug
  }
}

指定配置文件启动

  • ./logstash -f ../config/es_log.conf

查看索引列表 http://localhost:9200/_cat/indices?v

  • curl http://localhost:9200/_cat/indices?v


查看数据 http://localhost:9200/es-message-2020.05.27/_search

  • curl http://localhost:9200/es-message-2020.05.27/_search

猜你喜欢

转载自blog.csdn.net/weixin_44096448/article/details/106357227