telegraf、influxDB、Grafana的安装与基本使用

摘要:
目的理解influxDB的数据收集原理和方法为使用grafana分析数据及展示结作好准备介绍[收集数据]Telegraf是一个用Go编写的代理程序,可收集系统和服务的统计数据,并写入到InfluxDB数据库。Telegraf具有内存占用小的特点,通过插件系统开发人员可轻松添加支持其他服务的扩展。[存储数据]InfluxDB是Go语言开发的一个开源分布式时序数据库,非常适合存储指标、事件、分析等数据[展示数据]Grafana是纯Javascript开发的前端工具,用于访问InfluxDB,自定义报表、显示图表等。

目的
理解influxDB的数据收集原理和方法
为使用grafana分析数据及展示结作好准备
介绍
[收集数据]Telegraf 是一个用 Go 编写的代理程序,可收集系统和服务的统计数据,并写入到 InfluxDB 数据库。Telegraf 具有内存占用小的特点,通过插件系统开发人员可轻松添加支持其他服务的扩展。
[存储数据]InfluxDB 是 Go 语言开发的一个开源分布式时序数据库,非常适合存储指标、事件、分析等数据
[展示数据]Grafana 是纯 Javascript 开发的前端工具,用于访问InfluxDB,自定义报表、显示图表等。
telegraf安装
下载
wgethttp://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://serverIP :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的安装与基本使用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇经历:sybase的sql查询,当传递的参数中包含全角空格(u00a0),查询慢pandas 2 选择数据下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

HBase1.2官方文档——Apache HBase Coprocessors

原文档地址:http://hbase.apache.org/1.2/book.html#cp ApacheHbase协处理器 Apache HBase Coprocessors HBase Coprocessors协处理器是在Google BigTable的协处理器实现之后才建模的 (http://research.google.com/people/je...

prometheus学习笔记(1)-mac单机版环境搭建

注:以下所有环境均为mac笔记本 一、安装prometheus brew install prometheus 安装完后,默认的安装路径为: /usr/local/Cellar/prometheus/2.16.0/ 同时还会生成一个默认配置文件:/usr/local/etc/prometheus.yml global: scrape_interva...

饿了么全链路压测平台的实现与原理

背景 在上篇文章中,我们曾介绍过饿了么的全链路压测的探索与实践,重点是业务模型的梳理与数据模型的构建,在形成脚本之后需要人工触发执行并分析数据和排查问题,整个过程实践下来主要还存在以下问题: 测试成本较高,几乎每个环节都需要人力支撑,费时费力。 由于测试用例较多,涉及的测试机范围较广,手工执行容易犯错,线上测试尤其危险。 记录结果和测试报告极不方便,需要...

keystone身份认证服务

1. Keystone介绍 keystone 是OpenStack的组件之一,用于为OpenStack家族中的其它组件成员提供统一的认证服务,包括身份验证、令牌的发放和校验、服务列表、用户权限的定义等等。云环境中所有的服务之间的授权和认证都需要经过 keystone. 因此 keystone 是云平台中第一个即需要安装的服务。 作为 OpenStack 的...

openvas的坑

想装openvas很久了,上次安装的时候,下载出错,然后数据库有个地方出错,但是也占了很大的空间。所以就重装了Kali。。。 安装openvas其实比较容易。配置好源后,apt-get install openvas,直接安装。这个过程是比较快的。 然后执行初始化程序:openvas-setup 这个过程要等待很久。因为openvas 的机制,需要...

shiro启用注解方式

shiro验证权限方式一种是基于url配置文件: 例如: <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityMan...