開始在公司實施的小應用,慢慢完善之~~~~~~~~文檔制作 了好作運維同僚之間的前期普及。。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
軟體下載下傳位址:
<a href="https://www.elastic.co/downloads">https://www.elastic.co/downloads</a>
在實際部署中,根據伺服器的性能配置,elk可部署在同一個機器上,也可以分别安裝在不同的機器上,隻要能保證網絡連通。但建議elasticsearch和kibana部署在同一個機器上,這樣可以加快檢索速度。
shipper: 分布式部署在各應用伺服器,收集并轉發日志。
broker:将日志集中收集、排隊并轉發。
indexer:收集和轉發資料至elasticsearch。在elasticsearch建立索引并存儲日志資料。
web interface:基于nginx的kibana3 http通路接口,提供ui搜尋elasticsearch的資料。
一,elasticsearch
1,解壓elasticsearch-1.4.4.tar.gz
2,啟動指令bin/elasticsearch
二,logstash
1,解壓logstash-1.4.2.tar.gz
2.a 作為indexer檔案的logstash.conf(樣例,從redis裡擷取資料)
input {
redis {
host => '10.x.x.x'(redis的位址)
data_type => 'list'
port => "6379"
key => 'logstash:redis'
type => 'redis-input'
}
output {
elasticsearch {
host => "10.x.x.x"(elasticsearch的位址)
2.b 作為shipper的logstash.conf配置(樣例,将日志注入redis,可作過濾)
file {
type => "app_ip_java_debug"
path => "/var/logs/tomcat/*.out"
#filter {
# grep {
# match => [ "@message", "freshclam" ]
# }
host => '10.x.x.x'(送出到redis的位址)
3,啟動指令bin/logstash agent -f logstash.conf
三,redis
1, 下載下傳redis-2.8.18.tar.gz
2, 安裝參考http://blog.csdn.net/testcs_dn/article/details/39756477
四,kibana
1, 解壓kibana-4.0.0-linux-x64.tar.gz
2, 編輯conf/kibana.yml檔案(将elasticseach服務位址定位)
elasticsearch_url: "http://localhost:9200"
3, 啟動指令bin/kibana
五,附錄(網上其它類似配置和搜尋條件)
以nginx通路日志為例,配置如下:
1)shipper.conf
type => "nginx"
path => [ "/nginx/path/logs/access.log" ]
start_position => "beginning"
sincedb_path => "/some/place/sincedb_nginx"
filter {
grok {
match => [ "message", "%{ip:client} (%{user:indent}|-) (%{user:auth}|-) \[%{httpdate:local_time}\] \"%{word:method} (?<request_url>%{uripath})(?<request_params>%{uriparam}) http/%{number:protocol}\" %{number:status} %{number:bytes_sent} %{qs:http_referer} %{qs:user_agent}" ]
date {
locale => "en"
match => [ "local_time", "dd/mmm/yyyy:hh:mm:ss z" ]
timezone => "asia/shanghai"
host => "192.168.1.130"
port => 6379
data_type => "list"
key => "nginx"
2) indexer.conf
常用的有以下幾種
1)邏輯查詢
2)範圍查詢
3)子查詢
4)通配符
5)保留字元轉義