WindowsシステムログをwinlogbeatとElasticsearch + Kibana で可視化
elasticsearchとkibanaをdockerでインストール
elasticsearchとkibanaのインストールと起動
1 2 3 4 5 |
$ docker pull elasticsearch $docker pull kibana $ docker run -d -p 9200:9200 --name elasticsearch elasticsearch $ docker run -d -p 5601:5601 --name kibana --link elasticsearch:elasticsearch kibana |
起動したか確認します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ curl 192.168.0.1:9200 { "name" : "yQPB5QU", "cluster_name" : "elasticsearch", "cluster_uuid" : "Rpk4_ljSRcqXKj3dCthttg", "version" : { "number" : "5.0.1", "build_hash" : "080bb47", "build_date" : "2016-11-11T22:08:49.812Z", "build_snapshot" : false, "lucene_version" : "6.2.1" }, "tagline" : "You Know, for Search" } |
1 2 3 4 5 6 7 8 9 |
$ curl 192.168.0.4:5601 <script>var hashRoute = '/app/kibana'; var defaultRoute = '/app/kibana'; var hash = window.location.hash; if (hash.length) { window.location = hashRoute + hash; } else { window.location = defaultRoute; |
docker-composeを使用して2つのコンテナを一発で起動できるymlファイルを作成します。
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$ vim docker-conpose.yml elasticsearch: image: elasticsearch container_name: elasticsearch ports: - "9200:9200" kibana: image: kibana container_name: kibana links: - elasticsearch:elasticsearch ports: - "5601:5601" |
docker-conpose.ymlのあるディレクトリで下記コマンドを実行。
1 |
$ docker-compose up -d |
elasticsearchとkibanaのコンテナが立ち上がります。
winlogbeatのインストールと設定
winlogbeatは公式ページからダウンロードします
ダウンロードしたファイルを解凍して任意のディレクトリに設置します。場所はC:\としております。解凍したディレクトリの中のwinlogbeat.ymlを編集します。hostsのIPをelasticsearchのIPにする。 今回の環境では192.168.0.1としています。
1 2 3 4 |
#-------------------------- Elasticsearch output ------------------------------ output.elasticsearch: # Array of hosts to connect to. hosts: ["192.168.0.1:9200"] |
その後、Powershellを管理者権限で実行します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Windows PowerShell Copyright (C) 2016 Microsoft Corporation. All rights reserved. PSReadline モジュールを読み込めません。コンソールは PSReadline なしで実行されています。 PS C:\Windows\system32> cd C:\winlogbeat-5.0.1-windows-x86_64 PS C:\winlogbeat-5.0.1-windows-x86_64> Set-ExecutionPolicy RemoteSigned 実行ポリシーの変更 実行ポリシーは、信頼されていないスクリプトからの保護に役立ちます。実行ポリシーを変更すると、about_Execution_Policies のヘルプ トピック (http://go.microsoft.com/fwlink/?LinkID=135170) で説明されているセキュリティ上の危険にさらされる可能性があります。実行ポリシーを変更しますか? [Y] はい(Y) [A] すべて続行(A) [N] いいえ(N) [L] すべて無視(L) [S] 中断(S) [?] ヘルプ (既定値は "N"): Y PS C:\winlogbeat-5.0.1-windows-x86_64> . .\install-service-winlogbeat.ps1 Status Name DisplayName ------ ---- ----------- Stopped winlogbeat winlogbeat PS C:\winlogbeat-5.0.1-windows-x86_64> Invoke-RestMethod -Method Put -InFile win ogbeat.template.json -Uri http://192.168.0.1:9200/_template/winlogbeat acknowledged ------------ True PS C:\winlogbeat-5.0.1-windows-x86_64> Start-Service –Name winlogbeat |
サービスを起動したらelasticsearchにデータがたまります。
1 2 |
$ curl 192.168.0.1:9200/_cat/indices yellow open winlogbeat-2016.11.21 KIpRonKTQGy_Wk_wD0V0-A 5 1 9080 0 6.6mb 6.6mb |
ブラウザでkibanaに接続します。http://192.168.0.1:5601
index patternをwinlogbeat-*とし、@Timestampにしてcreateボタンを押します。
index作成後、左のDiscoverをクリックするとデータが可視化されています。
参考サイト
winlogbeat + Elasticsearch + Kibana で Windowsシステムログを可視化する ~ インストールも自動化 ~ - Qiita
# 0.はじめに
Elastic社より提供されている[winlogbeat(ver.1.2.3)](https://www.elastic.co/downloads/beats/winlogbeat)について試してみました。
Elastic社より提供されている[winlogbeat(ver.1.2.3)](https://www.elastic.co/downloads/beats/winlogbeat)について試してみました。
本記事...