@grafana/prometheus

中文文档
13.2.2发布于 2026/09/29AGPL-3.0-onlyTypeScriptESM + CJS构建来源已验证近 30 天下载 11万

Grafana Prometheus Library

原始使用文档

Grafana Prometheus NPM Library

@grafana/prometheus is currently in ALPHA.

@grafana/prometheus is a collection of components used to build a Prometheus data source plugin in Grafana.

See package source for more details.

Installation

yarn add @grafana/prometheus

npm install @grafana/prometheus

Extended range selectors

The query builder supports Anchored rate, Anchored increase, Anchored delta, Anchored changes, Anchored resets, Smoothed rate, Smoothed increase, and Smoothed delta under Range functions. Code mode also recognizes the modifier syntax and offers completions after supported selectors.

increase(http_requests_total[5m] anchored)
rate(http_requests_total[5m] smoothed)

anchored uses observed samples at the range boundaries without extrapolation or interpolation. smoothed interpolates boundary values using surrounding samples. Because smoothing needs samples after the end of the range, recent results can be underestimated; recording and alerting rules should use a rule group query_offset.

The Prometheus server must support extended range selectors and run with --enable-feature=promql-extended-range-selectors. Supported sample types depend on the server version. Extended range selectors do not support subqueries. Instant selectors with smoothed, and modified selectors combined with offset or @, can be used in Code mode; Builder reports a conversion error for those forms. See the Prometheus extended range selector documentation.

版本与发布记录

@grafana/prometheus 共发布 9,585 个版本,首次发布于 2024/02/16;过去 12 个月发布了 5169 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
13.2.2latest2026/09/291 个月前
13.2.12026/09/231 个月前
13.2.02026/09/221 个月前
13.1.142026/08/272 个月前
13.1.132026/08/272 个月前
13.1.122026/07/293 个月前

其他发布通道:next → 11.0.0-preview,11.5-latest → 11.5.8,11.6-latest → 11.6.5,12.1-latest → 12.1.1,nightly → 12.2.0-17630182352,v11.5-latest → 11.5.10。

关于 @grafana/prometheus 的常见问题

@grafana/prometheus 是什么?

Grafana Prometheus Library

如何安装 @grafana/prometheus?

在项目目录运行 npm install @grafana/prometheus,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(18.3.1)、react-dom(18.3.1)、@grafana/ui(13.1.7)、@grafana/data(13.1.7)、@grafana/i18n(13.1.7)、@grafana/schema(13.1.7)、@grafana/runtime(13.1.7)、@grafana/e2e-selectors(13.1.7)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@grafana/prometheus 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@grafana/prometheus 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@grafana/prometheus 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@grafana/prometheus 可以商用吗?

@grafana/prometheus 使用 AGPL-3.0-only 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@grafana/prometheus 的下载量有多少?

根据 npm 官方下载统计,@grafana/prometheus 在 2026/10/17 – 2026/11/15 这 30 天内被下载 109,557 次,日均约 3,652 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@grafana/prometheus 还在维护吗?

最新版本 13.2.2 发布于 2026/09/29(1 个月前);至今共发布 9585 个版本,其中过去 12 个月发布了 5169 个;首次发布于 2024/02/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。