Skip to main content

Fetch software versions from your app for Prometheus.

Project description

Adds a Prometheus exporter to your web application to read out version information.

Installation

pip install versions-client

# This stores the OS packages upfront because it's very resource intensive
os-package-versions > /var/local/os-package-versions.yaml

Usage

>>> import versions_client
>>> versions_client.generate_versions(version='1.0', revision='d0935f4')

# HELP version_application version info.
# TYPE version_application gauge
version_application{version="1.0",revision="d0935f4"} 1
# HELP version_platform version info.
# TYPE version_platform gauge
version_platform{achitecture="64bit",name="linux",system="4.13.3-coreos",distro_version="8.9",distro_id="debian",distro_name="debian",type="x86_64"} 1
# HELP version_python version info.
# TYPE version_python gauge
version_python{date="2017-10-10 02:49:49",implementation="cpython",version="2.7.14",compiler="gcc 4.9.2"} 1
# HELP version_package version info.
# TYPE version_package gauge
version_package{version="4.9.2",group="os",name="libgcc1"} 1
version_package{version="4.9.2",group="os",name="libitm1"} 1
version_package{version="2.0.21",group="os",name="libevent-2.0-5"} 1
...
version_package{version="0.30.0",group="python",name="wheel"} 1
version_package{version="15.1.0",group="python",name="virtualenv"} 1
version_package{version="1.0.0",group="python",name="versions-client"} 1
version_package{version="36.5.0",group="python",name="setuptools"} 1
version_package{version="3.12",group="python",name="pyyaml"} 1
version_package{version="0.0.21",group="python",name="prometheus-client"} 1
version_package{version="9.0.1",group="python",name="pip"} 1
version_package{version="0.2.0",group="python",name="envparse"} 1
...

Settings

Environment variable

Description

VERSIONS_OS_PACKAGE_PATH

The path to the stored os packages file.

Usage with Django

  1. Add application labels to your django settings:

    INSTALLED_APPS = (
        # ...
        'versions_client',
        # ...
    )
    
    ...
    
    VERSIONS_AUTH = [('admin', 'secret')]
    VERSIONS_LABELS = {
        'version': 'v1.0',
        'revision': 'd0935f4',
    }
  2. a. Add the included URL’s:

    # urls.py
    
    from django.conf.urls import include, url
    
    
    urlpatterns = [
        url(r'^', include('versions_client.django.urls')),
    ]

    This creates an endpoint on /versionz.

    b. Or create your own URL’s and views:

    # urls.py
    
    from django.conf.urls import include, url
    
    from . import views
    
    
    urlpatterns = [
        url(r'^metrics$', views.metrics_view, name='prometheus-django-metrics'),
    ]

    To get more metrics, you could integrate django-prometheus.

    In this example we combine our metrics with those from prometheus-client.

    # views.py
    
    import prometheus_client
    from django.conf import settings
    from django.http.response import HttpResponse
    import versions_client
    
    
    @versions_client.django.auth.basic
    def metrics_view(request):
        application_labels = getattr(settings, 'VERSIONS_LABELS', {})
        metrics_page = prometheus_client.generate_latest()
        version_page = versions_client.generate_versions(**application_labels)
        return HttpResponse(
            metrics_page + version_page,
            content_type=prometheus_client.CONTENT_TYPE_LATEST)

Project details


Download files

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

Source Distribution

versions-client-0.5.tar.gz (5.2 kB view details)

Uploaded Source

File details

Details for the file versions-client-0.5.tar.gz.

File metadata

  • Download URL: versions-client-0.5.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.14

File hashes

Hashes for versions-client-0.5.tar.gz
Algorithm Hash digest
SHA256 c2974f7e6ecb653675c17149dc2779aa56fef6438be63cfdd55f60fc30337af2
MD5 c65abab215b6c0e07d7735752f075e8e
BLAKE2b-256 282742216c107b853fd8f50fb3d15f11ff3a663f93b2b1dfc0cd47472b4e6ffb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page