kempnerpulse.reader.prometheus

Layer 1 (Read) — Prometheus backend (dcgm-exporter /metrics).

Scrapes a dcgm-exporter HTTP endpoint (or reads a saved exposition-format file) and emits one RawRecord per GPU, keyed by the metric names the exporter publishes. Source labels (gpu, UUID, modelName, …) ride along in the same fields mapping as string values; Layer 2 separates metric values from identity labels.

Entry points:
  • parse_prometheus_records — pure text -> RawRecord parser.

  • load_source — fetch the exposition text (HTTP URL or local file).

  • PrometheusBackend — a scrape-per-poll Backend implementation.

Functions

load_source(source[, timeout])

Return exposition-format text from an HTTP(S) URL or a local file path.

parse_prometheus_records(text, *[, ...])

Parse exposition text into RawRecord objects, one per labelled entity.

Classes

PrometheusBackend

Backend that scrapes the exporter once per poll interval.

kempnerpulse.reader.prometheus.load_source(source, timeout=5.0)[source]

Return exposition-format text from an HTTP(S) URL or a local file path.

Parameters:
Return type:

str

kempnerpulse.reader.prometheus.parse_prometheus_records(text, *, source_version='exporter', timestamp=None, wallclock=None)[source]

Parse exposition text into RawRecord objects, one per labelled entity.

A metric line’s entity key is its gpu label (falling back to UUID then device); lines without one are skipped. Bare (unlabelled) metric lines are grouped under the "global" entity. The entity’s labels are carried in fields as string values alongside the numeric metrics. All records share one timestamp/wallclock.

Parameters:
  • text (str)

  • source_version (str)

  • timestamp (float | None)

  • wallclock (float | None)

Return type:

List[RawRecord]

class kempnerpulse.reader.prometheus.PrometheusBackend[source]

Bases: object

Backend that scrapes the exporter once per poll interval.

Unlike the dcgmi backend there is no long-lived subprocess: each pass through stream performs one scrape and yields that scrape’s records, then sleeps poll_seconds before the next. dcgm-exporter refreshes profiling fields on its own (~30 s) scrape cycle, which sets the true ceiling on useful poll rates.

__init__()[source]
Return type:

None

open(config)[source]
Parameters:

config (ReaderConfig)

Return type:

None

stream()[source]
Return type:

Iterator[RawRecord]

close()[source]
Return type:

None

property caps: BackendCaps