Grafana+InfluxDB+Collectd构建监控系统

本文涉及的产品
可观测可视化 Grafana 版,10个用户账号 1个月
简介:

架构原理

Contents

Collectd(数据采集,配置Server连接InfluxDB的25826端口) -> InfluxDB(数据存储,启用collectd插件监听25826端口) —> Grafana(数据展示)

  • Collectd : C 语言开发的一个守护(daemon)进程,周期性收集统计数据和存储,拥有丰富的插件包括监控Ceph,DRBD,OpenLDAP,ZK等,类似statD(graphite也可以用来采集数据,不过展示功能没有Grafana丰富),数据可以存储在Kafka,InfluxDB,OpenTSDB等上

  • InfluxDB: GO开发的开源分布式时序数据库,适合存储指标,时间,分析等数据

  • Grafana: 是一个开源的,具有丰富指标仪表盘的数据展示和图表编辑工具,支持Graphite,Elasticsearch,OpenTSDB,Prometheus和influxDB,Zabbix等

Collectd

  1. 安装collectd

yum -y  installperl-ExtUtils-Embedperl-ExtUtils-MakeMaker  liboping* 
wgethttps://collectd.org/files/collectd-5.5.0.tar.gz
tarxfcollectd-5.5.0.tar.gz
cdcollectd-5.5.0./configure --enable-cpu  --enable-df --enable-disk --enable-interface --enable-load --enable-memory --enable-ping --enable-swap --enable-users --enable-uptimemake && makeinstall
cpcontrib/redhat/init.d-collectd  /etc/rc.d/init.d/collectd
chmod +x /etc/rc.d/init.d/collectdln -s /opt/collectd/sbin/collectdmon  /usr/sbin/ln -s /opt/collectd/sbin/collectd  /usr/sbin/
  1. 配置collectd

    vim /etc/collectd.confBaseDir "/opt/collectd"PIDFile "/run/collectd.pid"Hostname "host.example.com"Interval 60<loadplugindf>Interval 120</loadplugin>LoadPlugindiskLoadPlugininterfaceLoadPluginloadLoadPluginmemoryLoadPluginnetworkLoadPluginprocessesLoadPluginusers<plugininterface>Interface "eth1"IgnoreSelectedfalse</plugin><pluginnetwork>Server "10.44.38.244" "25826"</plugin>
  2. 说明 
    默认collectd进程会每10s中调用注册在配置文件中的插件,默认全局参数interval=10s(10s上报一次数据到influxdb等),针对不同的插件可以配置不同的搜集数据的时间间隔interval

InfluxDB

  1. 安装并启动服务

    cat < <EOF | sudotee /etc/yum.repos.d/influxdb.repo
    [influxdb]
    name = InfluxDBRepository - RHEL \$releaseverbaseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
    enabled = 1gpgcheck = 1gpgkey = https://repos.influxdata.com/influxdb.key
    EOF
    yum -y installinfluxdb
    serviceinfluxdbstart
    启动后TCP端口:8083 为InfluxDB 管理控制台
      TCP端口:8086 为客户端和InfluxDB通信时的HTTPAPI
    启动后InfluxDB用户认证默认是关闭的,先创建用户:geekwolfgeekwolf
    命令行输入influx
  2. 基本使用

    [root@geekwolf ~]# influx
    Visithttps://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
    Connectedto http://localhost:8086 version 0.12.2InfluxDBshell 0.12.2> createdatabasecollectdb
    > createdatabasecollectdb
    > showdatabases
    name: databases
    \------
    name
    _internal
    collectdb
    > createusergeekwolfwithpassword 'geekwolf'> showusers
    user            admin
    geekwolf        false
    > grantalloncollectdbfromto geekwolf
    > helpshow
    Usage:
        connect <host:port>  connectsto anothernodespecifiedbyhost:port    auth                  promptsfor usernameand password
        pretty                togglesprettyprint for thejsonformat
        use <db_name>        setscurrentdatabase
        format <format>      specifiestheformatoftheserverresponses: json, csv, or column
        precision </format><format>    specifiestheformatofthetimestamp: rfc3339, h, m, s, ms, u or ns
        consistency <level>  setswriteconsistencylevel: any, one, quorum, or all    history              displayscommandhistory
        settings              outputsthecurrentsettingsfor theshell
        exit/quit/ctrl+d      quitstheinfluxshell
     
        showdatabases        showdatabasenames
        showseries          showseriesinformation
        showmeasurements    showmeasurementinformation
        showtagkeys        showtagkeyinformation
        showfieldkeys      showfieldkeyinformation
     
        A fulllist ofinfluxqlcommandscanbefoundat:    https://docs.influxdata.com/influxdb/v0.10/query_language/spec
  3. 启用认证

    修改配置文件启用认证
    sed -i ’s#auth-enabled = false#auth-enabled = true#g’ /etc/influxdb/influxdb.conf
    serviceinfluxdbrestart

