侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

ELK(Elasticsearch + Logstash + Kibana) 日志分析平台

2023-11-21 星期二 / 0 评论 / 0 点赞 / 65 阅读 / 4657 字

前言:在大神的基础上自己测试,留个记录。 Elasticsearch + Logstash + Kibana(ELK)是一套开源的日志管理方案,分析网站的访问情况时我们一般会借助Google/百度/

前言:在大神的基础上自己测试,留个记录。

 

Elasticsearch + Logstash + Kibana(ELK)是一套开源的日志管理方案,分析网站的访问情况时我们一般会借助Google/百度/CNZZ等方式嵌入JS做数据统计,但是当网站访问异常或者被攻击时我们需要在后台分析如Nginx的具体日志,而Nginx日志分割/GoAccess/Awstats都是相对简单的单节点解决方案,针对分布式集群或者数据量级较大时会显得心有余而力不足,而ELK的出现可以使我们从容面对新的挑战。

  • Logstash:负责日志的收集,处理和储存
  • Elasticsearch:负责日志检索和分析
  • Kibana:负责日志的可视化

扩展阅读

CentOS 7.x安装ELK(Elasticsearch+Logstash+Kibana) - http://www.chenshake.com/centos-install-7-x-elk-elasticsearchlogstashkibana/

Centos 6.5 安装nginx日志分析系统 elasticsearch + logstash + redis + kibana -http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=17291169&id=4898582

logstash-forwarder and grok examples - https://www.ulyaoth.net/threads/logstash-forwarder-and-grok-examples.32413/

三斗室 - http://chenlinux.com/

elastic - https://www.elastic.co/guide

LTMP索引 - http://wsgzao.github.io/index/#LTMP

组件预览

JDK - http://www.oracle.com/technetwork/java/javase/downloads/index.html

Elasticsearch - https://www.elastic.co/downloads/elasticsearch

Logstash - https://www.elastic.co/downloads/logstash

Kibana - https://www.elastic.co/downloads/kibana

redis - http://redis.io/download

一、服务端

java

java -versionopenjdk version "1.8.0_121"OpenJDK Runtime Environment (build 1.8.0_121-b13)OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)

Elasticsearch

#下载elasticsearch-2.4.4.tar.gztar -zxvf elasticsearch-2.4.4.tar.gzcd elasticsearch-2.4.4#建议是使用其他用户启动,我这方便就使用root了。不建议。./bin/elasticsearch -Des.insecure.allow.root=true#下载head插件https://github.com/mobz/elasticsearch-head #到plugins目录###################################################################################5.2.X的版本安装不同#参考http://blog.csdn.net/ronmy/article/details/63685254#一、安装nodejs  curl -sL -o /etc/yum.repos.d/khara-nodejs.repo https://copr.fedoraproject.org/coprs/khara/nodejs/repo/epel-7/khara-nodejs-epel-7.repoyum install -y nodejs nodejs-npm#二、安装grunt npm install grunt-clinpm install gruntgrunt -version#三、安装head git clone git://github.com/mobz/elasticsearch-head.git cd elasticsearch-headnpm install vim _site/app.js# 修改 『http://localhost:9200』字段到本机ES端口与IPgrunt server# 打开浏览器 http://localhost:9100####################################################################################

 

Kibana

这个简单,直接下载,放到apache的目录,然后启动

#下载kibana#kibana-4.6.4-linux-x86_64.tar.gztar -zxvf kibana-4.6.4-linux-x86_64.tar.gzmv kibana-4.6.4 /vaw/www/html/kibana#修改配置文件#vim config/kibana.ymlserver.port: 5601server.host: "0.0.0.0"elasticsearch.url: "http://192.168.30.98:9200"kibana.index: ".kibana"#启动cd /var/www/html/kibana/./bin/kibana

 

Logstash

#下载logstash-2.4.1.tar.gztar -zxvf logstash-2.4.1.tar.gz -C /usr/local/#进入/usr/local/logstash/etc#新建文件logstash_agent.conf#内容如下:input {    file {      type => "http.access"      path => ["/var/log/httpd/access_log"]    }      file {      type => "http.error"      path => ["/var/log/httpd/error_log"]    }      file {      type => "messages"      path => ["/var/log/messages"]    }  }    output {      stdout{        codec => rubydebug}  elasticsearch {      hosts => "192.168.30.98:9200"    index => "logstash-%{type}-%{+YYYY.MM.dd}"  }  } 

启动logstash

/usr/local/logstash/bin/logstash -f /usr/local/logstash/etc/logstash_agent.conf

打开浏览器,访问Elasticsearch

http://192.168.30.98:9200/_plugin/head/

访问kibana

http://192.168.30.98:5601

 

 

广告 广告

评论区