Grafana+Influxdb+Telegraf服务器监控平台
一套监控系统应主要由数据采集、数据存储、数据展示三部分构成
使用目的
Jmeter
Grafana
Influxdb
Telegraf
利用以上开源性能监控工具,可以达到以下两大方面的监控:
1、负载施压负载情况监控(请求数tps qps响应时间等)
2、被压测机器的硬件资源消耗(cpu,内存,网络,磁盘IO等)
Influxdb安装
cat <
sudo yum install influxdb
配置influxdb.conf
sudo vim /etc/influxdb/influxdb.conf
大致修改的内容如下
[http]
# Determines whether HTTP endpoint is enabled.
enabled = true
# The bind address used by the HTTP service.
bind-address = ":8086"
[[graphite]]
# Determines whether the graphite endpoint is enabled.
enabled = true
database = "jmeter"
retention-policy = ""
bind-address = ":2003"
protocol = "tcp"
consistency-level = "one"
sudo systemctl start influxdb
先创建influxdb数据库jmeter
influx
#################
Connected to http://localhost:8086 version 1.8.0
InfluxDB shell version: 1.8.0
> CREATE DATABASE jmeter
> SHOW DATABASES
name: databases
name
----
telegraf
_internal
jmeter
> use jmeter
Using database jmeter
Grafana安装
wget https://dl.grafana.com/oss/release/grafana-7.0.5-1.x86_64.rpm
sudo yum install grafana-7.0.5-1.x86_64.rpm
systemctl start grafana-server
启动服务成功后,grafana重置访问地址
http://localhost:3000
Telegraf安装
sudo yum install telegraf
备份和修改telegraf.conf
sudo vim /etc/telegraf/telegraf.conf
大致修改的内容如下
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
## The full HTTP or UDP URL for your InfluxDB instance.
## ## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
# urls = ["unix:///var/run/influxdb.sock"]
# urls = ["udp://127.0.0.1:8089"]
# 你安装的Influxdb地址 我安装在了本机配置可以是127.0.0.1 或 localhost 或你本机配置的固定ip 接:8086
urls = ["http://192.168.***.***:8086"]
## The target database for metrics; will be created as needed.
# 你想要监控host硬件资源机器的存储数据库名
database = "telegraf"
sudo systemctl start telegraf
配置Grafana数据源
以上三个服务后,访问grafana http://localhost:3000
添加数据源类型influxdb的jmeter数据库,也就是influxdb.conf中配置的为了记录jmeter负载情况的。
添加数据源类型influxdb的telegraf数据库,也就是telegraf.conf中配置为了记录主机硬件资源情况的。
三Grafana仪表盘监控配置
Grafana import Dashboard监控面板
导入前可以自行create Folder jmeter和telegraf以便于区分存储和记录,也注意选择需要存储的DB name (jmeter和telegraf )
一个是监控jmeter负载情况的https://grafana.com/dashboards/4026
一个是监控主机硬件资源情况的https://grafana.com/dashboards/3967 照着修改配置文件telegraf.conf内容
监控本机主机TR硬件资源效果图
四Jmeter BackendListerer监控配置
配置Jmeter BackendListerer
启动jmeter5.0随便设置一个线程组创建一个http请求访问百度
BackendListerer(后端监听)主要配置如下
然后,可以线程组里设置些循环,然后启动执行该testplan
Jmeter仪表盘搜集负载情况监控数据效果图
一些命令
#开启服务
systemctl start influxd
systemctl start telegraf
systemctl start grafana-server
#结束服务
systemctl stop influxd
systemctl stop telegraf
systemctl stop grafana-server
#查看运行状态
systemctl status influxd
systemctl status telegraf
systemctl status grafana-server