vmagentfdw
vmagentfdw · Foreign data wrapper for reading vmagent scrape-target status through its HTTP API.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101198 | vmagentfdw | vmagentfdw | 0.0.2 | FDW | Apache-2.0 | Rust |
PostgreSQL · 14, 15, 16
Usage
Sources:
vmagentfdw is a read-only Rust foreign data wrapper that exposes vmagent’s active and dropped scrape targets as PostgreSQL rows. It reads the vmagent /api/v1/targets endpoint synchronously during a foreign-table scan, so remote latency and availability directly affect the querying backend.
Core Workflow
Install the extension, register the handler and validator, and point a foreign server at a trusted vmagent endpoint:
Define only the columns needed by queries. Their names drive the wrapper’s value mapping:
Column Mapping
stateis synthesized asactiveordroppedfrom the response section containing the target.health,last_samples_scraped,last_scrape_duration,last_scrape,last_error,scrape_url, andscrape_poolmap the corresponding target fields.labelsanddiscovered_labelsreturn the complete label maps as JSONB.- A column named
labels_<key>projects one entry from the target’s label map. Unrecognized columns return NULL.
Operational Caveats
The implementation fetches all active and dropped targets for each scan and does not push PostgreSQL filters, ordering, or limits into the HTTP request. It implements no write callbacks. The reviewed source declares builds for PostgreSQL 14, 15, and 16, but compatibility still depends on the installed binary. Restrict who may create or query servers, use a bounded and trusted endpoint, and enforce suitable statement/network timeouts. The documented options provide only the endpoint address; authentication and TLS policy must therefore be handled by the selected URL and surrounding network controls.