1. jmeter监控搭建influxdb+grafana

查看IP
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO="static" # 使用静态IP地址,默认为dhcp
IPADDR="192.168.222.128" # 设置的静态IP地址
NETMASK="255.255.255.0" # 子网掩码
GATEWAY="192.168.222.2" # 网关地址
DNS1="192.168.222.2" # DNS服务器
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33

2. UUID=c36cec2b-3aac-446b-936b-283bd58505b3

DEVICE=ens33
ONBOOT=yes
ZONE=public

3. influxdb安装和使用

查看yum仓库

[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-x86_64-kernel.repo nginx.repo
CentOS-Base.repo.bak CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo docker-ce.repo

centos 安装 influxdb,很简单的。

3.1. 、将InfluxDB加入yum源

cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL $releasever
baseurl = https://repos.influxdata.com/rhel/$releasever/$basearch/stable enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key EOF

3.2. 、安装

4. 安装

sudo yum install -y influxdb

进程查看:
[root@localhost ~]# ps -ef |grep -i "influx"
root 20901 17266 0 07:21 pts/0 00:00:00 grep --color=auto -i influx

4.1. 、influxdb的状态,启动,关闭

在linux中,systemctl 管理大多数服务,可以执行以下命令

systemctl status influxdb // 查看influxdb的状态
systemctl start influxdb // 启动influxdb服务
systemctl stop influxdb // 停止influxdb服务

开机启动
systemctl enable influxdb
1
2
3

4.2. 、使用influx进入客户端

————————————————
版权声明:本文为CSDN博主「jeT5_devil」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:

influxdb操作

  • 1、创建数据库,查看数据库,删除数据库
> create database test1
> show databases
name: databases
name
----
_internal
test1
> drop database test1
> show databases
name: databases
name
----
_internal
>
  • 2、切换数据库,使用数据库

use test1

Using database test1

  • 3、measurements:相当于传统数据库中的表

但是influxdb没有创建表的语句,是直接通过insert语句来实现measurements的创建
* insert语法
基本格式:
insert measurementName,tag1=value1[,<tag2=value2>] field1=value1[,<field2=value2>] <时间戳>
* tag和field和时间戳使用空格进行分割。
* 时间戳可以不用输入,influxdb会自动写入时间

> insert testing,app=jmeter,class=实战 processor=0.9,memory=2g
ERR: {"error":"unable to parse 'testing,app=jmeter,class=实战 processor=0.9,memory=2g': invalid number"}

> insert testing,app=jmeter,class=实战 processor=0.9,memory="2g"
> insert testing,app=jmeter,class=实战 processor=0.9,memory="800"
> show measurements
name: measurements
name
----
testing

**查询数据**
> select * from testing
name: testing
time                app    class memory processor
----                ---    ----- ------ ---------
1624146665355452609 jmeter 实战    2g     0.9
1624146731188526963 jmeter 实战    800    0.9

数据丢失的演示 时间和tag一样

> insert testing,app=jmeter,class=实战 processor=0.9,memory="800" 15812345678
> select * from testing
name: testing
time                app    class memory processor
----                ---    ----- ------ ---------
15812345678         jmeter 实战    800    0.9
1624146665355452609 jmeter 实战    2g     0.9
1624146731188526963 jmeter 实战    800    0.9
> insert testing,app=jmeter,class=实战 processor=0.9,memory="800" 15812345678
> select * from testing
name: testing
time                app    class memory processor
----                ---    ----- ------ ---------
15812345678         jmeter 实战    800    0.9
1624146665355452609 jmeter 实战    2g     0.9
1624146731188526963 jmeter 实战    800    0.9
> insert testing,app=jmeter,class=实战 processor=0.9,memory="600" 15812345678
> select * from testing
name: testing
time                app    class memory processor
----                ---    ----- ------ ---------
15812345678         jmeter 实战    600    0.9
1624146665355452609 jmeter 实战    2g     0.9
1624146731188526963 jmeter 实战    800    0.9
  • 4、tag--索引,用来区分数据的
> show tag keys
name: testing
tagKey
------
app
class
> insert testing1,app=jmeter,class=实战 processor=0.9,memory="600" 15812345678
> show tag keys
name: testing
tagKey
------
app
class

name: testing1
tagKey
------
app
class
> show tag keys from testing
name: testing
tagKey
------
app
class
> show tag values from testing with key="app"
name: testing
key value
--- -----
app jmeter
  • 5、field--字段,是存储我们的监控数据的
> show field keys
name: testing
fieldKey  fieldType
--------  ---------
memory    string
processor float

name: testing1
fieldKey  fieldType
--------  ---------
memory    string
processor float
> show field values from testing with key="memory"
ERR: error parsing query: found VALUES, expected KEY, KEYS at line 1, char 12
> select memory from testing
name: testing
time                memory
----                ------
15812345678         600
1624146665355452609 2g
1624146731188526963 800
  • 6、没有删除数据,数据存活期retention policies
> use test1
Using database test1
> show measurements
name: measurements
name
----
testing
testing1
> select * from testing
name: testing
time                app    class memory processor
----                ---    ----- ------ ---------
15812345678         jmeter 实战    600    0.9
1624146665355452609 jmeter 实战    2g     0.9
1624146731188526963 jmeter 实战    800    0.9
> delete from testing where memory="600"
ERR: shard 3: fields not supported in WHERE clause during deletion
> show retention policies on test1
name    duration shardGroupDuration replicaN default
----    -------- ------------------ -------- -------
autogen 0s       168h0m0s           1        true
> create database test2 with duration 30d
> show databases
name: databases
name
----
_internal
test1
test2
> show retention policies
name    duration shardGroupDuration replicaN default
----    -------- ------------------ -------- -------
autogen 0s       168h0m0s           1        true
> show retention policies on test2
name    duration shardGroupDuration replicaN default
----    -------- ------------------ -------- -------
autogen 720h0m0s 24h0m0s            1        true
>
  • 7、jmeter使用influxdb

influxdb和prometheus数据源 influxdb-proxy_IPV6

influxdb和prometheus数据源 influxdb-proxy_CentOS_02

{"results":[{"statement_id":0,"series":[{"name":"testing","columns":["time","app","class","memory","processor"],"values":[["1970-01-01T00:00:15.812345678Z","jmeter","实战","600",0.9],["2021-06-19T23:51:05.355452609Z","jmeter","实战","2g",0.9],["2021-06-19T23:52:11.188526963Z","jmeter","实战","800",0.9]]}]}]}

influxdb和prometheus数据源 influxdb-proxy_IPV6_03

写入数据

influxdb和prometheus数据源 influxdb-proxy_CentOS_04

> show measurements
name: measurements
name
----
testing
testing1
> select * from testing1
name: testing1
time                app    class memory monitor oa      processor value
----                ---    ----- ------ ------- --      --------- -----
15812345678         jmeter 实战    600                    0.9
1624150129050444132                     cpu     testing           0.9
>

5. grafana安装和使用

  • 1、获取安装包
    网速不好,建议到官网下载,然后上传到Linux系统中grafana-5.2.1-1.x86_64.rpm
    https://grafana.com/grafana/download
  • 2、安装
    yum install grafana-5.2.1-1.x86_64.rpm -y
  • 2、启动
    systemctl daemon-reload //读取配置文件
    systemctl start grafana-server //启动grafana服务
    systemctl status grafana-server //查看grafana状态
    systemctl enable grafana-server //开机启动

默认端口3000

默认管理员和密码都是admin

influxdb和prometheus数据源 influxdb-proxy_IPV6_05

建议修改密码:123456

新增一个数据源

influxdb和prometheus数据源 influxdb-proxy_CentOS_06

url:如果influxdb和grafana部署在同一个服务器,可以写localhost

http://localhost:8086

配置好数据源,直接点击Sava

influxdb和prometheus数据源 influxdb-proxy_IPV6_07

提示Data source is working即配置成功

查找模板

import json

jmeter提供了一个----Upload .json File

apache-jmeter-5.1.1\extras GrafanaJMeterTemplate.json

influxdb和prometheus数据源 influxdb-proxy_IPV6_08

导入成功,但是有报错,需要点击右上角的setting手动去修改

influxdb和prometheus数据源 influxdb-proxy_CentOS_09

官网查找

https://grafana.com/

点击grafana---dashboards

influxdb和prometheus数据源 influxdb-proxy_IPV6_10