“This is the 22nd day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

One, the introduction

JMeter’s PerfMonMetricsCollector plug-in supports the collection of server performance metrics, but we rarely use it because of the performance loss it collects. In addition, we also need to collect JMeter test results data. We can already use inflluxDB to store performance test results, so we can also store server performance data to influxDB, and with Grafana we can get a cool visual kanban in real time.

Second, the target

Collect performance indicators of Linux APP server:

  • List item
  • cpu
  • disk
  • disk.io
  • processes
  • swap memory usage
  • memory usage
  • system load and uptime
  • network interface usage
  • inodes usage

Iii. Solutions

1, the Telegraf

JMeter will not persist the collected performance data to the database unless I modify the JMeter source code myself, but this cost is too high, so we chose the simpler and lower cost Telegraf as the collection service.

Telegraf is an agent written in Go that collects statistics on systems and services and writes them to the InfluxDB database. Telegraf has a small memory footprint and can easily add extensions to support other services through the plug-in system.

TICK the family

Official website: www.influxdata.com/time-series…

2. Overall design

Telegraf&InfluxDB integration

1. Download and install

[root@zuozewei ~]Wget # https://dl.influxdata.com/telegraf/releases/telegraf-1.7.4-1.x86_64.rpm
[root@zuozewei ~]# yum localinstall telegraf 1.7.4-1. X86_64. RPM
Copy the code

2. Create influxDB users and databases

[root@zuozewei ~]# influx
Connected to http://localhost:8086 version 1.6.2
InfluxDB shell version: 1.6.2
> create user "telegraf" with password 'telegraf'
> create database telegraf
> show databases
name: databases
name
----
_internal
jmeter
demo
test
7dgroup
telegraf
> exit
Copy the code

3. Configure Telegraf

[root@zuozewei ~]# 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://127.0.0.1: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"
Copy the code

4. Start Telegraf

[root@zuozewei ~]# systemctl start telegraf
Copy the code

5. Check the data

[root@zuozewei ~]# influx
Connected to http://localhost:8086 version 1.6.2
InfluxDB shell version: 1.6.2
> use telegraf
Using database telegraf
> show measurements
> show measurements
name: measurements
name
----
cpu
disk
diskio
kernel
mem
processes
swap
system
Copy the code

The performance data has been saved successfully

Integration of InfluxDB&Grafana

Grafana create new data source

Download the Kanban template

Search for Kanban templates

Official Kanban template library: grafana.com/dashboards

Select the Kanban template to import

This kanban address: grafana.com/dashboards/…

Grafana imports the template

Select the Telegraf data source

Finally, a big hd picture of the monitoring effect

Other kanban template renderings

Template address: grafana.com/dashboards/…

Related resources:

  • Github.com/zuozewei/bl…