grafana+influxdb+telegraf搭建服务器监控平台

grafana+influxdb+telegraf搭建服务器监控平台

前言

[收集数据] Telegraf 是一个用 Go 编写的代理程序,可收集系统和服务的统计数据,并写入到 InfluxDB 数据库。Telegraf 具有内存占用小的特点,通过插件系统开发人员可轻松添加支持其他服务的扩展。[存储数据] InfluxDB 是 Go 语言开发的一个开源分布式时序数据库,针对时间序列数据的快速,高可用性存储和检索进行了优化,非常适合运营监控,应用指标和实时分析。[展示数据] Grafana 是纯 Javascript 开发的web应用,用于提供界面监控,访问各类数据源,自定义报表、显示图表等等。

官方文档地址

telegraf: https://docs.influxdata.com/telegraf/v1.8/influxdb: https://docs.influxdata.com/influxdb/v1.6/grafana: http://docs.grafana.org/

系统版本centos7

telegraf安装

下载安装

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

启动服务、查看状态、添加开机启动

systemctl start telegraf.serviceservice telegraf statussystemctl enable telegraf.service

查看版本号

telegraf --version

配置

默认路径:/etc/telegraf/telegraf.conf

influxdb安装

下载安装

sudo wget https://dl.influxdata.com/influxdb/releases/influxdb-1.6.4.x86_64.rpmsudo yum localinstall influxdb-1.6.4.x86_64.rpm

启动服务、查看状态、添加开机启动

service influxdb startservice influxdb statussystemctl enable influxdb

查看版本号

influx --version

配置

默认路径:/etc/influxdb/influxdb.conf

启用端口

Networking By default, InfluxDB uses the following network ports:TCP port ==8083== is used for InfluxDB’s Admin panelTCP port ==8086== is used for client-server communication over InfluxDB’s HTTP APITCP ports ==8088== and 8091 are required for clustered InfluxDB instances

进入Influx查看数据库

查看服务端口

grafana安装

下载安装

sudo wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.1-1.x86_64.rpmsudo yum localinstall grafana-5.3.1-1.x86_64.rpm

启动服务、查看状态、添加开机启动

systemctl start grafana-server-serversystemctl status grafana-serversystemctl enable grafana-server

查看版本号

grafana -v

配置

默认路径:/etc/grafana/grafana.ini

启用端口

默认端口为3000 ,如http://127.0.0.1:3000访问, 默认登陆信息账号和密码分别admin和admin

Grafana使用及配置

登录http://127.0.0.1:3000,默认用户名admin,密码admin

进入后,首先选择Add Data Sources,添加需要的数据源


然后进入dashboard页面,创建仪表盘。我们可以通过访问https://grafana.com/dashboards来查看已经由其他用户共享的仪表盘,选取合适的使用,缩短上手时间,也可以自己自定义创建表盘。在这里选取的是两个仪表盘https://grafana.com/dashboards/1443https://grafana.com/dashboards/928这两个仪表盘内已经基本涵盖一个系统需要监控的相关参数

通过导入该仪表盘进入grafana后,选择我们需要的数据源,最终的监控仪表盘的效果如下

Telegraf Host Metrics

system dashboard