MCPcopy Index your code
hub / github.com/Jayko001/prometheus_fdw

github.com/Jayko001/prometheus_fdw @v0.2.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.1 ↗ · + Follow
15 symbols 17 edges 3 files 1 documented · 7% updated 17mo agov0.2.1 · 2024-12-20★ 493 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Prometheus_fdw

Prometheus_fdw is an integration of Prometheus monitoring data into Postgres. It enables querying for Prometheus metrics directly within Postgres, bridging the gap between Prometheus monitoring and Postgres's robust database capabilities. Static Badge PGXN version

Pre-requisistes

  • Install prometheus_fdw
  • (Optional) install pg_partman and pg_cron

Quick start

create extension prometheus_fdw;

Create the foreign data wrapper:

create foreign data wrapper prometheus_wrapper
  handler prometheus_fdw_handler
  validator prometheus_fdw_validator;

Create the server:

create server my_prometheus_server
  foreign data wrapper prometheus_wrapper
  options (
    base_url '<base prometheus url>');

Create Foreign Table:

CREATE FOREIGN TABLE IF NOT EXISTS metrics (
  metric_name TEXT,
  metric_labels JSONB,
  metric_time BIGINT,
  metric_value FLOAT8
  )
server my_prometheus_server
options (
  object 'metrics',
  step '10m'
);

Queries

To simply run the fdw and look at values

SELECT
  *
FROM metrics
WHERE
  metric_name='container_cpu_usage_seconds_total'
  AND metric_time > 1696046800 AND metric_time < 1696133000;

Examples

Please see the examples/ directory to find a basic example and a practical example. In the practical example, metrics are automatically synced into the database using pg_cron, and automatically expired using pg_partman. Performance is optimized using indexes and partitioning.

Core symbols most depended-on inside this repo

resp_to_rows
called by 1
src/lib.rs
build_url
called by 1
src/lib.rs
from
called by 0
src/lib.rs
value_to_promql_string
called by 0
src/lib.rs
new
called by 0
src/lib.rs
begin_scan
called by 0
src/lib.rs
iter_scan
called by 0
src/lib.rs
end_scan
called by 0
src/lib.rs

Shape

Method 8
Function 5
Class 1
Enum 1

Languages

Rust100%

Modules by API surface

src/lib.rs11 symbols
src/init.rs4 symbols

For agents

$ claude mcp add prometheus_fdw \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact