EFK 設定 / 動作確認

# 概要
 - k8sテスト環境構築<br>
<b>EFK 設定 / 動作確認</b>

# 構築目次
 - [全体目次] (https://qiita.com/prodigy413/items/89fcb8cfb71e80f541d8)

# 環境
 - Rancher: v2.4.8
 - kubernetes(Client): v1.19.1
 - kubernetes(Server): v1.18.8
 - ECK(Elastic Cloud on Kubernetes): v1.2.1
 - Elasticsearch: v7.9.2
 - Kibana: v7.9.2
 - Fluentd: v1.9.3

# Kibana 設定
 - 作業場所: ClientPC
 - Kibanaにログイン  
URL : <b>https://kibana.test.local</b>

### Sample User 追加
左側のメニュー → [<b>Stack Management</b>]クリック
![4-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/c3d98668-b76d-33c9-dd97-719d6ab7d061.png)
![4-2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/f857d427-2a80-53d1-56df-faf7150eb528.png)

Security[<b>Users</b>] → [<b>Create user</b>]クリック
![5-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/0e801cdc-5e81-9413-a5e6-b50b16cd86a6.png)
![5-2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/7356cea1-2f25-dcc6-a11c-db21d46919fd.png)

[Username]、[Password]記入
[Roles]は`superuser`追加 → [<b>Create user</b>]クリック
![30-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/935bff9b-d46e-5cfd-df36-87b76a7f61d3.png)

### Index pattern 作成
左側のメニュー → [<b>Stack Management</b>]クリック
![4-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/c3d98668-b76d-33c9-dd97-719d6ab7d061.png)
![4-2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/f857d427-2a80-53d1-56df-faf7150eb528.png)
Kibana[<b>Index Patterns</b>] → [<b>Create index pattern</b>]クリック
![7-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/3a5c60ec-7666-8865-73d9-7bf004e881a2.png)
![8_2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/d6cae466-2546-beb1-0b3d-dee7f6eaa80d.png)
[Index pattern name]に`logstash-*`入力 → [<b>Next step</b>]クリック
![8-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/af7811b5-1745-6615-a5e6-49884b483793.png)
[Time filed]は`@timestamp`選択 → [<b>Create index pattern</b>]クリック
![9-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/ac296f23-cce7-3ff9-17f5-5d43ff08b9f6.png)

### 確認
左側のメニュー → Kibana[<b>Discover</b>]クリック
![4-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/c3d98668-b76d-33c9-dd97-719d6ab7d061.png)
![31-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/44b0f8c5-c05f-934f-5a64-2f62d4d8651f.png)
ログ確認
![11-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/0cc527fe-01dc-4888-99f4-29a0e186e0fa.png)

# Sample Dashboard 作成
 - 作業場所: ClientPC

### Discover filter 設定
左側のメニュー → Kibana[<b>Discover</b>] → [<b>Add filter</b>]クリック
![4-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/c3d98668-b76d-33c9-dd97-719d6ab7d061.png)
![31-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/44b0f8c5-c05f-934f-5a64-2f62d4d8651f.png)
![11-2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/02801f50-dc3d-c02e-499f-f7ef37cac9f4.png)
以下にように設定 → [<b>Save</b>]クリック
・[Field]: <b>kubernetes.namespace_name.keyword</b>
・[Operator]: <b>is</b>
・[Value]: <b>default</b>
![13-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/4316d47e-e65b-a729-c8bf-ada5fd0c6600.png)
・[Available fields]: [<b>kubernetes.pod_name</b>]と[<b>log</b>]を[<b>Add</b>]
![14-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/2c7dd84f-e6f9-613e-3870-341219b39bc9.png)
![15-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/ea830860-fa2c-033e-e926-02953f97d6a9.png)
![17-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/49748d5c-b207-2bfd-31ad-08ea77a2daed.png)
設定後、ログ確認
![32-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/c63d2d27-8099-a592-3038-401a61e1e169.png)

### 設定保存
[<b>Save</b>] → 「Title」に`ns-default-log`と書いて[<b>Save</b>]クリック
![33-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/a96a94ff-7f3f-5874-2a41-09a30eff081f.png)
![19-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/800596b7-86aa-7981-0cc5-8c2d37ffde00.png)

### Visualization 作成
左側のメニュー → Kibana[<b>Visualize</b>] → [<b>Create new visualization</b>]クリック
![4-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/c3d98668-b76d-33c9-dd97-719d6ab7d061.png)
![31-2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/6f38ccd0-b951-f375-d998-a90a24e67f4e.png)
![22_2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/36443cc8-8406-828f-a23f-d94b802e521b.png)
[<b>Vertical Bar</b>]選択
![21-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/3479c633-6c59-0222-c743-4e180dc90264.png)
[<b>logstach-\*</b>]選択
![24_1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/df87e1a0-c39e-6bfa-605e-784e63350cee.png)
Metrics[<b>Y-axis</b>]設定:
・[Aggregation]: <b>Count</b>
・[custom label]: <b>Total</b>
![25_1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/4a1918b4-572d-48f7-a5bb-5f962f0714c7.png)
Buckets[<b>Add</b>] → [<b>X-axis</b>]クリック
![26_1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/1c250f3d-5096-4ccf-ede4-054d157c3e4c.png)
Metrics[<b>X-axis</b>]設定:
・[Aggregation]: <b>Terms</b>
・[Field]: <b>kubernetes.pod_name.keyword</b>
・[Order by]: <b>Metric:Total</b>
・[Order]: <b>Descending</b>
・[Size]: <b>10</b>
![29_1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/e8009772-d39f-ee96-7225-06b9134b4fda.png)
[<b>Update</b>]クリック
![22-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/7dad47b3-6dd9-aa57-4bbe-843a43e0fd03.png)
[<b>Add filter</b>]クリック
![11-2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/02801f50-dc3d-c02e-499f-f7ef37cac9f4.png)
以下にように設定 → [<b>Save</b>]クリック
・[Field]: <b>kubernetes.namespace_name.keyword</b>
・[Operator]: <b>is</b>
・[Value]: <b>default</b>
![13-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/4316d47e-e65b-a729-c8bf-ada5fd0c6600.png)
確認
![23-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/5aef3ebc-d3ba-321c-dafa-4c7ec2a1f3a3.png)

### 設定保存
[<b>Save</b>] → 「Title」に`ns-log-total`と書いて[<b>Save</b>]クリック
![23-2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/2156993c-2469-33a2-1d6d-abb82419990e.png)
![24-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/4d4bd956-64c4-e69f-3ee2-242d3a593fd5.png)

### Dashboard 作成
左側のメニュー → Kibana[<b>Dashboard</b>] → [<b>Create new dashboard</b>]クリック
![4-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/c3d98668-b76d-33c9-dd97-719d6ab7d061.png)
![31-3.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/cc228dad-933c-f927-f047-ed0996d7065d.png)
![33_2.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/b5f67c70-c1f1-a3ba-bb0e-2c0f7de8ddd3.png)
[<b>Add an existing</b>]クリック
![26-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/d5ace8cd-993d-818f-de2b-60fbdaf2efd7.png)

作成したPanel選択 → [<b>X</b>]クリック
![27-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/45ff27b6-9d2e-79ff-099f-be6654e1de3b.png)
Dashboard 確認
![29-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/83b0325c-cdf3-d8b5-efab-75106a81fa0f.png)
[<b>Save</b>] → 「Title」に`ns-default-dashboard`と書いて[<b>Save</b>]クリック
![34.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/0a4e107d-326b-007f-c131-9a76c0864093.png)
![35-1.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/561025/82d4df34-c7ce-2ce8-b056-249528178650.png)