Skip to content

feat(providers): add GreptimeDB metric provider#10

Open
shilicqupt wants to merge 4 commits intoalibaba:mainfrom
shilicqupt:feat/greptimedb-provider
Open

feat(providers): add GreptimeDB metric provider#10
shilicqupt wants to merge 4 commits intoalibaba:mainfrom
shilicqupt:feat/greptimedb-provider

Conversation

@shilicqupt
Copy link
Copy Markdown
Contributor

@shilicqupt shilicqupt commented Apr 30, 2026

Summary

  • Add GreptimeDB as a new metric provider (-p greptimedb / -p greptime).
  • Reuse the shared PromqlMetricProvider with path prefix /v1/prometheus for query, list, labels, label-values, and series.
  • Do not advertise metric info support because GreptimeDB does not currently expose the Prometheus metadata endpoint.
  • Reject metric info locally with an unsupported error instead of calling the known-missing backend endpoint.
  • Register the obz-greptimedb skill in the embedded skill registry.
  • Document bearer token auth, basic auth, unauthenticated config, and provider check usage.

Changes

File Change
crates/providers/src/greptimedb/mod.rs New provider module with meta() and build(); delegates supported PromQL commands and rejects metric info locally
crates/providers/src/greptimedb/convert.rs Re-exports shared PromQL conversions
crates/providers/src/greptimedb/response.rs Re-exports shared PromQL response types
crates/providers/src/lib.rs Register greptimedb::meta()
crates/obz/src/skills.rs Register embedded obz-greptimedb skill and add tests
skills/obz-greptimedb/SKILL.md Provider skill document for AI agents
README.md / README.zh-CN.md Add GreptimeDB to provider support tables

Usage

# Instant query
obz metric query -p greptimedb --endpoint http://localhost:4000 -q 'up'

# Range query
obz metric query -p greptimedb --endpoint http://localhost:4000 \
  -q 'rate(http_requests_total[5m])' --from now-1h --range

# With config file
# ~/.config/obz/config.yaml:
# providers:
#   greptime-local:
#     provider: greptimedb
#     endpoint: http://localhost:4000
obz metric query -p greptime-local -q 'up'

# Health check for a configured provider name
obz provider check greptime-local

Test plan

  • cargo fmt --check
  • cargo test -p obz-providers greptimedb -- --nocapture
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
  • cargo deny check licenses bans sources (passes with existing unmatched-license warnings)
  • cargo build
  • ./target/debug/obz metric info -p greptimedb --endpoint http://localhost:4000 up returns unsupported without a backend request
  • ./target/debug/obz skills show obz-greptimedb
  • ./target/debug/obz skills list | rg 'obz-greptimedb|GreptimeDB'
  • ./target/debug/obz provider list shows the greptimedb entry

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 30, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Collaborator

@yaohe-wzh yaohe-wzh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the GreptimeDB provider. I tested this PR locally against GreptimeDB v1.0.1 and reviewed the provider wiring. The overall direction looks good — reusing the shared PromQL provider with the /v1/prometheus prefix is the right approach — but I think there are a few issues to fix before merge.

  1. Please do not declare metric info as supported for GreptimeDB.

GreptimeDB v1.0.1 does not expose the Prometheus metadata endpoint used by obz metric info:

GET /v1/prometheus/api/v1/metadata

Local verification:

/v1/health                                -> 200
/v1/prometheus/api/v1/query               -> 200
/v1/prometheus/api/v1/labels              -> 200
/v1/prometheus/api/v1/series              -> 200
/v1/prometheus/api/v1/label/{name}/values -> 200
/v1/prometheus/api/v1/metadata            -> 404

GreptimeDB also has an upstream issue for this exact missing API: GreptimeTeam/greptimedb#4824 (/v1/prometheus/api/v1/metadata not supported).

So SupportedCommands should be changed to:

metric_query: true,
metric_list: true,
metric_info: false,
metric_labels: true,
metric_label_values: true,
metric_series: true,

Please also update README.md, README.zh-CN.md, and skills/obz-greptimedb/SKILL.md so they no longer say that all six metric commands work or that GreptimeDB supports metric info.

  1. The new obz-greptimedb skill is not registered in the embedded skill registry.

This PR adds:

skills/obz-greptimedb/SKILL.md

but it is not added to crates/obz/src/skills.rs::SKILLS. As a result, the built binary cannot show the skill:

$ ./target/debug/obz skills show obz-greptimedb
unknown skill 'obz-greptimedb' — run `obz skills list` to see available skills

Please add the corresponding SkillEntry and update the skill registry tests so obz skills list/show/install can see the GreptimeDB skill.

  1. Please fix the provider check example in the skill document.

The current skill doc says:

obz provider check -p greptimedb --endpoint http://localhost:4000

However, provider check does not accept -p or --endpoint; it checks a configured provider name. The example should instead configure a provider first, then run something like:

obz provider check greptimedb

