croft for Python
The collector's signals as pandas frames, for notebooks and analysis.
pip install "croft-signals[plot]"
uv add "croft-signals[plot]"
uv add --editable ../python # from a project inside this repository
1. Sources
| Source | Function | History | Pods |
|---|---|---|---|
| Prometheus | metrics.signal() and one function per signal |
as long as Prometheus keeps it | joined through kube-state-metrics |
collector /metrics |
metrics.live() |
the newest poll | container_id |
| dataset files | dataset.signal() and one function per signal; dataset.read() for raw rows |
as long as the node keeps it | container_id, or names from kube.names() |
CROFT_PROMETHEUS sets the Prometheus URL (PROM_HOST is read as a fallback),
CROFT_METRICS_ADDR the collector address and CROFT_DATASET the dataset directory.
2. Signals
| Signal | Metric | Unit |
|---|---|---|
syscall_rate |
croft_container_syscall_rate |
calls/s, per syscall |
syscall_bytes |
croft_container_syscall_bytes_total |
bytes/s, per syscall |
socket_io |
croft_container_socket_io_total |
calls/s, per direction |
connects |
croft_container_connects_total |
connects/s, per address and port |
cpu_cores |
croft_container_cpu_cores |
cores |
cpu_throttled_fraction |
croft_container_cpu_throttled_fraction |
fraction |
cpu_pressure |
croft_container_cpu_pressure_avg10 |
% |
runqueue_wait |
croft_container_runqueue_wait |
s/s |
inflight_requests |
croft_container_inflight_requests |
requests |
Counters come as rates over 15 s or the step, whichever is longer; gauges are averaged over each step longer than
5 s. metrics.catalog() returns this table. The dataset holds syscall_rate, runqueue_wait and the three CPU
signals; the other three are on /metrics and Prometheus.
3. Usage
from croft import metrics, plot
frame = metrics.syscall_rate("boutique", "frontend", since="1h", match={"syscall": "getpeername"})
plot.lines(frame, by="pod")
metrics.runqueue_wait("hotel-res", since="2026-11-18 09:00", until="2026-11-18 10:00")
metrics.wide(frame, by="deployment") # one column per deployment
metrics.query("sum(rate(container_cpu_usage_seconds_total[1m]))", since="30m")
metrics.live("127.0.0.1:9464") # newest poll of one collector
Without Prometheus, the same frames come from the dataset files, with node and container_id added:
from croft import dataset, kube
names = kube.names() # container_id to namespace, pod and container, through kubectl
frame = dataset.syscall_rate("boutique", "frontend", since="1h", names=names, match={"syscall": "getpeername"})
A summed signal (syscall_rate, runqueue_wait) is the container's total per poll, averaged over the polls of
each step; a poll without a row for the container counts as 0, since idle processes are written every 15 polls.
A CPU signal is averaged over the polls that hold it. kube.names() knows the pods the API server holds, so
containers of deleted pods keep their container_id only.
Each row holds time (UTC), namespace, deployment, pod, container, the
signal's own labels and value. deployment comes from the pod name and is empty
for pods outside a Deployment. since and until take a duration before now
("90m"), a date or a unix time; the step keeps a range under 1000 samples.
4. Tests
uv run python -m unittest discover -s tests
Metadata
Release files for croft-signals 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| croft_signals-0.4.0.tar.gz | 11.5 kB | With provenance | Details for croft_signals-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| croft_signals-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for croft_signals-0.4.0-py3-none-any.whl |
Total release size: 24.9 kB
Release files / croft_signals-0.4.0.tar.gz
| Download URL | croft_signals-0.4.0.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b62b416bbfe452145d0f17580c1e51719e5625c9591160e5f5ef46a68400a500
|
|
BLAKE2b-256 checksum How to use checksums |
256f508a2cf42965411247e88334131eded067675077aaee4bbc35201fff7489
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / croft_signals-0.4.0-py3-none-any.whl
| Download URL | croft_signals-0.4.0-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8b490917a1d1981fe2ad709dcbc3a85851d5d902c8a014a13bbb2d7659ed910
|
|
BLAKE2b-256 checksum How to use checksums |
dd040672f9882a063ce3e537c0ba26a2ee697621ab9065a4793f6c3fd02754e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logSecurity for croft-signals 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for croft_signals-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.