filebeat+kafka+ELK5.4安装与部署
admin
2023-03-21 11:01:30
0

用ELK打造强大的日志分析平台,具体拓扑结构如下:


filebeat+kafka+ELK5.4安装与部署


在这里我们将进行kafka+filebeat+ELK5.4的部署

各软件版本

jdk-8u131-linux-i586.tar.gz
filebeat-5.4.0-linux-x86_64.tar.gz
elasticsearch-5.4.0.tar.gz
kibana-5.4.0-linux-x86_64.tar.gz
logstash-5.4.0.tar.gz
kafka_2.11-0.10.0.0.tgz

1、JDK安装配置(略过)


2、ELK安装与配置

创建ELK用户,并进行文件解压

1.elasticsearch配置

[elk@localhost elasticsearch-5.4.0]$ vi config/elasticsearch.yml 
.....
network.host: 192.168.12.109
#
# Set a custom port for HTTP:
#
http.port: 9200

..........

保存,启动
[elk@localhost elasticsearch-5.4.0]$ nohup bin/elasticsearch &
验证
#
[elk@localhost elasticsearch-5.4.0]$ curl http://192.168.12.109:9200
{
  "name" : "aCA2ApK",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "Ea4_9kXZSaeDL1fYt4lUUQ",
  "version" : {
    "number" : "5.4.0",
    "build_hash" : "780f8c4",
    "build_date" : "2017-04-28T17:43:27.229Z",
    "build_snapshot" : false,
    "lucene_version" : "6.5.0"
  },
  "tagline" : "You Know, for Search"
}

2、kibana安装与配置

[elk@localhost kibana-5.4.0-linux-x86_64]$ vi config/kibana.yml 
## Kibana is served by a back end server. This setting specifies the port to use.
server.port: 5601

# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: "192.168.12.109"
..........
# The URL of the Elasticsearch instance to use for all your queries.
elasticsearch.url: "http://192.168.12.109:9200"
..........
[elk@localhost kibana-5.4.0-linux-x86_64]$ nohup bin/kibana &

在浏览器访问  能访问即可


3、kafka安装与配置

这里我们只做单机192.168.12.105部署单节点《centos kafka单包单机部署


4、logstah安装与配置

[elk@localhost logstash-5.4.0]$ vi nginx.conf    这里新生成一个配置文件

input {
       kafka  {
       codec => "json"
     topics_pattern => "logstash-.*"
     bootstrap_servers => "192.168.12.105:9092"
     auto_offset_reset => "latest"
     group_id => "logstash-g1"
  }


}

filter {
    if "nginx-accesslog" in [tags] {
        grok {
                match => { "message" => "%{IPORHOST:http_host} %{IPORHOST:clientip} - %{USERNAME:remote_user} \[%{HTTPDATE:timestamp}\] \"(?:%{WORD:http_verb} %{NOTSPACE:http_request}(?: HTTP/%{NUMBER:http_version})?|%{DATA:raw_http_request})\" %{NUMBER:response} (?:%{NUMBER:bytes_read}|-) %{QS:referrer} %{QS:agent} %{QS:xforwardedfor} %{NUMBER:request_time:float} %{GREEDYDATA:traceID}"}
        }
        mutate {
                convert => ["status","integer"]
                convert => ["body_bytes_sent","integer"]
                convert => ["request_time","float"]
        }
        geoip {
                source=>"remote_addr"
        }
        date {
                match => [ "timestamp","dd/MMM/YYYY:HH:mm:ss Z"]
        }
        useragent {
                source=>"http_user_agent"
        }
}



    if "tomcat-accesslog"  in [tags] {
        grok {
           match => { "message" => "%{IPORHOST:clientip} \[%{HTTPDATE:timestamp}\] \"(?:%{WORD:http_verb} %{NOTSPACE:http_request}(?: HTTP/%{NUMBER:http_version})?|%{DATA:raw_http_request})\" %{NUMBER:response} (?:%{NUMBER:bytes_read}|-) %{QS:referrer} %{NUMBER:request_time:float} %{GREEDYDATA:traceID}"}
            }
        date {
               match => [ "timestamp","dd/MMM/YYYY:HH:mm:ss Z"]
        }
}
}

