Skip to main content

sgnmon

Monitoring and metrics for SGN streaming pipelines

ci coverage documentation pypi version


Observe SGN pipelines from the outside: collect Prometheus metrics (gap/non-gap content, latencies, throughput, end-of-stream state) from running pipelines, serve them over HTTP, and evaluate pipeline health checks suitable for container orchestration and monitoring plugins.

Resources

Installation

pip install sgnmon

Features

  • Non-invasive taps -- attach probes to any existing pipeline's pads without modifying the graph, at three observation points per element (frames produced, frames received, and post-audioadapter consumption) so latency can be attributed per element
  • Monitoring elements -- a pass-through MonitorTransform and terminal MonitorSink for explicit in-graph instrumentation
  • Prometheus metrics -- frame counts, gap/data seconds, sample throughput, latency histograms, per-pad execution time, freshness timestamps, EOS state, and opt-in process CPU/memory metrics
  • Custom metrics -- declare application metrics on your own elements (MetricSpec/MetricsMixin) or create families directly on the monitor; an EventLatency element measures per-event latency for event streams
  • Windowed statistics -- rates, gap fractions, and latencies aggregated natively over a 5s...6h trailing-window ladder, for sub-minute resolution and consumers without PromQL
  • Health checks -- a configuration-free default set (data freshness, throughput, latency drift) that self-paces its startup, plus opt-in absolute-latency, gap-fraction, and end-of-stream checks, aggregated into a JSON report
  • Built-in webserver -- /metrics, /health (HTTP 503 when unhealthy), /status, /graph, and live updates over server-sent events, served from a background thread
  • Live dashboard -- a self-contained web page drawing the pipeline graph with live per-element rates, latencies, gap fractions, and health state; composed elements expand in place to show their internal elements
  • CLI -- sgnmon run -- <app> ... attaches monitoring to any sgn application with zero code changes; sgnmon demo runs a monitored example pipeline; sgnmon check <url> queries a running pipeline's health with plugin-friendly exit codes

Quickstart

Monitor any sgn application, zero code changes

$ sgnmon run --port 9090 -- sgn-cal --config config.yaml --model model.npz
[sgnmon] dashboard: http://localhost:9090/

Tap an existing pipeline

from sgnmon import Monitor, MonitorServer

monitor = Monitor()
monitor.tap(pipeline)  # observe every pad, no graph changes

with MonitorServer(monitor, port=9090):
    pipeline.run()

Default health checks (data freshness, throughput, latency drift) are registered out of the box; tune or extend them with monitor.add_default_checks(...). Then point Prometheus at http://<host>:9090/metrics, or check health by hand:

$ sgnmon check http://localhost:9090

Instrument with elements

from sgnmon import Monitor, MonitorTransform

monitor = Monitor()
mon = MonitorTransform(name="mon", sink_pad_names=["H1"], monitor=monitor)
pipeline.insert(src, mon, snk)
pipeline.link({
    "mon:snk:H1": "src:src:H1",
    "snk:snk:H1": "mon:src:H1",
})

Try the demo

$ sgnmon demo --port 9090
dashboard: http://localhost:9090/
metrics:  http://localhost:9090/metrics
health:   http://localhost:9090/health
status:   http://localhost:9090/status

Open the dashboard in a browser to watch the pipeline graph update live.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sgnmon-0.1.1.tar.gz (99.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sgnmon-0.1.1-py3-none-any.whl (81.6 kB view details)

Uploaded Python 3

File details

Details for the file sgnmon-0.1.1.tar.gz.

File metadata

  • Download URL: sgnmon-0.1.1.tar.gz
  • Upload date:
  • Size: 99.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.13.12 HTTPX/0.28.1

File hashes

Hashes for sgnmon-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d1fa04c9e2561ded34f05d78711984c5378870bb152f42e73ffff61f20c3866d
MD5 7d9379b3b7e01ddb572fa30d987bb529
BLAKE2b-256 6f80485faaf678246e907fa682631265c0a0516b3e0bb5d40d5054204292657b

See more details on using hashes here.

File details

Details for the file sgnmon-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sgnmon-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 81.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.13.12 HTTPX/0.28.1

File hashes

Hashes for sgnmon-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 534edb3fd244270fbfd00721a828c5e64dbd66f54e3f70382c7313c9dc421abb
MD5 59c60d258dc326c34ba988cd65480cf6
BLAKE2b-256 3a9770465f36943a4785b1d696370f90857d8c93668f7bd444a39a01d61f0053

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page