您的位置:首页 > 运维架构 > Linux

grafana + influxdb + telegraf , 构建linux性能监控平台

2018-04-03 10:56 836 查看

安装3个软件

1.Grafana安装

grafana , 访问各类数据源 , 自定义报表、显示图表等等 , 用于提供界面监控 , 默认端口为3000 ,如http://127.0.0.1:3000访问, 默认登陆信息账号和密码分别admin和admin

本人系统版本centos7,用yum安装

yum install https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.6.3-1.x86_64.rpm #启动服务
systemctl start grafana
#查看服务状态
systemctl status grafana


其他版本安装参考官网:

http://docs.grafana.org/installation/rpm/

2.InfluxDB 安装

InfluxDB是一个开源数据库别名时序数据库,针对时间序列数据的快速,高可用性存储和检索进行了优化。 InfluxDB非常适合运营监控,应用指标和实时分析。默认端口为Web端8083 , API端8086

#新建一个源仓库
vi /etc/yum.repos.d/influxdata.repo
#输入以下内容
[influxdb]
name = InfluxData Repository - RHEL $releasever
baseurl = https://repos.influxdata.com/rhel/$releasever/$basearch/stable enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key 
#安装
yum install influxdb
#启动服务
systemctl start influxdb
#查看服务状态
systemctl status influxdb


安装完可以登录http://127.0.0.1:8083,默认安装是不需要账号和密码。

3.Telegraf 安装

Telegraf是收集系统和服务器各种源入mysql,nginx等的统计数据 , 并写入到 InfluxDB数据库 ,最后InfluxDB收集到数据给Grafana以各种图表显示

同时Telegraf和Grafana是配套,因为上面设置源,因此可以直接安装

#安装
yum install telegraf


重点是否收集数据到Influx时序库:

3.1 查看Telegraf配置文件

vi /etc/telegraf/telegraf.conf


3.2 定位到[outputs.influxdb] 节点

[[outputs.influxdb]]
## The full HTTP or UDP endpoint URL for your InfluxDB instance.
## Multiple urls can be specified as part of the same cluster,
## this means that only ONE of the urls will be written to each interval.
# urls = ["udp://localhost:8089"] # UDP endpoint example
urls = ["http://localhost:8086"] # required,这个url可以改成自己host
## The target database for metrics (telegraf will create it if not exists).
database = "telegraf" # required,这个会在influx库创建一个库


3.3 启动服务和查看状态

#启动服务
systemctl start telegraf
#查看服务状态
systemctl status telegraf


3.4 进入Influx查看数据库名“telegraf”是否生成

#进入Influx
influx
#查看可用数据库
show databases
#结果如下:
Output
name: databases
name
----
_internal
telegraf   #这个是启动服务后自动生成

#查看收集的字段有那些
show measurements
#结果如下:
Output
name: measurements
name
----
cpu
disk
diskio
kernel
mem
processes
swap
system


啦啦,看到这些数据说明已经收集到数据,我们差一点展示数据就ok了。

4.配置Grafana的数据源(Data Source)和面板(Dashboard)

4.1 数据源配置

1).登陆grafana , 左上角菜单新建数据源 , 并配置好相关信息



这里具体配置源参数



2).我们是监控cpu,内存等等,因此我们直接用别人写好面板直接导入





然后从别人编辑好面板复制https://grafana.com/dashboards/928ID到上面



3).最后看到一切都ok的图表,是不是很happy。

第一张:



第二张:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息