本文介绍小白使用工具telegraf、influxdb、grafana对数据进行抽取、存储、展示的构建过程
环境:macos、Telegraf 1.15.2、InfluxDB 1.8.2、grafana
导航
1、telegraf的下载安装,启动,重启
2、influxdb的下载安装,启动,重启
3、telegraf配置文件的influxdb输出,与influxdb的创建的数据库用户,密码,数据库名称一致。
4、grafana配置influx数据源,右侧选择图表类型,下侧选择监控字段
5、telegraf监控信息字段解释:https://www.cnblogs.com/foolaround/p/12923932.html
6、grafana面板参数解释:https://www.cnblogs.com/i6010/articles/11608695.html
1、telegraf下载:brew install telegraf
telegraf启动:brew services start telegraf
telegraf重启:brew services restart telegraf
2、influxdb下载:brew install influxdb
influxdb启动:influxd -config /usr/local/etc/influxdb.conf
influxdb重启:influxd -config /usr/local/etc/influxdb.conf
进入influxdb:命令行输入influx
创建用户与密码:create user “telegraf” with password “password”,此处的用户和密码在telegraf连接时需用到。
查询用户:show users;
创建数据库:create database telegraf
查询数据库:show databases
使用某一数据库:use telegraf
查询数据表:show measurements
查询表中数据:select * from cpu
3、telegraf配置文件:
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
debug = false
quiet = false
hostname = ""
omit_hostname = false
[[outputs.influxdb]]
urls = ["http://127.0.0.1:8086"]
database = "telegraf"
retention_policy = ""
timeout = "5s"
username = "telegraf"
password = "password"
软链接:ln -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents
cp ./influxdb.conf /etc/influxdb/
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.influxdb.plist
启动influxdb拉取数据规则的任务
4、grafana配置influx数据源,右侧选择图表类型,下侧选择监控字
5、telegraf收集数据说明:
1、CPU、Disk、Diskio、MEM、NETSTAT、System、SWAP。
6、grafana的下载安装,启动。
brew install grafana
brew services start grafana
访问地址:http://127.0.0.1:3000/
默认账号和密码:admin/admin