mirror of
https://github.com/nikdoof/simple-webfinger.git
synced 2025-12-13 10:22:15 +00:00
Add Prometheus metrics
This commit is contained in:
2
Makefile
2
Makefile
@@ -14,4 +14,4 @@ serve-uwsgi:
|
|||||||
SIMPLE_WEBFINGER_CONFIG_FILE="examples/example-config.yaml" python3 -m poetry run uwsgi -w "simple_webfinger.app:create_app()" --master --http 0.0.0.0:8000
|
SIMPLE_WEBFINGER_CONFIG_FILE="examples/example-config.yaml" python3 -m poetry run uwsgi -w "simple_webfinger.app:create_app()" --master --http 0.0.0.0:8000
|
||||||
|
|
||||||
serve:
|
serve:
|
||||||
SIMPLE_WEBFINGER_CONFIG_FILE="examples/example-config.yaml" FLASK_DEBUG=1 FLASK_APP="simple_webfinger.app:create_app()" python3 -m poetry run flask run
|
DEBUG_METRICS=1 SIMPLE_WEBFINGER_CONFIG_FILE="examples/example-config.yaml" FLASK_DEBUG=1 FLASK_APP="simple_webfinger.app:create_app()" python3 -m poetry run flask run
|
||||||
|
|||||||
31
poetry.lock
generated
31
poetry.lock
generated
@@ -203,6 +203,35 @@ files = [
|
|||||||
dev = ["pre-commit", "tox"]
|
dev = ["pre-commit", "tox"]
|
||||||
testing = ["pytest", "pytest-benchmark"]
|
testing = ["pytest", "pytest-benchmark"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "prometheus-client"
|
||||||
|
version = "0.20.0"
|
||||||
|
description = "Python client for the Prometheus monitoring system."
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.8"
|
||||||
|
files = [
|
||||||
|
{file = "prometheus_client-0.20.0-py3-none-any.whl", hash = "sha256:cde524a85bce83ca359cc837f28b8c0db5cac7aa653a588fd7e84ba061c329e7"},
|
||||||
|
{file = "prometheus_client-0.20.0.tar.gz", hash = "sha256:287629d00b147a32dcb2be0b9df905da599b2d82f80377083ec8463309a4bb89"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
twisted = ["twisted"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "prometheus-flask-exporter"
|
||||||
|
version = "0.23.1"
|
||||||
|
description = "Prometheus metrics exporter for Flask"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
files = [
|
||||||
|
{file = "prometheus_flask_exporter-0.23.1-py3-none-any.whl", hash = "sha256:ab49b2c40b57cd35cd51e91e59b3c306b3754477095c4f3cf679034c5122398c"},
|
||||||
|
{file = "prometheus_flask_exporter-0.23.1.tar.gz", hash = "sha256:587c770a1061e93d72c5cbcdefbd7b633fb764e39dffd7dd16932c9124559244"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
flask = "*"
|
||||||
|
prometheus-client = "*"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pydantic"
|
name = "pydantic"
|
||||||
version = "2.8.2"
|
version = "2.8.2"
|
||||||
@@ -526,4 +555,4 @@ watchdog = ["watchdog (>=2.3)"]
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.0"
|
lock-version = "2.0"
|
||||||
python-versions = "^3.11"
|
python-versions = "^3.11"
|
||||||
content-hash = "b042304154f4d2a7ccbe9fffcebc6db3c38549d73e080d317b7d039c33a28fa3"
|
content-hash = "b221de707ffd32f063004ac38e899c2065608fbd7717d0e8885e42fb554e4b14"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ Flask = "^3.0.3"
|
|||||||
PyYAML = "^6.0.2"
|
PyYAML = "^6.0.2"
|
||||||
uwsgi = "^2.0.26"
|
uwsgi = "^2.0.26"
|
||||||
pydantic = "^2.8.2"
|
pydantic = "^2.8.2"
|
||||||
|
prometheus-flask-exporter = "^0.23.1"
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
pytest = "^8.0.0"
|
pytest = "^8.0.0"
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ from urllib.parse import urlparse
|
|||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from flask import Flask, abort, request
|
from flask import Flask, abort, request
|
||||||
|
from prometheus_flask_exporter import PrometheusMetrics
|
||||||
|
|
||||||
from simple_webfinger.models.webfinger import JSONResourceDefinition
|
from simple_webfinger.models.webfinger import JSONResourceDefinition
|
||||||
|
|
||||||
|
|
||||||
@@ -62,6 +64,10 @@ def filter_links(links: dict[str, str], rel: list[str]) -> list:
|
|||||||
|
|
||||||
def create_app(config={}):
|
def create_app(config={}):
|
||||||
app = Flask("simple_webfinger")
|
app = Flask("simple_webfinger")
|
||||||
|
|
||||||
|
metrics = PrometheusMetrics(app)
|
||||||
|
metrics.info('app_info', 'Application info', version='0.1.0')
|
||||||
|
|
||||||
app.webfinger_config = {
|
app.webfinger_config = {
|
||||||
"domain": None,
|
"domain": None,
|
||||||
"accounts": {},
|
"accounts": {},
|
||||||
|
|||||||
Reference in New Issue
Block a user