Linux 環境 離線 ELK7.4.0之APM服務安裝(含kibana配套使用說明)

ELK部分文章是需要配套一起看纔可以完整了解這塊的搭建使用,目前文檔將搭建和使用分篇來介紹,通過ELK文檔中入口來找到你想要的部分內容。

APM服務分爲兩部分,服務端 apm-server服務端,獨立部署服務,用於收集客戶端發送過來的監控信息,另一部分是apm客戶端,需要集成到相應的服務代碼裏,目前官網提供了各種各樣的接入demo.這塊代碼入侵性小,無需代碼改造,就java而言,只需要調整啓動參數,加一個java代理即可,原業務代碼可以不做任何改動。

目前對此的研究和驗證不多,生產環境使用APM對於系統本身性能的影響還未驗證,如有必要建議做壓力測試的對比。這部分內容適用於rest接口服務效果會更好,針對目前我的業務裏rpc類型的接口居多,rest類型的接口較少,很多功能的用處都體現不出來,對我的系統來說這個功能不是那麼強大,但是不可否認,服務的狀態監控上這個是沒問題的。

apm-server安裝指南

apm-server解壓安裝包

cd /home/elk/apm
tar -xvf apm-server-7.4.2-linux-x86_64.tar.gz # 解壓文件到當前目錄,可以通過 -C 來指定解壓目錄

在這裏插入圖片描述

apm-server配置屬性apm-server.yml

完整的樣例(針對修改的部分內容提供,默認的內容就不粘貼)


################################################ APM Server ################################################

apm-server:
  # Defines the host and port the server is listening on. Use "unix:/path/to.sock" to listen on a unix domain socket.
  #apm服務端對外提供http訪問ip,端口 目前apm-server本身不支持集羣,可以通過反向代理的服務來實現
  host: "ip:8200"

  #允許在kibana中對apm客戶端的配置做調整
  kibana:
    # For APM Agent configuration in Kibana, enabled must be true.
    #enabled: false
    enabled: true

    # Scheme and port can be left out and will be set to the default (`http` and `5601`).
    # In case you specify an additional path, the scheme is required: `http://localhost:5601/path`.
    # IPv6 addresses should always be defined as: `https://[2001:db8::1]:5601`.
    #host: "localhost:5601"
    #配置對應kibana的訪問地址,
    host: "ip:5601"

下面重要片段
index-lifecycle-management(ILM)策略,自定義索引規則詳細描述見Filebeat部分描述

#================================= Template =================================

# A template is used to set the mapping in Elasticsearch.
# By default template loading is enabled and the template is loaded.
# These settings can be adjusted to load your own template or overwrite existing ones.

# Set to false to disable template loading.
setup.template.enabled: true

# Template name. By default the template name is "apm-%{[observer.version]}"
# The template name and pattern has to be set in case the elasticsearch index pattern is modified.
setup.template.name: "apm-%{[observer.version]}"

# Template pattern. By default the template pattern is "apm-%{[observer.version]}-*" to apply to the default index settings.
# The first part is the version of apm-server and then -* is used to match all daily indices.
# The template name and pattern has to be set in case the elasticsearch index pattern is modified.
setup.template.pattern: "apm-%{[observer.version]}-*"


#================================ Outputs =================================

# Configure the output to use when sending the data collected by apm-server.

#關閉iml策略
setup.ilm.enabled: false
#-------------------------- Elasticsearch output --------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  # Scheme and port can be left out and will be set to the default (`http` and `9200`).
  # In case you specify and additional path, the scheme is required: `http://localhost:9200/path`.
  # IPv6 addresses should always be defined as: `https://[2001:db8::1]:9200`.
  # hosts: ["localhost:9200"]
  hosts: ["http://ip:9200","http://ip:9200"]
  index: "apm-%{[observer.version]}-%{+yyyy.MM.dd}"

apm-server服務啓動

cd apm-server-7.4.2-linux-x86_64

#非後臺啓動服務方式
./apm-server -e -c apm-server.yml


#後臺啓動服務方式
nohup ./apm-server -e -c apm-server.yml &

apm-server服務運行情況檢查

#查看服務進程
ps -ef|grep apm-server 

#日誌信息查看
nohup 方式啓動以後原先控制檯的日誌輸出在運行腳本的目錄下的nohup.out文件

tail -fn200 /home/elk/apm/nohup.out

在這裏插入圖片描述
在這裏插入圖片描述

apm agent安裝指南

這裏以java語言爲例

java \
 -javaagent:/.../elastic-apm-agent-<version>.jar\
 -Delastic.apm.service_name=my-application\
 -Delastic.apm.server_urls=http://localhost:8200\
 -Delastic.apm.application_packages=org.example\
 -jar my-application.jar

在這裏插入圖片描述

APM在Kibana上的相關界面

找到APM菜單

在這裏插入圖片描述

APM主頁面

默認顯示的是目前服務列表,列表不支持分頁顯示,搜索框部分的使用都是通用的,和其他模塊裏的類似

在這裏插入圖片描述

搜索輸入框

使用方式查看詳情

時間輸入框

使用方式查看詳情

Filters

APM幾乎所有頁面左側都有一塊Filters 內容,此處是一部分下拉選擇類型的過濾項,用於數據過濾,支持手動輸入動態匹配

在這裏插入圖片描述

Setting(beta內測功能)

在這裏插入圖片描述
在這裏插入圖片描述

APM某個監控服務詳情頁面

Transaction 列表頁面

在這裏插入圖片描述

Transaction 詳情頁面

在這裏插入圖片描述

Transaction 詳細Timeline

目前這個只能針對當前服務本身的一些流程來統計耗時,涉及到調用第三方接口的部分目前無法統計
在這裏插入圖片描述

Errors 列表頁

在這裏插入圖片描述

Errors 詳情頁

在這裏插入圖片描述

某條錯誤記錄的詳情

在這裏插入圖片描述

某條錯誤記錄的詳情Metadata

在這裏插入圖片描述

Metrics監控信息圖表頁

在這裏插入圖片描述

參考資料

這篇文章絕大多數內容都是從官網的開發文檔中找到依據,少量的參考其他資料,結合實際驗證而來.官網的相關資料都在上文相應的位置做了鏈接,此處不再重複列舉,提供一個官網地址涵蓋全部官網的參考資料。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章