Elasticsearchをインストールする。
まず、javaが必要なのでインストールする。
# yum -y install java-1.7.0-openjdk
Elasticsearchをインストールする
# wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.4.noarch.rpm
# rpm -ivh elasticsearch-1.2.0.noarch.rpm
起動させる
service elasticsearch start
fluent-plugin-elasticsearchをインストール
まず、gcc libcurl-devel をインストール
yum -y install gcc libcurl-devel
fluent-plugin-elasticsearchをインストールする際に必要。
fluent-plugin-elasticsearchをインストールする。
/usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-elasticsearch
td-agent.confを書き換え、
ApacheのログをElasticsearchに記録するよう設定する。
ApacheのログをElasticsearchに記録するよう設定する。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# vi /etc/td-agent/td-agent.conf <source> type tail path /var/log/httpd/access_log pos_file /var/log/td-agent/access_log.pos format apache2 tag apache.access </source> <match apache.access> type elasticsearch host localhost port 9200 type_name access_log logstash_format true flush_interval 3s </match> |
検索コマンド
curl -XGET ‘http://localhost:9200/logstash-2014.10.01/ny_acl_log/_search?query=process:nserver
curl -XGET ‘http://localhost:9200/logstash-2014.10.01/ny_acl_log/_search?query=process:nserver
全データを削除
# curl -XDELETE ‘http://localhost:9200/*’ {“acknowledged”:true}