elk 日志分析系统Logstash+ElasticSearch+Kibana4

elk 日志分析系统

Logstash+ElasticSearch+Kibana4

  • logstash 管理日志和事件的工具
  • ElasticSearch 搜索
  • Kibana4 功能强大的数据显示client
  • redis 缓存

安装包

  • logstash-1.4.2-1_2c0f5a1.noarch.rpm
  • elasticsearch-1.4.4.noarch.rpm
  • logstash-contrib-1.4.2-1_efd53ef.noarch.rpm
  • kibana-4.0.1-linux-x64.tar.gz

安装jdk

openjdk或者Oracle的jdk都能够。


这里用openjdk

yum install java-1.7.0-openjdk

安装redis

yum install redis
/etc/init.d/redis start
查看redis中的键值
redis-cli keys '*'

安装測试ElasticSearch

rpm -ivh elasticsearch-1.4.4.noarch.rpm
确认9200port监听有正常返回值即可:
curl -X GET http://localhost:9200

[root@iZ28ywqw7nhZ ~]# curl -X GET http://localhost:9200
{
  "status" : 200,
  "name" : "Damballah",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.4.4",
    "build_hash" : "c88f77ffc81301dfa9dfd81ca2232f09588bd512",
    "build_timestamp" : "2015-02-19T13:05:36Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.3"
  },
  "tagline" : "You Know, for Search"
}

安装logstash

rpm -ivh logstash-1.4.2-1_2c0f5a1.noarch.rpm
logstash配置

最简单的是接受一个输入。然后将在输出出来:

bin/logstash -e 'input { stdin { } } output { stdout {} }'
helo
2015-03-19T09:09:38.161+0000 iZ28ywqw7nhZ helo

相似的还有:

bin/logstash -e 'input { stdin { } } output { stdout { codec => rubydebug } }'

可是上面两个并没有非常大的实际意义,我们能够将数据插入到elasticsearch中,然后用kibana显示出来。

  1. 首先要确保elasticsearch启动,9200监听。
  2. 然后插入数据:
/opt/logstash/bin/logstash  -e 'input { stdin { } } output { elasticsearch { host => localhost } }'

然后能够用kibana 查看
或者訪问
curl ‘http://localhost:9200/_search?

pretty’ 来查看数据

下载kibana,执行

kibana就是一个java包。

tar -xf kibana-4.0.1-linux-x64.tar.gz
bin/kibana > kibana.log &

里面配置index patterns ,用默认的即可了。

后记

基本上elk都是连着用的,连官网都是同一个官方站点。比方说elasticsearch通常是从logstash上面取数据的。

kibana 默认又是从elasticsearch上面取数据。三者结合的非常好。


很多其它功能正在探索中。elk 非常强大的数据收集查询分析开源解决方式。

http://logstash.net/docs/1.4.2/tutorials/getting-started-with-logstash

http://www.cnblogs.com/buzzlight/p/logstash_elasticsearch_kibana_log.html

Logstash 最佳实践

Upgrade Required Your version of Elasticsearch is too old. Kibana requires Elasticsearch 0.90.9 or above.
init: tty (/dev/tty4) main process killed by KILL signal

list all indexs
curl ‘localhost:9200/_cat/indices?

v’

delete

curl -XDELETE ‘localhost:9200/customer?

pretty’
curl ‘localhost:9200/_cat/indices?v’

http://www.elastic.co/guide/en/elasticsearch/reference/1.x/_index_and_query_a_document.html

转载于:https://www.cnblogs.com/wzzkaifa/p/7216466.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值