Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Stat, metric, and diagnostic publishing and consuming tools

Project description

`Documentation <>`_ |
`Package <>`_ |
`Code <>`_

.. image::


Mmstats is a way to expose and read diagnostic values and metrics for

Think of mmstats as /proc for your application and the readers as procps

This project is a Python implementation, but compatible implementations can be
made in any language (see Goals).

Discuss at


* Separate publishing/writing from consuming/reading tools
* Platform/language independent (a Java writer can be read by a Python tool)
* Predictable performance impact for writers via:

* No locks (1 writer per thread)
* No syscalls (after instantiation)
* All in userspace
* Reading has no impact on writers

* Optional persistent (writer can sync anytime)
* 1-way (Publish/consume only; mmstats are not management extensions)



CPython 2.6 or 2.7 (Windows is untested)

PyPy (only tested in 1.7, should be faster in 1.8)


1. ``easy_install mmstats`` or ``pip install mmstats`` or if you've downloaded
the source: ``python install``
2. Then in your Python project create a sublcass of mmstats.MmStats like

.. code-block:: python

import mmstats

class WebStats(mmstats.MmStats):
status2xx = mmstats.CounterField(label='status.2XX')
status3xx = mmstats.CounterField(label='status.3XX')
status4xx = mmstats.CounterField(label='status.4XX')
status5xx = mmstats.CounterField(label='status.5XX')
last_hit = mmstats.DoubleField(label='timers.last_hit')

3. Instantiate it once per process: (instances are automatically thread local)

.. code-block:: python

webstats = WebStats(label_prefix='web.stats.')

4. Record some data:

.. code-block:: python

if response.status_code == 200:

webstats.last_hit = time.time()

5. Run ``slurpstats`` to read it
6. Run ``mmash`` to create a web interface for stats
7. Run ``pollstats -p web.stats.status 2XX,3XX,4XX,5XX /tmp/mmstats-*`` for a
vmstat/dstat like view.
8. Did a process die unexpectedly and leave around a stale mmstat file?
``cleanstats /path/to/mmstat/files`` will check to see which files are stale
and remove them.

.. include:: CHANGES.rst
:end-before: 0.5.0

Project details

Download files

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

Files for mmstats, version 0.8.0
Filename, size File type Python version Upload date Hashes
Filename, size mmstats-0.8.0.tar.gz (104.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page