搭建 influxdb+grafana 监控 jmeter

1.安装grafana

wget https://dl.grafana.com/oss/release/grafana-6.3.2-1.x86_64.rpm

yum localinstall grafana-6.3.2-1.x86_64.rpm -y

配置文件位置:/etc/grafana/grafana.ini

端口默认为3000,如要修改在此文件修改

[server]

# Protocol (http, https, h2, socket)

;protocol = http

# The ip address to bind to, empty will bind to all interfaces

;http_addr =

# The http port  to use

;http_port = 3000

#启动服务

systemctl enable grafana-server #开机自动启动

systemctl start grafana-server #启动grafana服务

#查看进程

ps -auxf|grep grafana

#查看端口

netstat -lntup|grep graf

#WEB端登录

http://服务器IP:3000/

默认用户名和密码:admin

2.安装influxdb

# wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.8.x86_64.rpm

# sudo yum localinstall influxdb-1.7.8.x86_64.rpm

修改配置

[meta]

  # Where the metadata/raft database is stored

  dir = "/var/lib/influxdb/meta"

[data]

  # The directory where the TSM storage engine stores TSM files.

  dir = "/var/lib/influxdb/data"

  # The directory where the TSM storage engine stores WAL files.

  wal-dir = "/var/lib/influxdb/wal"

[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 = "graphite"

   retention-policy = ""

   bind-address = ":2003"

   protocol = "tcp"

   consistency-level = "one"

#启动

sudo systemctl start influxdb

#配置开机启动

sudo systemctl enable influxdb

#防火墙设置--可以跳过

#开放端口

# firewall-cmd --add-port=8086/tcp --permanent

#重载防火墙配置

# firewall-cmd --reload

#启动Cli命令

[root@localhost grafana]# influx

Connected to http://localhost:8086 version 1.7.8

InfluxDB shell version: 1.7.8

>

 #创建influxdb数据库用户

CREATE USER admin WITH PASSWORD 'admin' WITH ALL PRIVILEGES

SHOW USERS

#创建influxdb数据库

CREATE DATABASE  jmeter

#展示数据库

SHOW DATABASES

#使用数据库

USE DATABASES

#展示数据库中所有表

SHOW  MEASUREMENTS

#查询数据

select * from table

3.grafana配置数据源

登录garafa→Datasources→add data source

搜索类型influxdb,点击进入add data source页

 

 

 配置好数据源后配置监控面板

下载监控模板:

官网模版库:https://grafana.com/dashboards

下载后导入dashboards模板

 

选择好数据库保存后检查监控页面

 

 4.jmeter端配置

添加监听器→后端监听器

 

 后端监听器实现选择:(必填项)

org.apache.jmeter.visualizers.backend.influxdb.InfulxdbBackendListenerClient

InfluxdbUrl填写安装influxdb数据的服务器IP和配置端口(必填项),其他项可以使用默认值,如果需要配置可以修改其他项。

配置后端监听器各项指标的含义:

  • Backend Listener implementation【后端监听器实现】 - 这是一个实现类,将用作JMeter测试指标的监听器。该参数的值基于我们将要使用的协议。如果您还记得,我们使用InfluxDB配置指定的graphite配置。为此,我们需要使用'GraphiteBackendListenerClient'
  • Async Queue size【异步队列大小】 - 队列值包含异步处理时的度量标准。除非有一些特定的性能问题,否则最好不要从默认的'5000'值更改此值。
  • graphiteMetricsSender - 将用作度量标准发送者的实现类。只需使用默认值。
  • graphiteHost - InfluxDB所在的主机
  • graphitePort - 我们在InfluxDB配置文件的'graphite'部分中指定的端口
  • rootMetricsPrefix - 将用于存储在数据库中的所有度量标准的基本前缀。请记住,指标没有默认分隔符。这就是为什么使用'。'更好。符号在此属性中指定的前缀的末尾
  • summaryOnly - 如果只想在数据库中保存汇总结果并且不想在测试执行期间收集所有详细指标,请使用“true”
  • samplersList - 如果要将特定采样器仅发送到数据库,请使用此字段。在我们的例子中,我们想发送所有的样本,所以我们将这个参数留空
  • useRegexpForSamplersList - 如果您想在'samplersList'字段中指定一个正则表达式来选择应该发送到数据库的采样器,则输入'true'
  • percentiles【百分比】 - 用于指定应发送到数据库的度量百分比

配置完成后,我们可以运行我们的测试执行。

posted @ 2022-01-30 15:55  逆风前进的狼  阅读(69)  评论(0编辑  收藏  举报