关于 influxdb+grafana 的文章,谷歌百度一大把,但是 99.9% 不知所云,不是这边漏一点就是那边漏一点。甚至怀疑绝大部分都是互相抄袭。本着前人挖坑后入埋的态度,我整理了一份详细的文档,给大家分享一下。ubuntu 环境
wget https://dl.influxdata.com/influxdb/releases/influxdb_1.2.4_amd64.deb
sudo dpkg -i influxdb_1.2.4_amd64.deb
vim /etc/influxdb/influxdb.conf
执行:influx 进入数据库
[root@imzcy ~]# influx
> CREATE USER root WITH PASSWORD '000000' WITH ALL PRIVILEGES
> SHOW USERS
user admin
root true
配置文件中,8086 端口下开启 auth 权限控制
vim /etc/influxdb/influxdb.conf
重启数据库之后再访问数据库就需要带入用户名密码了,否则会报错
influx -username root -password 000000
需要配置用户名密码,然后连接
wget https://dl.influxdata.com/telegraf/releases/telegraf_0.11.1-1_amd64.deb
sudo dpkg -i telegraf_0.11.1-1_amd64.deb
vim /etc/telegraf/telegraf.conf
配置 host,端口(8086),数据库名称,数据库用户名密码
/etc/init.d/telegraf restart
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_5.1.3_amd64.deb
sudo apt-get install -y adduser libfontconfig
sudo dpkg -i grafana_5.1.3_amd64.deb
执行:service grafana-server restart
用户名密码默认是 admin admin
jmeter 模板 id:4026
telegraf 模板 id:3967
点击/home/system
添加数据库连接 host,端口,库名,用户名,密码
聚合报告
SELECT count(responseTime) as Count, mean(responseTime) as Avg, min(responseTime) as Min, median(responseTime) as Median, percentile(responseTime, 90) as "90%",percentile(responseTime, 95) as "95%",percentile(responseTime, 99) as "99%", max(responseTime) as Max, (sum(errorCount)/count(responseTime)) as "Error Rate" FROM "requestsRaw" WHERE $timeFilter GROUP BY time(1m)
吞吐量
SELECT count("responseTime") FROM "requestsRaw" WHERE $timeFilter GROUP BY time(1s)
响应时间
SELECT mean("responseTime") FROM "requestsRaw" WHERE $timeFilter GROUP BY time($__interval)
活动线程
SELECT mean("meanActiveThreads") FROM "virtualUsers" WHERE $timeFilter GROUP BY time(1s)