热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Telegraf+Influxdb2监控系统部署

一、InfluxDB的安装与部署InfluxDB是一个开源分布式时序、事件和指标数

一、InfluxDB的安装与部署

InfluxDB 是一个开源分布式时序、事件和指标数据库。使用 Go 语言编写,无需外部依赖。其设计目标是实现分布式和水平伸缩扩展。

1、官网下载文件并安装(以2.1.1为例,influxdb_v1请自行搜索)

wget https://dl.influxdata.com/influxdb/releases/influxdb2-2.1.1-linux-amd64.tar.gz

tar xzvf influxdb2-2.1.1-linux-amd64.tar.gz

vi /etc/influxdb/influxdb.conf 

[data]

  # The directory where the TSM storage engine stores TSM files.

  dir = "/var/lib/influxdb/data"


  # The directory where the TSM storage engine stores WAL files.

  wal-dir = "/var/lib/influxdb/wal"

[http]

  # Determines whether HTTP endpoint is enabled.

  # enabled = true

  # Determines whether the Flux query endpoint is enabled.

  # flux-enabled = false

  # Determines whether the Flux query logging is enabled.

  # flux-log-enabled = false

  # The bind address used by the HTTP service.

  # bind-address = ":8086"

  

cd influxdb2-2.1.1-linux-amd64

mv influxd /usr/sbin/

vi /etc/systemd/system/influxd.service 

# If you modify this, please also make sure to edit init.sh

[Unit]

Description=InfluxDB is an open-source, distributed, time series database

Documentation=https://docs.influxdata.com/influxdb/

After=network-online.target

[Service]

User=influxdb

Group=influxdb

LimitNOFILE=65536

EnvirOnmentFile=-/etc/default/influxdb

ExecStart=/usr/sbin/influxd -config /etc/influxdb/influxdb.conf

KillMode=control-group

Restart=on-failure

Type=forking

PIDFile=/var/lib/influxdb/influxd.pid


[Install]

WantedBy=multi-user.target

Alias=influxd.service


systemctl daemon-reload

systemctl start influxd

2.数据配置

启动后在windows下访问http://host:8086,第一次登录会提示添加用户配置密码

配置后添加buckets和org

1)点击左侧菜单data,在右侧点buckets->create bucket

2)点击头像,create organization,输入要创建的org name和刚才创建的bucket name

3)点击左侧菜单data,在右侧点api tokens,点击要使用的bucket,记录下token备用

4)点击左侧菜单data,在右侧点telegraf,create configuration生成telegraf配置文件

5)点击左侧菜单board,create dashboard-->import dashboard->paste json,生成influxdb2自带的telegraf面板

https://github.com/influxdata/community-templates/blob/master/linux_system/linux_system.yml

更多模板请参考:

https://www.influxdata.com/products/influxdb-templates/gallery/?_templates_resources=dashboard


3.下载telegraf ,客户端并安装 (input配置请参考telegraf配置文档,本文仅介绍outputs.influxdb_v2 )

使用Telegraf做夜莺5.1的数据采集

telegraf 监控配置

wget https://dl.influxdata.com/influxdb/releases/influxdb2-client-2.2.1-linux-amd64.tar.gz

tar xvfz influxdb2-client-2.2.1-linux-amd64.tar.gz

cd influxdb2-client-2.2.1-linux-amd64

配置telegraf output(可以使用上面生成的配置文件,下边仅供参考)

##influxdb配置简单,如果要使用grafana,建议用influxdb,这个简单(需要根据实际情况配置,telegraf支持同时将采集到的数据输出到多个目标数据库)

[[outputs.influxdb]]

  urls = ["http://127.0.0.1:8286"]

  database = "telegraf"

  database_tag = ""

  

##influxdb_v2配置,请根据实际情况配置

[[outputs.influxdb_v2]]

  urls = ["http://192.168.10.70:8086"]

  token = "9YOBzOmNICJHx9GZHbvfLodocjsXrYz_LfPmphuW3O4c68ZGAQT5RIP_G1Vs-9ziHk16NRRtAYCZE5aLPaY06Q=="

  bucket = "telegraf"



influxdb_v2增加了面板和告警功能,直接配合telegraf就可以实现常用的监控告警功能,不过数据操作使用的是flux,这个相对v1的sql不是太容易入门

如果不习惯用influxdb的面板功能,可以参考下面文章使用grafana

使用grafana监控clickhouse



推荐阅读
author-avatar
-MP5
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有