Skip to content

Add VictoriaMetrics Database Driver (#376) #1295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ljluestc
Copy link

@ljluestc ljluestc commented Jul 5, 2025

The implementation supports label filters and time ranges (e.g., victoria://localhost:8428?label_filter={__name__="up"}&start=2020-08-01T00:00:00Z), as requested, and is designed for high-performance data streaming (per VictoriaMetrics’ API docs).

Changes

  1. VictoriaMetrics Driver (database/victoria/victoria.go):

    • Added a new driver implementing the database.Driver interface.
    • Supports /api/v1/import for writing time series data (JSON line format).
    • Supports /api/v1/export for reading data with label filters and time ranges.
    • Uses DSN victoria://host:port?label_filter=...&start=...&end=....
    • No version tracking, as VictoriaMetrics is schemaless.
  2. Driver Registration (database/database.go):

    • Registered the victoria driver with the database.Register function.
  3. Testing (database/victoria/victoria_test.go):

    • Added unit tests for:
      • Importing data via /api/v1/import.
      • Exporting data via /api/v1/export with label filters.
      • Version handling (returns -1, false).
      • Driver closure and error handling.
    • Used a mock HTTP server to simulate VictoriaMetrics APIs.
    • Ran go test ./database/victoria to confirm functionality.
  4. Dependencies:

    • Added github.com/VictoriaMetrics/metrics v1.23.0 (optional, for potential metric handling).
    • No other external dependencies.

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.

1 participant