配置InfluxDB支持Collectd

  1. 修改配置

    vim /etc/influxdb/influxdb.conf[collectd]
    enabled = true
    bind-address = "10.44.38.244:25826"database = "collectdb"typesdb = "/opt/collectd/share/collectd/types.db"batch-size = 5000batch-pending = 10batch-timeout = "10s"read-buffer = 0serviceinfluxdbrestart
  2. 查看metrics信息

[root@geekwolf ~]# influx
Visithttps://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.Connectedto http://localhost:8086 version 0.12.2InfluxDBshell 0.12.2> use collectdb
Usingdatabasecollectdb
> showfieldkeysname: cpu_value
---------------
fieldKey
value
 name: df_free
-------------
fieldKey
value
 name: df_used
-------------
fieldKey
value
 name: disk_read
---------------
fieldKey
value
> select * fromcpu_valuelimit 15;name: cpu_value
---------------
time                    host                    instance        type    type_instance  value1461657293000000000    host.example.com        1              cpu    idle            1.59845e+061461657293000000000    host.example.com        1              cpu    system          23161461657293000000000    host.example.com        1              cpu    nice            5081461657293000000000    host.example.com        0              cpu    steal          01461657293000000000    host.example.com        1              cpu    user            116191461657293000000000    host.example.com        1              cpu    interrupt      01461657293000000000    host.example.com        1              cpu    steal          01461657293000000000    host.example.com        1              cpu    wait            1721461657293000000000    host.example.com        1              cpu    softirq        01461657303000000000    host.example.com        1              cpu    wait            1721461657303000000000    host.example.com        1              cpu    softirq        01461657303000000000    host.example.com        1              cpu    nice            5081461657303000000000    host.example.com        0              cpu    idle            1.587007e+061461657303000000000    host.example.com        0              cpu    softirq        1271461657303000000000    host.example.com        0              cpu    interrupt      54

安装配置Grafana

yuminstallhttps://grafanarel.s3.amazonaws.com/builds/grafana-3.0.0-beta51460725904.x86_64.rpm目录结构/usr/sbin/grafana-server/etc/init.d/grafana-server          上述命令的拷贝,启动脚本/etc/sysconfig/grafana-server      环境变量/etc/grafana/grafana.ini            配置文件/var/log/grafana/grafana.log        日志文件/var/lib/grafana/grafana.db    sqlite3数据库
 
启动服务: servicegrafana-serverstart
        chkconfiggrafana-serveron

访问地址:http://10.44.38.244:3000 默认账号为admin admin关闭Grafana注册功能:

sed -i ’s/#allow_sign_up = true/allow_sign_up = false/g’  /etc/grafana/grafana.ini,重启服务
  • 界面添加InfluxDB数据源及监控例子即可





