I also ran the usual Rust checks on this branch:

cargo fmt --check                         passed
cargo clippy --workspace --all-targets -- -D warnings  passed
cargo test                                passed
cargo build                               passed
cargo deny check licenses bans sources    passed, with existing unmatched-license warnings only

Once metric_info is disabled for GreptimeDB and the skill registry/docs are fixed, this provider should be in much better shape for merge.

Copy link
Copy Markdown
Collaborator

@yuanmao16 yuanmao16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this PR follows the established provider pattern well — reusing PromqlMetricProvider with the /v1/prometheus path prefix is the right approach. A few issues around documentation accuracy and a minor lint concern below.

Comment on lines +63 to +68
providers:
greptime-prod:
endpoint: http://localhost:4000
auth:
username: ${env:GREPTIME_USER}
password: ${env:GREPTIME_PASS}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config key greptime-prod differs from the provider's internal name greptimedb, so a provider: greptimedb field is needed here — otherwise obz won't know which provider this config entry maps to.

Same issue on line 81 for the greptime-local example.

Compare with README.md examples for sls, dd, es-prod which all include the provider: field.

Comment thread skills/obz-greptimedb/SKILL.md Outdated
| Signal | Metric |
| Query language | PromQL |
| Default port | 4000 (HTTP) |
| Auth | Basic auth or no auth |
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Quick Reference says Auth is Basic auth or no auth, but the code in mod.rs line 63 calls config.bearer_token(), meaning bearer token auth is also supported. This should read something like Bearer token, Basic auth, or no auth to reflect the actual capability.

//! payloads to standard Prometheus, so we reuse the shared conversion
//! logic from the `promql` module.

#[allow(unused_imports)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#[allow(unused_imports)] is used here without a justification comment. Per project guidelines (AGENTS.md), suppressing warnings requires justification. Since these re-export files exist for structural consistency with other PromQL-based providers (Mimir, Prometheus), consider adding a brief comment above the attribute, e.g.:

// Structural consistency with other PromQL-based providers;
// imports are used by tests and future provider-specific overrides.

Same applies to response.rs.

Comment thread crates/providers/src/greptimedb/mod.rs Outdated
Comment on lines +10 to +14
//! `GreptimeDB` routes queries to the `public` database by default.
//! To target a different database, append `?db=<name>` directly in
//! your queries or set a custom `db` query parameter via the `db`
//! config key (passed as an extra header workaround is not needed —
//! the default works for most deployments).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph is a bit hard to follow — "passed as an extra header workaround is not needed" reads as a parenthetical that references a workaround the reader has no context for. Consider simplifying to:

To target a different database, pass the db query parameter in your PromQL request. The default database is public, which suits most deployments.

Comment on lines +57 to +69
## Authentication

GreptimeDB supports basic auth (username + password). Configure credentials
in `~/.config/obz/config.yaml`:

```yaml
providers:
greptime-prod:
endpoint: http://localhost:4000
auth:
username: ${env:GREPTIME_USER}
password: ${env:GREPTIME_PASS}
```
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the code supports bearer token auth (via config.bearer_token()), it would be useful to add a token-based config example here alongside the basic auth and no-auth examples, e.g.:

providers:
  greptime-cloud:
    provider: greptimedb
    endpoint: https://greptime.example.com
    auth:
      token: ${env:GREPTIME_TOKEN}

Comment thread README.md
Comment on lines +5 to +10
[![CI](https://github.com/alibaba/obz-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/alibaba/obz-cli/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/alibaba/obz-cli?sort=semver&display_name=tag)](https://github.com/alibaba/obz-cli/releases)
[![crates.io](https://img.shields.io/crates/v/obz.svg)](https://crates.io/crates/obz)
[![Downloads](https://img.shields.io/github/downloads/alibaba/obz-cli/total)](https://github.com/alibaba/obz-cli/releases)
[![License](https://img.shields.io/github/license/alibaba/obz-cli)](LICENSE)
[![Rust](https://img.shields.io/badge/rust-1.75%2B-orange.svg)](Cargo.toml)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These badge additions are unrelated to the GreptimeDB provider feature. Mixing unrelated changes into a feature PR makes it harder to review and revert independently. Consider splitting them into a separate commit or PR.

shili2088 and others added 3 commits April 30, 2026 16:18
GreptimeDB exposes a Prometheus-compatible HTTP API under /v1/prometheus,
so we reuse the shared PromqlMetricProvider with that path prefix. All six
metric commands (query, list, info, labels, label-values, series) work
out of the box. Provider aliases: greptimedb, greptime. Health check uses
/v1/health. Auth: basic auth or unauthenticated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wrap GreptimeDB in backticks in all doc comments to satisfy
clippy::doc_markdown, and collapse the check closure to a single line
to match rustfmt output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shilicqupt shilicqupt force-pushed the feat/greptimedb-provider branch from 9ccb409 to 4c3b0c8 Compare April 30, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants