目錄
一、前言
在前面這篇文章:Jmeter+Grafana+Influxdb可視化性能監控平臺搭建:讓壓測實時的“酷炫”起來!,搭建了監控
Jmeter性能測試結果
的平臺。
但是在Jmeter性能測試過程中,我們還需要關注被壓測服務器系統的系統資源
情況。例如服務器的cpu
、disk
、mem
等資源情況。
雖然Jmeter可以通過安裝PerfMonMetricsCollector
插件來收集服務器的這些指標。但是這種方式對性能消耗有點大
,所以一般不採用這種方式。所以採用Grafana+InfluxDB+Telegraf
來監控服務器的資源情況。
Grafana+InfluxDB+Telegraf實現服務器性能監控的原理:Telegraf負責收集服務器的資源情況
並將存儲到InfluxDB數據庫中,然後Grafana負責展示InfluxDB中的數據。
二、InfluxDB安裝及配置
2.1 Docker安裝InfluxDB
關於安裝InfluxDB的這部分內容,直接參考文章:Jmeter+Grafana+Influxdb可視化性能監控平臺搭建:讓壓測實時的“酷炫”起來!的
2.1 Docker安裝Influx
部分
2.2 創建用戶和數據庫
[root@YFF Telegraf]# docker exec -it 26b59ddf8a40 /bin/bash
root@26b59ddf8a40:/# influx
Connected to http://localhost:8086 version 1.8.0
InfluxDB shell version: 1.8.0
> show databases;
name: databases
name
----
_internal
jmeter
> create user "telegraf" with password 'telegraf'
> create database telegraf
> show databases
name: databases
name
----
_internal
jmeter
telegraf
三、Telegraf安裝及配置
3.1 下載並安裝Telegraf
[root@YFF Telegraf]# wget https://dl.influxdata.com/telegraf/releases/telegraf-1.7.4-1.x86_64.rpm
[root@YFF Telegraf]# yum localinstall telegraf-1.7.4-1.x86_64.rpm
3.2 配置Telegraf
- 配置Telegraf:修改
/etc/telegraf/telegraf.conf
文件.vim /etc/telegraf/telegraf.conf
- 修改相關內容爲如下內容。
# Configuration for sending metrics to InfluxDB [[outputs.influxdb]] ## The full HTTP or UDP URL for your InfluxDB instance. urls = ["http://***.*.*.*:8086"] ## The target database for metrics; will be created as needed. database = "telegraf" ## Name of existing retention policy to write to. Empty string writes to ## the default retention policy. Only takes effect when using HTTP. retention_policy = "" ## Timeout for HTTP messages. timeout = "5s" ## HTTP Basic Auth username = "telegraf" password = "telegraf"
3.3 啓動Telegraf
systemctl start telegraf
四、Grafana安裝及配置
4.1 Grafana安裝及配置InfluxDB
關於Grafana安裝及配置InfluxDB的這部分內容,直接參考文章:Jmeter+Grafana+Influxdb可視化性能監控平臺搭建:讓壓測實時的“酷炫”起來!的
2.1 Docker安裝Grafana
、2.2 Grafana配置influx
部分。不過最後這部分要修改相關的InfluxDB的參數。
4.2 下載模板及創建儀表盤
關於Grafana下載模板及創建儀表盤的這部分內容,直接參考文章:Jmeter+Grafana+Influxdb可視化性能監控平臺搭建:讓壓測實時的“酷炫”起來!的
2.3 Grafana使用模板文件創建儀表盤
。不過最後這部分要修改相關的InfluxDB的參數。
這個地方下載的模板文件是ID爲79
的Dynamic Dashboord。可以直接在此處下載:https://grafana.com/grafana/dashboards/79
最後再導入模板後選擇創建好的DataSource即可
4.3 最終效果圖
五、寫在後面
關於監控服務器的方式有很多,例如還有Prometheus+Grafana+node_exporter
的方式,但是重點在於數據,而非展示數據的方式。