telegraf、influxDB、Grafana的安装与基本使用
目的
理解influxDB的数据收集原理和方法
为使用grafana分析数据及展示结作好准备
介绍
[收集数据] Telegraf 是一个用 Go 编写的代理程序,可收集系统和服务的统计数据,并写入到 InfluxDB 数据库。Telegraf 具有内存占用小的特点,通过插件系统开发人员可轻松添加支持其他服务的扩展。
[存储数据] InfluxDB 是 Go 语言开发的一个开源分布式时序数据库,非常适合存储指标、事件、分析等数据
[展示数据] Grafana 是纯 Javascript 开发的前端工具,用于访问InfluxDB,自定义报表、显示图表等。
telegraf安装
下载
wget http://get.influxdb.org/telegraf/telegraf-0.11.1-1.x86_64.rpm
安装
yum localinstall telegraf-0.11.1-1.x86_64.rpm -y
启动服务、添加开机启动
systemctl start telegraf.service
service telegraf status
systemctl enable telegraf.service
查看版本
telegraf --version
Telegraf - Version 0.11.1
配置
路径:/etc/telegraf/telegraf.conf
示例:安装完成后会有一个示列配置文件,请根据所需仔细阅读文件。
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
安装: yum install influxdb -y
启动服务、添加开机启动
service influxdb start
systemctl enable influxdb
service influxdb status
服务默认使用端口:
Networking By default, InfluxDB uses the following network ports:
TCP port 8083 is used for InfluxDB’s Admin panel
TCP port 8086 is used for client-server communication over InfluxDB’s HTTP API
TCP ports 8088 and 8091 are required for clustered InfluxDB instances
服务验证 -输入 influx 进入数据库
[root@ctn-7-12 ~]# influx
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 0.11.0
InfluxDB shell 0.11.0
创建一个查询用户
CREATE USER "ptquery" WITH PASSWORD 'ptquery'
> show users;
user admin
ptquery false
ptdb1 fals
7.也可以在页面创建查询用户 CREATE USER "ptquery" WITH PASSWORD 'ptquery'
查看服务端口
[root@ctn-7-12 ~]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp6 0 0 :::8083 :::* LISTEN 22124/influxd
tcp6 0 0 :::8086 :::* LISTEN 22124/influxd
浏览器访问数据库管理平台:
http://172.16.7.11:8083/
参考信息:
https://influxdata.com/downloads/
grafana安装
手动安装:
wget https://grafanarel.s3.amazonaws.com/builds/grafana-latest-1.x86_64.rpm
yum install grafana-latest-1.x86_64.rpm
安装包详情
二进制文件 /usr/sbin/grafana-server
启动脚本 /etc/init.d/grafana-server
环境变量 /etc/sysconfig/grafana-server
配置文件 /etc/grafana/grafana.ini
systemd服务 grafana-server.service
日志 /var/log/grafana/grafana.log
服务详情
启动用户 grafana
服务名称 grafana-server
默认端口 3000
账号 admin
密码 admin
启动服务、添加开机启动
systemctl daemon-reload
systemctl start grafana-server
systemctl status grafana-server
systemctl enable grafana-server.service
访问
http://server IP :3000
将数据写入influxDB
influxDB line写入协议介绍
格式: [measurements],[tag]=[tagvalue]空格 [field1]=[field1value],[field1]=[field1value]
说明:
命名规则:measurements、tag、field的命名不能含空间,逗号,如必须有,需有\转义;
行格式有严格的要求,“=”左右及","分隔不能有空格
measurements,从统计学角度上看,这叫做样本集。相当于关系数据库的Table
tag,样本集中个体的标识符,相当于关系数据库的primary key,
filed,个体属性的度量值,可以为整型,浮点型,字符型,布尔型 ,相当于关系数据库的一般字段
根据上面的写入协议,编写sh脚本,然后通过telegraf调度执行,就可以把数据写入到influxDB,具体步骤如下:
编写sh脚本,例子如下(bash shell脚本也可以调用python脚本,只要满足line写入协议输出即可):
#! /bin/env bash
echo 'employee,empname=kk age=20,salary=3000'
修改telegraf的配置文件/etc/telegraf/telegraf.conf,具体如下:
[[outputs.influxdb]]
urls = ["http://192.168.18.118:8086"] #infulxdb地址
database = "telegraf" #数据库
precision = "s"
timeout = "5s"
username = "admin" #帐号
password = "admin" #密码
[[inputs.exec]]
# Shell/commands array
commands = ["/tmp/qq.sh"]
# Data format to consume. This can be "json", "influx" or "graphite" (line-protocol)
# NOTE json only reads numerical measurements, strings and booleans are ignored.
data_format = "influx"
interval = "60s" #调度间隔
timeout = "15s" #超时控制
检验数据,登录到http://192.168.18.118:8086 数据已经被写入到influxDB中
---------------------
作者:harryho
来源:CSDN
原文:https://blog.csdn.net/harryho/article/details/77585124
版权声明:本文为博主原创文章,转载请附上博文链接!
telegraf、influxDB、Grafana的安装与基本使用的更多相关文章
- Telegraf+InfluxDB+Grafana搭建服务器监控平台
Telegraf+InfluxDB+Grafana搭建服务器监控平台 tags:网站 个人网站:https://wanghualong.cn/ 效果展示 本站服务器状态监控:https://statu ...
- 使用Telegraf + Influxdb + Grafana 监控SQLserver服务器的运行状况
使用Telegraf + Influxdb + Grafana 监控SQLserver服务器的运行状况 前言 本文在Debian9下采用Docker的方式安装Telegraf + Influxdb + ...
- [转帖] 基于telegraf, influxdb, grafana 建立 esxi 监控
[系统集成] 基于telegraf, influxdb, grafana 建立 esxi 监控 https://www.cnblogs.com/hahp/p/7677420.html 之前在 nagi ...
- 基于telegraf+influxdb+grafana进行postgresql数据库监控
前言 随着公司postgresql数据库被广泛应用,尤其是最近多个项目在做性能测试的时候都是基于postgresql的数据库,为了确定性能瓶颈是否会出现在数据库中,数据库监控也被我推上了日程.在网上找 ...
- Telegraf+InfluxDB+Grafana快速搭建实时监控系统 监控postgresql
Telegraf+InfluxDB+Grafana快速搭建实时监控系统 监控postgresql
- [系统集成] 基于telegraf, influxdb, grafana 建立 esxi 监控
之前在 nagios 上建立了 esxi 监控,指标少.配置麻烦.视觉效果差.最近我把 esxi 监控迁移到了 influxdb+grafana 平台上,无论是监控指标.可操作性还是视觉效果都有了很大 ...
- 通过 Telegraf + InfluxDB + Grafana 快速搭建监控体系的详细步骤
第一部分 Telegraf 部署和配置 Telegraf 是实现 数据采集 的工具.Telegraf 具有内存占用小的特点,通过插件系统开发人员可轻松添加支持其他服务的扩展. 在平台监控系统中,可以使 ...
- Telegraf+Influxdb+Grafana自动化运维监控
概述:Telegraf收集信息,influxdb时序数据库存储数据,grafana平台展示数据,并进行监控告警,组成一个自动化运维监控平台. 一.influxdb InfluxDB是一个由Infl ...
- Spring Boot Actutaur + Telegraf + InFluxDB + Grafana 构建监控平台
完成一套精准,漂亮图形化监控系统从这里开始第一步 Telegraf是收集和报告指标和数据的代理 它是TICK堆栈的一部分,是一个用于收集和报告指标的插件驱动的服务器代理.Telegraf拥有插件或集成 ...
- Windows下本机简易监控系统搭建(Telegraf+Influxdb+Grafana)
一.文件准备 1.1 文件名称 telegraf-1.2.1_windows_amd64.zip influxdb-1.2.2_windows_amd64.zip grafana-4.2.0.wind ...
随机推荐
- rabbitMQ教程(四) spring整合rabbitMQ代码实例
一.开启rabbitMQ服务,导入MQ jar包和gson jar包(MQ默认的是jackson,但是效率不如Gson,所以我们用gson) 二.发送端配置,在spring配置文件中配置 <?x ...
- Js_获取浏览器等高宽
IE中: document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document. ...
- Oracle中Clob类型处理解析 (转)
转:原文:http://blog.csdn.net/pojianbing/article/details/2789426 最近利用NHibernate映射类型为Clob字段在插入数据时发现当 ...
- Python+Selenium+Unittest+Ddt+HTMLReport分布式数据驱动自动化测试框架结构
1.Business:公共业务模块,如登录模块,可以把登录模块进行封装供调用 ------login_business.py from Page_Object.Common_Page.login_pa ...
- c# winform调用摄像头识别二维码
首先我们需要引用两个第三方组件:AForge和zxing. Aforge是摄像头操作组件,zxing是二维码识别组件.都是开源项目.避免重复造轮子. 其实一些操作代码我也是参照别人的,若侵犯您的版权, ...
- SCRUM 12.14
由于最近的课业较多,大家平时有些力不从心,对于工作完成得有限. 最近课业压力小了一些,我们决定从今天起,投入精力. 以下为我们的任务分配情况: 人员 任务 高雅智 清除缓存 彭林江 统计活跃用户数量 ...
- opencv2 用imwrite 抽取并保存视频图像帧
最近在写一个车辆检测程序,程序中需要获取图像帧,并保存为图片,且放到指定目录中去,我在网上查了很多发现都是opencv1的有关操作,没有opencv2的操作,我参考网上的例子,结合着用opencv2新 ...
- DOM父节点、子节点例子
父节点 <body> <ul id="oUl"> <li><a href="#">隐藏1</a>&l ...
- github建仓库注意
在导入新的项目工程时,github建仓库时不要选择readme文件初始化仓库
- Python 零基础 快速入门 趣味教程 (咪博士 海龟绘图 turtle) 2. 变量
大家在中学就已经学过变量的概念了.例如:我们令 x = 100,则可以推出 x*2 = 200 试试下面这段 Python 代码 import turtle turtle.shape("tu ...