Versions Client
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
Add application labels to your django settings:
INSTALLED_APPS = ( # ... 'versions_client', # ... ) ... VERSIONS_AUTH = [('admin', 'secret')] VERSIONS_LABELS = { 'version': 'v1.0', 'revision': 'd0935f4', }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)
Metadata
Release files for versions-client 0.5
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 |
|---|---|---|---|---|
| versions-client-0.5.tar.gz | 5.2 kB | Without provenance | Details for versions-client-0.5.tar.gz |
Release files / versions-client-0.5.tar.gz
| Download URL | versions-client-0.5.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c2974f7e6ecb653675c17149dc2779aa56fef6438be63cfdd55f60fc30337af2
|
|
BLAKE2b-256 checksum How to use checksums |
282742216c107b853fd8f50fb3d15f11ff3a663f93b2b1dfc0cd47472b4e6ffb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for versions-client 0.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.