本文转自super李导51CTO博客,原文链接: http://blog.51cto.com/superleedo/1893877 ,如需转载请自行联系原作者
相关实践学习
通过可观测可视化Grafana版进行数据可视化展示与分析
使用可观测可视化Grafana版进行数据可视化展示与分析。
相关文章
|
3月前
|
监控 Java 时序数据库
性能监控之Telegraf+InfluxDB+Grafana实现JMX实时监控
【6月更文挑战15天】性能监控之Telegraf+InfluxDB+Grafana实现JMX实时监控
116 6
性能监控之Telegraf+InfluxDB+Grafana实现JMX实时监控
|
20天前
|
Prometheus 数据可视化 Cloud Native
构建交互式的 Grafana 仪表盘
【8月更文第29天】Grafana 是一个功能强大的数据可视化工具,它支持多种数据源并能够创建高度定制化的仪表盘。通过使用交互式面板,用户可以更直观地探索数据并进行数据分析。本文将介绍如何设计和实现用户友好的交互式面板,以提高数据分析效率,并提供具体的代码示例。
26 2
|
20天前
|
Prometheus 监控 数据可视化
Grafana 插件生态系统:扩展你的监控能力
【8月更文第29天】Grafana 是一个流行的开源平台,用于创建和共享统计数据的仪表板和可视化。除了内置的支持,Grafana 还有一个强大的插件生态系统,允许用户通过安装插件来扩展其功能。本文将介绍一些 Grafana 社区提供的插件,并探讨它们如何增强仪表盘的功能性。
30 1
|
20天前
|
存储 Prometheus 监控
Grafana 与 Prometheus 集成:打造高效监控系统
【8月更文第29天】在现代软件开发和运维领域,监控系统已成为不可或缺的一部分。Prometheus 和 Grafana 作为两个非常流行且互补的开源工具,可以协同工作来构建强大的实时监控解决方案。Prometheus 负责收集和存储时间序列数据,而 Grafana 则提供直观的数据可视化功能。本文将详细介绍如何集成这两个工具,构建一个高效、灵活的监控系统。
73 1
|
20天前
|
Prometheus 监控 Cloud Native
Grafana 入门指南:快速上手监控仪表盘
【8月更文第29天】Grafana 是一款开源的数据可视化和监控工具,它允许用户轻松地创建美观的仪表盘和图表,以便更好地理解和监控数据。无论您是需要监控系统性能指标、应用程序日志还是业务关键指标,Grafana 都能提供灵活而强大的解决方案。本指南将带领您快速上手 Grafana,包括安装、配置以及创建第一个监控面板。
69 1
|
1月前
|
存储 Linux 数据库
性能工具之JMeter + Grafana + InfluxDB 性能平台搭建
【8月更文挑战第7天】性能工具之JMeter + Grafana + InfluxDB 性能平台搭建
49 1
性能工具之JMeter + Grafana + InfluxDB 性能平台搭建
|
1月前
|
Prometheus Kubernetes 监控
Kubernetes(K8S) 监控 Prometheus + Grafana
Kubernetes(K8S) 监控 Prometheus + Grafana
121 2
|
14天前
|
运维 Kubernetes 监控
Loki+Promtail+Grafana监控K8s日志
综上,Loki+Promtail+Grafana 监控组合对于在 K8s 环境中优化日志管理至关重要,它不仅提供了强大且易于扩展的日志收集与汇总工具,还有可视化这些日志的能力。通过有效地使用这套工具,可以显著地提高对应用的运维监控能力和故障诊断效率。
30 0
|
1月前
|
数据采集 监控 Unix
性能监控之Telegraf+InfluxDB+Grafana实现结构化日志实时监控
【8月更文挑战第1天】性能监控之Telegraf+InfluxDB+Grafana实现结构化日志实时监控
159 0
|
2月前
|
监控 数据可视化 关系型数据库
PolarDB产品使用问题之如何使用Grafana采集PolarDB的指标并进行可视化监控
PolarDB产品使用合集涵盖了从创建与管理、数据管理、性能优化与诊断、安全与合规到生态与集成、运维与支持等全方位的功能和服务,旨在帮助企业轻松构建高可用、高性能且易于管理的数据库环境,满足不同业务场景的需求。用户可以通过阿里云控制台、API、SDK等方式便捷地使用这些功能,实现数据库的高效运维与持续优化。