EFK(Elasticsearch+Filebeat+Kibana)收集容器日誌
阿新 • • 發佈:2020-08-03
Elasticsearch
是一個實時的、分散式的可擴充套件的搜尋引擎,允許進行全文、結構化搜尋,它通常用於索引和搜尋大量日誌資料,也可用於搜尋許多不同型別的文件。
Beats 是資料採集的得力工具。將 Beats 和您的容器一起置於伺服器上,或者將 Beats 作為函式加以部署,然後便可在 Elastisearch 中集中處理資料。如果需要更加強大的處理效能,Beats 還能將資料輸送到 Logstash 進行轉換和解析。
Kibana 核心產品搭載了一批經典功能:柱狀圖、線狀圖、餅圖、旭日圖,等等。不僅如此,您還可以使用 Vega 語法來設計獨屬於您自己的視覺化圖形。所有這些都利用 Elasticsearch 的完整聚合功能。
Elasticsearch 通常與Kibana
一起部署,Kibana 是 Elasticsearch 的一個功能強大的資料視覺化 Dashboard,Kibana 允許你通過 web 介面來瀏覽 Elasticsearch 日誌資料。
EFK架構圖:
2|0安裝
這裡採用helm chart安裝
官方地址:https://github.com/elastic/helm-charts
1.安裝elasticsearch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
$ helm fetch elastic /elasticsearch
$ kubectl create ns logs $ helm repo add elastic https: //helm .elastic.co
#修改values.yaml檔案中pv為storageClass動態分配
volumeClaimTemplate:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "managed-nfs-storage"
resources:
requests:
storage: 30Gi
$ helm install -n elasticsearch --namespace=logs . /elasticsearch
|
檢視狀態
2.安裝kibana
1 2 3 4 5 6 7 8 9 |
$ helm fetch elastic /kibana
#修改values.yaml檔案中service為nodePort型別
service:
type : NodePort
port: 5601
nodePort: 30056
$ helm install -n kibana --namespace=logs . /kibana
|
檢視狀態
3.安裝filebeat
1 2 3 4 5 6 |
$ helm fetch elastic /filebeat
#預設讀取的是節點/var/lib下的所有檔案
# Root directory where Filebeat will write data to in order to persist registry data across pod restarts (file position and other metadata).
hostPathRoot: /var/lib
$ helm install -n kibana --namespace=logs . /kibana
|
檢視狀態,因為是DaemonSet型別所以每臺node都會裝一個。
3|0使用
登入kibana,建立index
可以過濾日誌