output {

    elasticsearch {
      hosts => ["192.168.12.109:9200"]
        index => "logstash-%{type}-%{+YYYY.MM.dd}"
        document_type => "%{type}"
    }

#stdout { codec => rubydebug }
}

保存,并启动
[elk@localhost logstash-5.4.0]$ nohup bin/logstash -f nginx.conf &

5、filebeat安装与配置

将filebeat分别拷贝到需要采集的服务器,进行解压,在这里我们分别采集Nginx,tomcat日志

Nginx服务器

[user@localhost filebeat-5.4.0-linux-x86_64]$ vi filebeat.yml 
filebeat.prospectors:
- input_type: log
  paths:
    - /data/programs/nginx/logs/access.log
  tags: ["nginx-accesslog"]
  document_type: nginxaccess
tags: ["nginx-test-194"]
output.kafka:
  enabled: true
  hosts: ["192.168.12.105:9092"]
  topic: logstash-%{[type]}


[user@localhost filebeat-5.4.0-linux-x86_64]$nohup filebeat -c filebeat.yml &

tomcat服务器

[user@localhost filebeat-5.4.0-linux-x86_64]$ vi filebeat.yml
 filebeat.yml 
filebeat.prospectors:
- input_type: log
  paths:
    - /data/tomcat/logs/localhost_access_log*
  tags: ["tomcat-accesslog"]
  document_type: tomcataccess
tags: ["tomcat103"]
output.kafka:
  enabled: true
  hosts: ["192.168.12.105:9092"]
  topic: logstash-%{[type]}
  
[user@localhost filebeat-5.4.0-linux-x86_64]$nohup filebeat -c filebeat.yml &


完成以上,我们的平台就搭建好了,接下来我们创建索引

输入:logstash-nginxaccess*

filebeat+kafka+ELK5.4安装与部署

输入logstash-tomcataccess*

filebeat+kafka+ELK5.4安装与部署


数据通过filebeat到kafka、ELK成功展示出来

filebeat+kafka+ELK5.4安装与部署


来张炫图

filebeat+kafka+ELK5.4安装与部署



相关内容

热门资讯

AI开源公开信签署企业增至50... IT之家 7 月 26 日消息,英伟达、微软、IBM、Meta 等 25 家美国科技企业本周(7 月...
南阳快手短视频代运营企业的服务... 在短视频平台快速发展的背景下,企业通过快手等渠道进行内容运营已成为常见的市场动作。对于希望借助短视频...
普通人该如何跟上科技发展的步伐 这个被称作科技的词汇, 听起来既有宏大之感, 又颇为遥远, 好似仅仅归属于在实验室里专心致志钻研的科...
原创 王... 菲尔兹奖名单一出,邓煜和王虹两位华人数学家共同获奖,本应是一件令人振奋的喜讯。然而,王虹那段仅3分1...
《万物》杂志首个阅读空间亮相正... 26日,由国内知名的青少年家庭科普期刊《万物》杂志与广州正佳自然科学探索中心联合打造的阅读互动空间—...
从康复机器人到脑机接口 智能康... 天津北方网讯:对脑卒中患者来说,重新抬起手臂、迈出一步,往往需要持续的康复训练,逐步恢复运动功能;对...
原创 苹... 当苹果、谷歌、斯坦福、麻省理工都无法留住一位年轻的中国AI天才时,究竟是什么力量吸引他毅然回国?为何...
为什么新能源车供应链要本地化? 当前汽车产业变革加速,电动化成为核心发展方向。车企为了在激烈市场中站稳脚跟,必须优化生产结构。其中,...
携程罚单的真正影响,不是酒店变... 文 | 听风译码 7月25日,市场监管总局对携程开出51.79亿元天价罚单。 全网叫好。 但如果你...
自己管理自己,我国成功发射两颗... 7月24日消息,力箭一号遥十五运载火箭今日在东风商业航天创新试验区成功发射,以“一箭5星”方式将5颗...