使用Docker快速部署ELK分析Nginx日誌實踐(二)

Kibana漢化使用中文界面實踐

1、背景

筆者在上一篇文章使用Docker快速部署ELK分析Nginx日誌實踐當中有提到如何快速搭建ELK分析Nginx日誌,可是這只是第一步,後面還有不少儀表盤須要配置,而對於大部分人來講,英文並非那麼好,但Kibana都是英文界面,這就阻礙了筆者熟悉Kibana的一些操做;node

因此筆者思考能不能將其漢化,在搜索引擎中找到了一些文章,發現漢化相對來講成本還算比較低,所以進行了一番實踐,整個操做流程即使是將前人的漢化包拿過來使用,但使用的過程漢化包的做者並無過多的講解,本文主要是講解如何使用漢化包以及操做過程的記錄。python

筆者上一篇文章使用Docker快速部署ELK分析Nginx日誌實踐URL地址:https://segmentfault.com/a/1190000016144694mysql

2、操做概述

  1. 漢化包下載
  2. 運行環境安裝
  3. 漢化效果演示

3、漢化包下載

筆者所使用的漢化包項目名稱爲Kibana_Hanization,在Github上進行了開源,URL地址以下nginx

https://github.com/anbai-inc/Kibana_Hanization

在上一篇文章當中筆者已經將/Users/song/dockerFile/掛載在容器的/data當中,所以能夠直接在宿主機中經過git拉取漢化包,而後去容器裏面運行它,參考命令以下git

cd /Users/song/dockerFile/ && git clone https://github.com/anbai-inc/Kibana_Hanization.git

4、運行環境安裝

安裝漢化包,須要完成三個步驟,首先須要有執行漢化包裏面工具的Python2.7環境,而後須要找到Kibana的安裝目錄,最後才能執行安裝,具體操做以下github

4.1 安裝Python2.7

筆者直接運行漢化包的時候發現此漢化工具依賴於Python2.7,而ELK中默認安裝的是Python3,所以筆者須要先安裝Python2.7的運行環境,操做以下redis

首先須要拉取Python倉庫地址sql

apt update

而後執行安裝,參考命令以下chrome

apt install python2.7

4.2 查找安裝位置

安裝好Python的運行環境以後,筆者還須要找到kibana的安裝位置,參考命令以下所示docker

find / -iname kibana

命令執行後返回的結果

/opt/logstash/x-pack/modules/azure/configuration/kibana
/opt/logstash/x-pack/modules/arcsight/configuration/kibana
/opt/logstash/modules/netflow/configuration/kibana
/opt/logstash/modules/fb_apache/configuration/kibana
/opt/kibana
/opt/kibana/src/core_plugins/kibana
/opt/kibana/node_modules/x-pack/plugins/ml/server/models/data_recognizer/modules/apache2/kibana
/opt/kibana/node_modules/x-pack/plugins/ml/server/models/data_recognizer/modules/nginx/kibana
/opt/kibana/node_modules/x-pack/plugins/monitoring/server/lib/kibana
/opt/kibana/node_modules/x-pack/plugins/monitoring/server/lib/metrics/kibana
/opt/kibana/node_modules/x-pack/plugins/monitoring/server/routes/api/v1/kibana
/opt/kibana/node_modules/x-pack/plugins/monitoring/public/views/kibana
/opt/kibana/node_modules/x-pack/plugins/monitoring/public/components/kibana
/opt/kibana/node_modules/x-pack/plugins/monitoring/public/directives/kibana
/opt/kibana/node_modules/@kbn/pm/src/utils/__fixtures__/kibana
/opt/kibana/bin/kibana
/etc/logrotate.d/kibana
/etc/init.d/kibana

根據返回結果和以往的經驗,大體猜想出安裝位置在/opt/kibana下,在獲得安裝目錄以後,如今筆者須要進入此前在宿主機經過git下載的漢化包目錄,由於運行elk容器的時候已經將宿主機目錄掛載進去,所以容器中能夠進入,參考嗎命令以下

cd /data/Kibana_Hanization

4.2 漢化包安裝

執行漢化命令

python2.7 main.py /opt/kibana/

返回結果

文件[/opt/kibana/optimize/bundles/kibana.bundle.js]已翻譯。
文件[/opt/kibana/optimize/bundles/commons.bundle.js]已翻譯。
文件[/opt/kibana/optimize/bundles/login.bundle.js]已翻譯。
文件[/opt/kibana/optimize/bundles/ml.bundle.js]已翻譯。
文件[/opt/kibana/optimize/bundles/monitoring.bundle.js]已翻譯。
文件[/opt/kibana/optimize/bundles/timelion.bundle.js]已翻譯。
文件[/opt/kibana/optimize/bundles/vendors.bundle.js]已翻譯。
文件[/opt/kibana/optimize/bundles/apm.bundle.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/ui_setting_defaults.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/translations/en.json]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/docker_metrics/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/netflow/elastic_cloud.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/netflow/on_prem_elastic_cloud.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/netflow/on_prem.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/netflow/common_instructions.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/kubernetes_metrics/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/apache_metrics/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/redis_metrics/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/apm/apm_server_instructions.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/apm/apm_client_instructions.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/nginx_metrics/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/system_metrics/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/system_logs/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/apache_logs/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/nginx_logs/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/redis_logs/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/mysql_metrics/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/server/tutorials/mysql_logs/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/common/tutorials/filebeat_instructions.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/common/tutorials/metricbeat_instructions.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kibana/public/dashboard/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/timelion/index.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kbn_vislib_vis_types/public/line.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kbn_vislib_vis_types/public/area.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kbn_vislib_vis_types/public/heatmap.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js]已翻譯。
文件[/opt/kibana/src/core_plugins/kbn_vislib_vis_types/public/histogram.js]已翻譯。
文件[/opt/kibana/src/ui/public/chrome/directives/global_nav/global_nav.js]已翻譯。

恭喜,Kibana漢化完成!

筆者執行這條命令時間大約在10秒鐘左右。

5、漢化效果演示

通過上一步操做,已經完成了漢化包的安裝,如今筆者進入Kibana的主頁來驗證漢化的效果,Kibana主頁的URL地址以下

http://localhost:5601/app/kibana#/home?_g=()

但在實際漢化後發現並無徹底漢化,筆者所使用的ELK版本爲6.4.0,效果以下圖所示

image

而漢化包中介紹的漢化效果效果卻以下圖所示

image

筆者猜想多是本身使用的ELK版本比較新,而漢化包還沒用跟上節奏所致使,不過效果已經很棒了;筆者接着又打開了幾個頁面,發現漢化效果大都在80%左右,視圖建立URL地址以下

http://localhost:5601/app/kibana#/visualize/new?_g=()

在瀏覽器中打開視圖建立頁面後,展示漢化以下圖所示

image


做者:湯青松

微信:songboy8888

日期:2018-08-31

相關文章
相關標籤/搜索