Windows环境下搭建ELK环境

Windows环境下搭建ELK环境

搭建Elastic Stack环境

  1. 通过官网下载相关包,网址:https://www.elastic.co/cn/downloads/elasticsearch

Elastic Stack

  1. 运行bin/elasticsearch (or bin\elasticsearch.bat on Windows)

  2. 在浏览器上访问http://localhost:9200,出现如下截图内容代表ES部署成功。

运行情况

搭建Logstash环境

  1. 下载logstash文件,网址:https://www.elastic.co/cn/downloads/logstash
    logstash
    下载Zip将Zip解压到本地。
  2. 新建Logstash.conf文件,将logstash.conf文件复制到bin文件夹下。
  • 通过检测文件的方式输出日志:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    input {
    file {
    path => ["D:/Log/*.log"] 检测文件,通过检测文件变化输出到ES中。
    start_position => "beginning"
    }
    }

    filter {
    date {
    match => [ "timestamp" , "YYYY-MM-dd HH:mm:ss" ]
    }
    }

    output {
    elasticsearch {
    hosts => ["localhost:9200"] ES地址
    }
    stdout {
    codec => rubydebug
    }
    }
  • 通过TCP方式进行监听日志信息。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    input {
    tcp {

    port => 9250 TCP端口号
    codec => json_lines
    }
    }

    filter {
    date {
    match => [ "timestamp" , "YYYY-MM-dd HH:mm:ss" ]
    }
    }

    output {
    elasticsearch {
    hosts => ["localhost:9200"]
    }
    stdout {
    codec => rubydebug
    }
    }
  1. 运行bin/logstash -f logstash.conf –t -t代表检测文件语法格式是否有误。
    运行结果
    通过访问9600可以得到如下内容:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    {
    "host": "DESKTOP-AVNGAHE",
    "version": "6.4.1",
    "http_address": "127.0.0.1:9600",
    "id": "bbb75ede-2654-4312-a80b-77d2c431ee73",
    "name": "DESKTOP-AVNGAHE",
    "build_date": "2018-09-13T23:17:51Z",
    "build_sha": "cee0d74663380e80c2a38cf5a9ccffb9a0cfa215",
    "build_snapshot": false
    }

搭建Kibana环境

  1. 下载Kibana,选择Windows版本。地址:https://www.elastic.co/cn/downloads/kibana
    下载地址
  2. 打开config/kibana.yml文件,设置elasticsearch.url 为http://localhost:9200
  3. 运行bin/kibana或者bin/kiana.bat(在windows下运行)。
  4. 访问地址localhost://5601
    访问的地址
  5. 配置日志打开Discover菜单,创建索引
    创建索引
  6. 创建筛选器–根据时间筛选
    创建筛选器–根据时间筛选
  7. 再次返回到 Discover
    Discover
文章目录
  1. 1. Windows环境下搭建ELK环境
    1. 1.1. 搭建Elastic Stack环境
    2. 1.2. 搭建Logstash环境
    3. 1.3. 搭建Kibana环境
|
载入天数...载入时分秒...