暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

好消息 | Grafana GreptimeDB 数据源插件上线啦,全面替代 Prometheus 插件!

GreptimeDB 2024-06-27
334

01

为什么创建 
GreptimeDB 
数据源插件



此前,用户可以通过 Prometheus 数据源插件,设置连接到 GreptimeDB 来进行 PromQL 查询。


GrpetimeDB 支持了 80% 以上的 PromQL 语法。但是,由于 GreptimeDB 底层使用多值模型,而非 Prometheus 的单值模型,同时 GreptimeDB 支持了许多额外高级功能,使用 Grafana Prometheus 数据源插件连接 GreptimeDB 并不能释放 GreptimeDB 的所有潜能。


因此,我们基于 Prometheus 数据源插件,开发了 Grafana GreptimeDB 数据源插件。该插件原生支持 GreptimeDB 特有的功能,比如支持多值模型,以期更友好、全面地支持 GreptimeDB 相关功能。另外,和直接使用 Prometheus 数据源相比,它还解决了一些兼容性问题。




02

以 Prometheus 
数据源插件作为基石



我们是基于 Grafana Prometheus 内置数据源插件[1] 修改的。Prometheus 数据源插件是集成在 Grafana 里的内置插件,并不是一个标准插件,不能独立运行。


为使 GreptimeDB 插件能作为标准插件运行,主要做了以下改动:

  • 解决前端依赖缺失问题:通过 Webpack alias 解决依赖地址变动问题,并提炼部分代码,减少不必要的依赖;

  • 实现 Go 相关的后台功能(插件内部并没有包含相关 Go 代码)。



03

安装插件



可以选择以下两种方式任意一种安装 GreptimeDB 数据源插件:

1. 从 发布页面[2] 获取最新版本,解压文件到你的 Grafana 插件目录[3]

下载地址形如下:

https://github.com/GreptimeTeam/greptimedb-grafana-datasource/releases/tag/v1.0.37


2. 使用 Grafana 命令行工具下载并安装:
grafana cli --pluginUrl https://github.com/GreptimeTeam/greptimedb-grafana-datasource/releases/latest/download/info8fcc-greptimedb-datasource.zip plugins install info8fcc



04

配置连接



1. 填写 GreptimeDB 服务器 URL,例如 http://<host>:4000

2. 填写数据库名称,默认为 public

3. 如果需要身份验证,选择 basic auth,并填写 GreptimeDB 的用户名和密码。

4. 点击 Save & Test 按钮测试连接。



05

基于本地
GreptimeDB 搭建
Node Exporter Dashboard



在 GreptimeDB 数据源插件开源仓库中,我们提供了一个开箱即用的 Docker Compose 配置文件,可以一键拉起 GreptimeDB、Prometheus、Prometheus Node Exporter、Grafana 和本插件。

克隆仓库并运行 Docker Compose 启动服务:

git clone https://github.com/GreptimeTeam/greptimedb-grafana-datasource.git
cd greptimedb-grafana-datasource/docker
docker compose up


基于 GreptimeDB 数据源插件,上述配置文件的方式可以使用内置的 GreptimeDB Data Source Connection 和 Node Exporter Dashboard,可直接运行查看效果:

1. 输入 http://locahost:3000 打开 Grafana 界面

2. 默认用户名和密码均为 admin

3. 在 Dashboards 页面可以看到 Node Exporter Full 的展示面板


🌟 如果 Dashboards 看不到 Node Export Full,请确认不要勾选 Starred 过滤器。




需要重点关注以下两个配置:

1. 配置 Prometheus Remote-Write 以将数据上传到 GreptimeDB
remote_write:
  - url: http://greptimedb:4000/v1/prometheus/write?db=public


2. 配置 Grafana
grafana:
    image:grafana/grafana:latest
container_name:grafana_info8fcc
ports:
-3000:3000
environment:
-GF_INSTALL_PLUGINS=https://github.com/GreptimeTeam/greptimedb-grafana-datasource/releases/latest/download/info8fcc-greptimedb-datasource.zip;info8fcc//安装插件
volumes:
-../provisioning:/etc/grafana/provisioning//使用预制provision
networks:
- datasource-network



06

通过 GreptimeDB 
数据源插件连接
GreptimeCloud



安装好 Prometheus 客户端,以及 Node Exporter 客户端,即可上传数据到 GreptimeCloud。


需要重点关注以下配置:

1. 配置 Prometheus remote write read

remote_write:
  -url:https://t3yzenagas4a.us-west-2.aws.greptime.cloud/v1/prometheus/write?db=lpw7na1gmw4gcool_debt-public
basic_auth:
username:NXOZb0pywez9y5LpGNFXvSAM
password:********

remote_read:
-url:https://t3yzenagas4a.us-west-2.aws.greptime.cloud/v1/prometheus/read?db=lpw7na1gmw4gcool_debt-public
basic_auth:
username:NXOZb0pywez9y5LpGNFXvSAM
password: ********

2. 配置 GreptimeDB 数据源插件连接


🌟 Host 对应 GreptimeDB server URL,需添加 https:// 前缀。


登录 GreptimeCloud 点击 Connection Information,即可获取配置:


这样就可以通过 GreptimeDB 数据源插件查询 GreptimeCloud 上的数据了。



Reference:

[1] https://github.com/grafana/grafana/tree/v10.3.3/public/app/plugins/datasource/prometheus

[2] https://github.com/GreptimeTeam/greptimedb-grafana-datasource/releases/tag/v1.0.38

[3] https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/#plugins




关于 Greptime

Greptime 格睿科技专注于为物联网(如智慧能源、智能汽车等)及可观测等产生大量时序数据的领域提供实时、高效的数据存储和分析服务,帮助客户挖掘数据的深层价值。目前主要有以下三款产品:


GreptimeDB 是一款用 Rust 语言编写的开源时序数据库,具有云原生、无限水平扩展、高性能和融合分析等特点,帮助企业实时读写、处理和分析时序数据的同时,降低长期存储的成本。我们提供 GreptimeDB 企业版,支持更多企业特性和定制化服务,如有需要欢迎联系我们:15310923206(同微信)。


边云一体方案专为更高效地解决物联网中边缘存储和计算问题而设计,解决了物联网企业数据呈几何倍数增长后的实际业务痛点。它通过将多模式边缘数据库与云端的GreptimeDB 企业版相结合,大幅降低了流量、计算和存储成本,同时提升了数据及时性和商业洞察力。


GreptimeCloud 是一款全托管的云上数据库即服务(DBaaS)解决方案,基于开源时序数据库 GreptimeDB 打造,能够高效支持可观测、物联网、金融等领域的应用。


GreptimeDB 作为开源项目,欢迎对时序数据库、Rust 语言等内容感兴趣的同学们参与贡献和讨论。第一次参与项目的同学推荐先从带有 good first issue 标签的 issue 入手,期待在开源社群里遇见你!扫码添加小助手备注“技术交流群”立即加入讨论吧~


Star us on GitHub Now: 

https://github.com/GreptimeTeam/greptimedb


官网:https://greptime.cn/

文档:https://docs.greptime.cn/

Twitter: https://twitter.com/Greptime

Slack: https://greptime.com/slack

LinkedIn: https://www.linkedin.com/company/greptime/


点击下方链接🔗关注 GreptimeDB,了解更多技术干货👇

往期精彩文章:


👇 点击下方阅读原文,立即体验 GreptimeDB!


文章转载自GreptimeDB,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论