elk配置安装

1.filebeat配置

1.1下载

curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.5.1-linux-x86_64.tar.gz

1.2配置

修改filebeat.yml配置文件

filebeat.inputs:
- type: log
  paths:
    - /log*
  tags: ["tag"]
output.logstash:
  hosts: [""]

或者直接打入到es:

filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /home/*
  #解析json到es,否则会变成json字符串存入message
  json.keys_under_root: true
  json.overwrite_keys: true

setup.template.settings:
  index.number_of_shards: 3
  index.number_of_replicas: 0
  index.codec: best_compression

output.elasticsearch:
  hosts: ["host","host"]
  username: "elastic"
  password: "pass"
  indices:
   - index: "index-%{+yyyyMM}"

processors:
  - drop_fields:
      fields: ["log","input","ecs","host","agent","cloud"]

主要是input和output

1.3启动

在filebeat目录下执行
nohup ./filebeat -e -c filebeat.yml &

2.logstash安装

2.1下载

wget https://artifacts.elastic.co/downloads/logstash/logstash-7.5.1.tar.gz

2.2配置

在config目录下创建conf.d目录,在conf.d目录下创建文件logstash.yml

input {
        beats {
                port => "5044"
        }
}

filter {
    if "aa" in [tags] {
        json {
            source => "message"
            remove_field => ["message", "beat", "offset", "[resp][data]"]
        }
        date {
            match => ["req_timestamp", "UNIX_MS"]
            remove_field => ["req_timestamp"]
        }
    } else if "bb" in [tags] {
        json {
            source => "message"
            remove_field => ["message", "beat", "offset", "[resp][data]","agent","ecs","log","input","@version"]
        }
        date {
            match => ["req_timestamp", "UNIX_MS"]
            remove_field => ["req_timestamp"]
        }
         ruby {
            code => "event.set('index_month', event.get('@timestamp').time.localtime.strftime('%Y%m'))"
       }
    } else if "cc" in[tags] {
        json {
            source => "message"
            remove_field => ["message", "beat", "offset"]
        }
        date {
            match => ["req_timestamp", "UNIX_MS"]
            remove_field => ["req_timestamp"]
        }
    } else if "dd" in [tags]{
         json {
            source => "message"
            remove_field => ["message", "beat", "offset","agent","input","ecs","@version","log"]
        }
     }else if "ee" in [tags]{
        json {
            source => "message"
            remove_field => ["message", "beat", "offset","agent","input","ecs","@version","log"]
        }
        date {
            match => ["req_timestamp", "UNIX_MS"]
            remove_field => ["req_timestamp"]
        }
         ruby {
            code => "event.set('index_month', event.get('@timestamp').time.localtime.strftime('%Y%m'))"
       }
    }else if "dd" in [tags]{

         json {
            source => "message"
            remove_field => ["message", "beat", "offset","agent","input","ecs","@version","log"]
        }
   }
}

output {

    if "aa" in [tags] {
                elasticsearch {
                        codec => "json"
                        hosts => "192.168.102.179:9200"
                        index => "aa"
                }
    } else if "bb" in [tags]{
                elasticsearch {
                        codec => "json"
                        hosts => "192.168.102.179:9200"
                        index => "bb-%{index_month}"
                }

    } else if "cc" in [tags] {
        elasticsearch {
            codec => "json"
            hosts => "192.168.102.179:9200"
            index => "cc_log"
        }
    }

else if "recommend" in [tags] {
        kafka {
            codec => json
            topic_id => "bbb"
            bootstrap_servers => "192.168.102.179:9092"
        }
    }else if "api" in [tags] {
     kafka {
            codec => json
            topic_id => "aaa"
            bootstrap_servers => "192.168.102.179:9092"
        }
   }
}

pipeline配置

- pipeline.id: main
  path.config: "/data/logstash-7.5.1/config/conf.d/*.conf"

2.3启动

启动bin目录下的脚本

nohup ./bin/logstash "--path.settings" "./config"  &

3.kibana安装

3.1下载

wget https://artifacts.elastic.co/downloads/kibana/kibana-6.3.2-linux-x86_64.tar.gz

3.2 配置

elasticsearch.hosts: ["http://192.168.102.179:9200"]
server.host: "0.0.0.0"

3.3启动

nohup ./bin/kibana --allow-root &
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值