Skip to main content

pymongoftdc

CI PyPI Python 3.10+ License: MIT

pymongoftdc reads numeric time-series metrics directly from MongoDB Full-Time Diagnostic Data Capture (FTDC) archive files.

Install

python -m pip install -e .

For development:

python -m pip install -e '.[test]'
pytest

Use

from datetime import datetime, timezone
from pyftdc import FTDCReader

reader = FTDCReader("/var/lib/mongo/diagnostic.data")
metrics = reader.get_metric(
    {"serverStatus.connections.current"},
    start=datetime(2026, 1, 1, tzinfo=timezone.utc),
    end=datetime(2026, 1, 1, 1, tzinfo=timezone.utc),
    sample_rate=0.1,
    sort_by_timestamp=False,
    workers=None,
)
points = metrics["serverStatus.connections.current"]

The source may be one metrics.* file or a directory that contains multiple metrics files.

  • Timespan endpoints are inclusive and must be timezone-aware. Omit start or end to use the earliest or latest timestamp in the source.
  • The result maps each requested name to points in source traversal order. Pass sort_by_timestamp=True to force order each point list by UTC timestamp (Usually unnecessary).
  • Pass an empty set to read every metric.
  • sample_rate must be greater than 0 and at most 1. For example, 0.1 returns approximately 10% of points. Its default is 1.0.
  • Metric chunks are decoded in separate processes. By default, workers is the detected CPU count minus one, with a minimum of one. Set workers=1 to disable multiprocessing or choose a smaller value to limit memory use.
  • query() is an alias for get_metric().
  • Use reader.get_metadata() to return the complete metadata payload from the first source file. Dedicated metadata accessors are:
    • get_mongodb_config() for the parsed getCmdLineOpts configuration
    • get_build_info() for MongoDB version and build details
    • get_host_info() for operating-system and hardware details
    • get_ulimits() for process resource limits
    • get_sys_max_open_files() for the system-wide open-file limit
    • get_metadata_start() and get_metadata_end() for collection timestamps
  • Use reader.list_metrics() to discover dotted metric paths from the first metric chunk. Pass all_chunks=True to scan the full source for schema changes.
  • A missing requested metric raises MetricNotFoundError; an invalid archive raises FTDCDecodeError.

Project layout

src/pyftdc/
  _codec.py       BSON framing and FTDC decompression
  reader.py       public query API
  models.py       returned value objects
  exceptions.py   library-specific errors
tests/             pytest tests and fixture builders

The reader supports BSON-framed type-1 metric chunks using MongoDB's delta/RLE/varint/zlib encoding. Metadata documents are safely skipped.

Metadata

Release files for pymongoftdc 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymongoftdc 0.1.2
File Size Uploaded Provenance Actions
pymongoftdc-0.1.2.tar.gz 17.9 kB With provenance Details for pymongoftdc-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pymongoftdc 0.1.2
File Interpreter ABI Platform Actions
pymongoftdc-0.1.2-py3-none-any.whl Python 3 none any Details for pymongoftdc-0.1.2-py3-none-any.whl

Total release size: 31.0 kB

Release files / pymongoftdc-0.1.2.tar.gz

Download URL pymongoftdc-0.1.2.tar.gz
Size 17.9 kB
Tags Source
SHA-256 checksum
How to use checksums
babfcdcf302de7cb95f8a6ce38278724afc34fd24a3cb6177e7ccef72e893df9
BLAKE2b-256 checksum
How to use checksums
7fe5c5be878806eb2d8705821c2cde3aabab28494637925e91e4287f5a1eb697
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 5, 2026.

Transparency log

Release files / pymongoftdc-0.1.2-py3-none-any.whl

Download URL pymongoftdc-0.1.2-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
76b2d92ab5a9187322600e4c4ea5c48fb515d55316b5ab578073441aff1103e0
BLAKE2b-256 checksum
How to use checksums
ed1e0522e1976b7d5d860c02a73f485703c67507a113b58a4289b1e8168cdd34
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 5, 2026.

Transparency log

Security for pymongoftdc 0.1.2

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.

Select from 2 files

Attestation for pymongoftdc-0.1.2.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 5, 2026.

Transparency log

A 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.

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