telegraf、influxdb、grafana抽取、存储、展示数据

本文介绍小白使用工具telegraf、influxdb、grafana对数据进行抽取、存储、展示的构建过程
环境:macos、Telegraf 1.15.2、InfluxDB 1.8.2、grafana

导航
1、telegraf的下载安装,启动,重启
2、influxdb的下载安装,启动,重启
3、telegraf配置文件的influxdb输出,与influxdb的创建的数据库用户,密码,数据库名称一致。
4、grafana配置influx数据源,右侧选择图表类型,下侧选择监控字段
5、telegraf监控信息字段解释:https://www.cnblogs.com/foolaround/p/12923932.html
6、grafana面板参数解释:https://www.cnblogs.com/i6010/articles/11608695.html

1、telegraf下载:brew install telegraf
      telegraf启动:brew services start telegraf
      telegraf重启:brew services restart telegraf
2、influxdb下载:brew install influxdb
      influxdb启动:influxd -config /usr/local/etc/influxdb.conf
      influxdb重启:influxd -config /usr/local/etc/influxdb.conf
      进入influxdb:命令行输入influx
      创建用户与密码:create user “telegraf” with password “password”,此处的用户和密码在telegraf连接时需用到。
      查询用户:show users;
      创建数据库:create database telegraf
      查询数据库:show databases
      使用某一数据库:use telegraf
      查询数据表:show measurements
      查询表中数据:select * from cpu

3、telegraf配置文件:

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
   debug = false
   quiet = false
  hostname = ""
  omit_hostname = false
[[outputs.influxdb]]
   urls = ["http://127.0.0.1:8086"]
   database = "telegraf"
   retention_policy = ""
   timeout = "5s"
   username = "telegraf"
   password = "password"

软链接:ln -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents
cp ./influxdb.conf /etc/influxdb/
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.influxdb.plist
启动influxdb拉取数据规则的任务

4、grafana配置influx数据源,右侧选择图表类型,下侧选择监控字
在这里插入图片描述
5、telegraf收集数据说明:
1、CPU、Disk、Diskio、MEM、NETSTAT、System、SWAP。

6、grafana的下载安装,启动。
   brew install grafana
   brew services start grafana
访问地址:http://127.0.0.1:3000/
默认账号和密码:admin/admin

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
数据抽取存储过程的编写需要根据具体的业务场景和数据源来确定,下面是一个简单的示例: ``` CREATE OR REPLACE PROCEDURE extract_sales_orders AS BEGIN -- 删除临时表中的数据 DELETE FROM tmp_sales_orders; -- 从ERP系统中抽取销售订单数据到临时表中 INSERT INTO tmp_sales_orders (order_id, order_date, customer_id, product_id, quantity, price) SELECT order_id, order_date, customer_id, product_id, quantity, price FROM erp_sales_orders WHERE order_date >= TRUNC(SYSDATE) - 7; -- 只抽取最近7天的订单数据 -- 将临时表中的数据插入到数据仓库的销售订单事实表中 INSERT INTO sales_orders (order_id, order_date_key, customer_key, product_key, quantity, price) SELECT tmp.order_id, DIM_DATE.date_key, DIM_CUSTOMER.customer_key, DIM_PRODUCT.product_key, tmp.quantity, tmp.price FROM tmp_sales_orders tmp JOIN DIM_DATE ON tmp.order_date = DIM_DATE.date JOIN DIM_CUSTOMER ON tmp.customer_id = DIM_CUSTOMER.customer_id JOIN DIM_PRODUCT ON tmp.product_id = DIM_PRODUCT.product_id; END; ``` 上面的示例中,我们首先定义了一个名为 `extract_sales_orders` 的存储过程,然后在存储过程中执行了以下操作: 1. 删除临时表中的数据,以确保每次抽取数据是最新的。 2. 从 ERP 系统中抽取最近 7 天的销售订单数据到临时表 `tmp_sales_orders` 中。 3. 将临时表中的数据插入到数据仓库的销售订单事实表 `sales_orders` 中,同时使用维度表 `DIM_DATE`、`DIM_CUSTOMER`、`DIM_PRODUCT` 进行关联,以获取订单日期、客户和产品的维度键。 这只是一个简单的示例,实际的数据抽取存储过程需要考虑更多的细节和业务规则。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值