centos8 安装influxdb+telegraf+grafana

端口说明

8083:访问web页面的地址,8083为默认端口;

8086:数据写入influxdb的地址,8086为默认端口;

8088:数据备份恢复地址,8088为默认端口;

#安装
yum -y install wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.8.x86_64.rpm
#启动,并设置自启
systemctl start influxdb
systemctl enable influxdb
influxd
#停止服务
systemctl stop influxdb

查看

#打开influx数据库
influx
#创建用户
CREATE USER QGS WITH PASSWORD '111111' WITH ALL PRIVILEGES
#查询用户
SHOW USERS
#创建数据库
CREATE DATABASE QGS
#查询数据库
SHOW DATABASES

卸载influxdb:

4. 输入: rpm -q influxdb  查询influxdb包的名字

5. 输入:rpm -e influxdb     删除特定的rpm包

6. 输入:rpm -q influxdb    查询influxdb包是否删除

2.CentOS下安装telegraf


wget https://dl.influxdata.com/telegraf/releases/telegraf-1.20.4-1.x86_64.rpm
yum localinstall telegraf-1.20.4-1.x86_64.rpm

     安装完成后配置文件的默认路径在/etc/telegraf/telegraf.conf

    修改配置文件将数据指向数据源,这里我用的是本地的Influxdb

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"]
  urls = ["http://127.0.0.1:8086"]
 
  ## The target database for metrics; will be created as needed.
  ## For UDP url endpoint database needs to be configured on server side.
  database = "telegraf"

//参考配置

[global_tags]
[agent]
  interval = "5m"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "30s"
  flush_jitter = "0s"
  precision = ""
  hostname = "yu17-ks-6b669819"
  omit_hostname = false
[[outputs.influxdb]]
  urls = ["http://136.36.89.03:8086"]
  database = "telegraf"
  username = "telegraf"
  password = "111222"
[[inputs.cpu]]
  percpu = true
  totalcpu = true
  collect_cpu_time = false
  report_active = false
[[inputs.disk]]
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.kernel]]
[[inputs.mem]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]
 [[inputs.net]]
    interfaces = ["*"]
[[outputs.influxdb]]
  urls = ["http://ppcdncloud.com:8086"]
  database = "telegraf"
  username = "telegraf"
  password = "111222"

开启telegraf服务,这时telegraf开始收集本机数据并发送到influxdb

systemctl start telegraf
[vagrant@td ~]$ influx
Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> SHOW DATABASES
name: databases
name
----
_internal
test
telegraf
> USE telegraf
Using database telegraf
> SHOW MEASUREMENTS
name: measurements
name
----
cpu
disk
diskio
kernel
mem
processes
swap
system
> select * from "mem" limit 5

查询net表最近10秒的数据

select bytes_recv,bytes_sent,host from net  where time >now() -10s

//指定host
select bytes_recv,bytes_sent,host from net  where time >now() -10s and host='vmtds'
//limit 1 跟在最后 只查询一条
select bytes_recv,bytes_sent,host from net  where time >now() -100s and host!='vmtds' limit 1

//字符串模糊查询 limit 放在 order by的后面 limit  放在语句最后面
select bytes_recv,bytes_sent,host from net  where  host=~/.*t.*/  order by time desc limit 20

//数字类型用范围查询
select bytes_recv,bytes_sent,host from net  where  host=~/.*t.*/  and bytes_sent>2592  order by time desc limit 20
select count(bytes_recv) from net  group by host 

3 安装 grafana 

镜像地址:下载飞快

Index of /grafana/yum/rpm/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

​
wget https://mirrors.tuna.tsinghua.edu.cn/grafana/yum/rpm/grafana-7.5.8-1.x86_64.rpm

​

yum install grafana-7.5.8-1.x86_64.rpm

启动  grafana

systemctl start grafana-server

systemctl enable grafana-server

浏览器访问3000端口

3.1 选择大屏模板  Dashboards | Grafana Labs

 选择模板 得到id直接导入 简单粗暴

//-----------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值