obmp-docker/postgres/scripts/008_obmp_policy_diff.sql
sam b681c473c0 Add Policy Diff, fleet-wide full-table feed, and Kafka lag monitoring
Policy Diff (roadmap E2 follow-up): obmp-rib-poller pulls per-router
post-policy accepted/advertised prefix counts and route-policy bindings
over CLI+NETCONF (BMP on XRv9000 24.3.1 carries only pre-policy
Adj-RIB-In). New tables in 008_obmp_policy_diff.sql; Policy Diff
dashboard joins them against BMP ip_rib for received-vs-kept-vs-rejected.

GoBGP fleet-wide feed: GoBGP re-advertises the full Bromirski table to
both labs' core routers (CML AS65020, PROX AS65021) over eBGP; as route
reflectors the cores propagate it to every R9K client, so all 18 lab
routers carry and BMP-export a full table -- an intentional stress test
of the ingestion/storage path. cml/gobgp_peering_config.py applies and
rolls back the core-side config; gobgp/README.md documents the rollback.

Kafka lag monitoring: kafka-lag-monitor samples consumer-group lag every
30s into TimescaleDB (009_kafka_lag.sql); Kafka Ingestion Lag dashboard
gives visibility into the pipeline under churn load.

Peer Detail dashboard: the Peer selector is now router-qualified
(router -> peer) so it is unambiguous in an iBGP route-reflector mesh.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-19 12:42:25 -07:00

54 lines
2.5 KiB
SQL

-- 008_obmp_policy_diff.sql
-- Policy Diff feature -- per-router routing-policy retrieval plus per-neighbor
-- received / kept / advertised counts, populated by the obmp-rib-poller
-- service (obmp-rib-poller/poller.py).
--
-- Why a poller and not BMP: on the lab's XRv9000 24.3.1 routers BMP only
-- carries pre-policy Adj-RIB-In. `route-monitoring inbound post-policy`
-- replaces (does not supplement) the pre-policy export and is not flagged
-- distinctly, and adj-rib-out BMP (RFC 8671) is unsupported on that image.
-- So "kept after inbound policy" and "advertised" are pulled directly from
-- the routers over CLI + NETCONF.
--
-- The Policy Diff dashboard joins router_rib_stats against BMP ip_rib
-- (received, pre-policy) to show received vs kept vs discarded vs advertised.
-- Full route-policy (RPL) bodies, one row per policy per router.
CREATE TABLE IF NOT EXISTS route_policies (
router_hash_id uuid NOT NULL,
policy_name varchar(256) NOT NULL,
body text,
retrieved_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (router_hash_id, policy_name)
);
-- Which route-policy is bound inbound/outbound on each neighbor address-family.
CREATE TABLE IF NOT EXISTS neighbor_policy_bind (
router_hash_id uuid NOT NULL,
peer_addr inet NOT NULL,
afi varchar(8) NOT NULL, -- ipv4 / ipv6
direction varchar(4) NOT NULL, -- in / out
policy_name varchar(256),
retrieved_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (router_hash_id, peer_addr, afi, direction)
);
-- Per-neighbor RIB sizes pulled from the router: accepted_count is the
-- post-inbound-policy prefix count (BGP summary PfxRcd), advertised_count is
-- the adj-rib-out size toward that neighbor.
CREATE TABLE IF NOT EXISTS router_rib_stats (
router_hash_id uuid NOT NULL,
peer_addr inet NOT NULL,
afi varchar(8) NOT NULL,
peer_as bigint,
session_state varchar(32),
accepted_count integer,
advertised_count integer,
polled_at timestamptz NOT NULL DEFAULT now(),
PRIMARY KEY (router_hash_id, peer_addr, afi)
);
CREATE INDEX IF NOT EXISTS idx_route_policies_router ON route_policies (router_hash_id);
CREATE INDEX IF NOT EXISTS idx_neighbor_policy_bind_router ON neighbor_policy_bind (router_hash_id);
CREATE INDEX IF NOT EXISTS idx_router_rib_stats_router ON router_rib_stats (router_hash_id);