django-aetos


Namedjango-aetos JSON
Version 0.2.0 PyPI version JSON
download
home_page
SummaryExport Django monitoring metrics for prometheus.io
upload_time2023-12-17 16:04:40
maintainer
docs_urlNone
author
requires_python>=3.9
licenseCopyright (c) 2023 uberspace.de Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords exporter metrics prometheus
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Django Aetos
============

A Django app to expose metrics to be scraped by prometheus.io.

Usage
-----

First, install django-aetos:

.. code-block:: python

    pip install django-aetos

then, add the app to `settings.py`:

.. code-block:: python

    INSTALLED_APPS = [
        # ... other apps ...
        "django_aetos",
        # ... other apps ...
    ]

and send requests to `/metrics` to Aetos in your `urls.py`:

.. code-block:: python

    from django.urls import include

    urlpatterns = [
        path("", include("django_aetos.urls")),
        # ... your other patterns ...
    ]

Then, add your own metrics by listening for the `collect_metrics` signal.
Refer to [the django docs](https://docs.djangoproject.com/en/dev/topics/signals/)
on details how to do this.

Your signal handler can return multiple metrics, each represented as a dict
within a list of generator.

Your `src/app/signals.py`:

.. code-block:: python

    from django.dispatch import receiver

    from django_aetos.signals import collect_metrics


    @receiver(collect_metrics, dispatch_uid='metric_universes_count')
    def metric_universes_count(sender, **kwargs):
        yield {
            "name": "universes_count",
            "help": "Total number of universes",
            "type": "counter",
            "value": 1,
        }

You can do anything you like here, like make database queries or look at files
in the filesystem.

To make sure your receiver actually connects, add an import to your
`src/app/apps.py`:

.. code-block:: python

    from django.apps import AppConfig

    class YourAppConfig(AppConfig):
        name = "yourapp"

        def ready(self):
            from . import signals  # NOQA

Dev Setup
---------

.. code-block::

    python3 -m venv venv
    source venv/bin/activate
    make setup
    make install-dev

Testing
---------

.. code-block::

    make test

Packaging
---------

.. code-block::

    git pull
    make bump-version part=minor
    git push origin main v$(bump-my-version show current_version)

.. code-block::

    make build
    make upload-test

once the package looks good, run `make upload`.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "django-aetos",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "\"uberspace.de\" <hallo@uberspace.de>",
    "keywords": "exporter,metrics,prometheus",
    "author": "",
    "author_email": "\"uberspace.de\" <hallo@uberspace.de>",
    "download_url": "https://files.pythonhosted.org/packages/5e/26/071e8053f450dc68af2a1029d9b6604966f937b1724a79cd5021615120f2/django_aetos-0.2.0.tar.gz",
    "platform": null,
    "description": "Django Aetos\n============\n\nA Django app to expose metrics to be scraped by prometheus.io.\n\nUsage\n-----\n\nFirst, install django-aetos:\n\n.. code-block:: python\n\n    pip install django-aetos\n\nthen, add the app to `settings.py`:\n\n.. code-block:: python\n\n    INSTALLED_APPS = [\n        # ... other apps ...\n        \"django_aetos\",\n        # ... other apps ...\n    ]\n\nand send requests to `/metrics` to Aetos in your `urls.py`:\n\n.. code-block:: python\n\n    from django.urls import include\n\n    urlpatterns = [\n        path(\"\", include(\"django_aetos.urls\")),\n        # ... your other patterns ...\n    ]\n\nThen, add your own metrics by listening for the `collect_metrics` signal.\nRefer to [the django docs](https://docs.djangoproject.com/en/dev/topics/signals/)\non details how to do this.\n\nYour signal handler can return multiple metrics, each represented as a dict\nwithin a list of generator.\n\nYour `src/app/signals.py`:\n\n.. code-block:: python\n\n    from django.dispatch import receiver\n\n    from django_aetos.signals import collect_metrics\n\n\n    @receiver(collect_metrics, dispatch_uid='metric_universes_count')\n    def metric_universes_count(sender, **kwargs):\n        yield {\n            \"name\": \"universes_count\",\n            \"help\": \"Total number of universes\",\n            \"type\": \"counter\",\n            \"value\": 1,\n        }\n\nYou can do anything you like here, like make database queries or look at files\nin the filesystem.\n\nTo make sure your receiver actually connects, add an import to your\n`src/app/apps.py`:\n\n.. code-block:: python\n\n    from django.apps import AppConfig\n\n    class YourAppConfig(AppConfig):\n        name = \"yourapp\"\n\n        def ready(self):\n            from . import signals  # NOQA\n\nDev Setup\n---------\n\n.. code-block::\n\n    python3 -m venv venv\n    source venv/bin/activate\n    make setup\n    make install-dev\n\nTesting\n---------\n\n.. code-block::\n\n    make test\n\nPackaging\n---------\n\n.. code-block::\n\n    git pull\n    make bump-version part=minor\n    git push origin main v$(bump-my-version show current_version)\n\n.. code-block::\n\n    make build\n    make upload-test\n\nonce the package looks good, run `make upload`.\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2023 uberspace.de  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Export Django monitoring metrics for prometheus.io",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/uberspace/django-aetos",
        "Issues": "https://github.com/uberspace/django-aetos/issues"
    },
    "split_keywords": [
        "exporter",
        "metrics",
        "prometheus"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d7d90fd6c73138ab7510307d307a70ae53c161feabdee4b30c1014ae03a51d0",
                "md5": "cde1e88708514b1d96808080ee32afb8",
                "sha256": "c1cc978c192f551d58f5034511b8840d47269a12b88b6f18a50c37f48bec8067"
            },
            "downloads": -1,
            "filename": "django_aetos-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cde1e88708514b1d96808080ee32afb8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 5149,
            "upload_time": "2023-12-17T16:04:38",
            "upload_time_iso_8601": "2023-12-17T16:04:38.781944Z",
            "url": "https://files.pythonhosted.org/packages/9d/7d/90fd6c73138ab7510307d307a70ae53c161feabdee4b30c1014ae03a51d0/django_aetos-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5e26071e8053f450dc68af2a1029d9b6604966f937b1724a79cd5021615120f2",
                "md5": "3ab50e8060288ceacf57bc97e6620a5d",
                "sha256": "b20fed3fb9cb30882be03d4ff74a25822a8b80ed174bda086071aefa71ba115f"
            },
            "downloads": -1,
            "filename": "django_aetos-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3ab50e8060288ceacf57bc97e6620a5d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 9001,
            "upload_time": "2023-12-17T16:04:40",
            "upload_time_iso_8601": "2023-12-17T16:04:40.751139Z",
            "url": "https://files.pythonhosted.org/packages/5e/26/071e8053f450dc68af2a1029d9b6604966f937b1724a79cd5021615120f2/django_aetos-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-17 16:04:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "uberspace",
    "github_project": "django-aetos",
    "github_not_found": true,
    "lcname": "django-aetos"
}
        
Elapsed time: 0.15596s