forked from s3lph/matemat
Merge branch 'staging'
This commit is contained in:
commit
300941b215
6 changed files with 40 additions and 3 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,5 +1,18 @@
|
||||||
# Matemat Changelog
|
# Matemat Changelog
|
||||||
|
|
||||||
|
<!-- BEGIN RELEASE v0.2.4 -->
|
||||||
|
## Version 0.2.4
|
||||||
|
|
||||||
|
Feature release
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
|
||||||
|
<!-- BEGIN CHANGES 0.2.4 -->
|
||||||
|
- Feature: Quick-and-dirty Prometheus metrics exporter
|
||||||
|
<!-- END CHANGES 0.2.4 -->
|
||||||
|
|
||||||
|
<!-- END RELEASE v0.2.4 -->
|
||||||
|
|
||||||
<!-- BEGIN RELEASE v0.2.3 -->
|
<!-- BEGIN RELEASE v0.2.3 -->
|
||||||
## Version 0.2.3
|
## Version 0.2.3
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
|
|
||||||
__version__ = '0.2.3'
|
__version__ = '0.2.4'
|
||||||
|
|
|
@ -11,6 +11,7 @@ from .touchkey import touchkey_page
|
||||||
from .buy import buy
|
from .buy import buy
|
||||||
from .deposit import deposit
|
from .deposit import deposit
|
||||||
from .admin import admin
|
from .admin import admin
|
||||||
|
from .metrics import metrics
|
||||||
from .moduser import moduser
|
from .moduser import moduser
|
||||||
from .modproduct import modproduct
|
from .modproduct import modproduct
|
||||||
from .userbootstrap import userbootstrap
|
from .userbootstrap import userbootstrap
|
||||||
|
|
23
matemat/webserver/pagelets/metrics.py
Normal file
23
matemat/webserver/pagelets/metrics.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
from bottle import abort, response, route
|
||||||
|
|
||||||
|
from matemat.db import MatematDatabase
|
||||||
|
from matemat.webserver.config import get_app_config
|
||||||
|
|
||||||
|
|
||||||
|
@route('/metrics')
|
||||||
|
def metrics():
|
||||||
|
config = get_app_config()
|
||||||
|
if config.get('MetricsEnabled', '0') != '1':
|
||||||
|
return abort(403,
|
||||||
|
'Prometheus metrics are disable in configuration. '
|
||||||
|
'If you believe this is an error, contact your administrator.')
|
||||||
|
with MatematDatabase(config['DatabaseFile']) as db:
|
||||||
|
products = db.list_products()
|
||||||
|
m = '''# TYPE matemat_beverage_supply_count gauge
|
||||||
|
# HELP matemat_beverage_supply_count Number of bottles available
|
||||||
|
'''
|
||||||
|
for product in products:
|
||||||
|
name = product.name.replace('"', '\\"')
|
||||||
|
m += f'matemat_beverage_supply_count{{product="{name}"}} {product.stock}\n'
|
||||||
|
response.headers['Content-Type'] = 'text/plain'
|
||||||
|
return m
|
|
@ -2,7 +2,7 @@
|
||||||
# Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
|
# Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
|
||||||
|
|
||||||
pkgname=matemat
|
pkgname=matemat
|
||||||
pkgver=0.2.3
|
pkgver=0.2.4
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
arch=('any')
|
arch=('any')
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Package: matemat
|
Package: matemat
|
||||||
Version: 0.2.3
|
Version: 0.2.4
|
||||||
Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
|
Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
|
||||||
Section: web
|
Section: web
|
||||||
Priority: optional
|
Priority: optional
|
||||||
|
|
Loading…
Reference in a new issue