From e19577bd23277d2ef2f8c6c9396f9c1c75714c41 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Fri, 26 Apr 2024 11:58:39 -0700 Subject: [PATCH] (WIP) add prometheus metrics --- gnocpush/gateway.py | 3 +++ pyproject.toml | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gnocpush/gateway.py b/gnocpush/gateway.py index f162fbc..1ac90c1 100644 --- a/gnocpush/gateway.py +++ b/gnocpush/gateway.py @@ -7,12 +7,14 @@ from flask import Flask, request from gnocpush import Pusher +from prometheus_flask_exporter import PrometheusMetrics # from flask_httpauth import HTTPBasicAuth # from werkzeug.security import generate_password_hash, check_password_hash app = Flask(__name__) app.config['MAX_CONTENT_LENGTH'] = 4 * 1024 * 1024 # 4 MB +metrics = PrometheusMetrics(app) # alertmanager webhook_config does not support http digest auth # auth = HTTPBasicAuth() @@ -42,6 +44,7 @@ def push_endpoint(): @app.route('/healthz', methods=['GET']) +@metrics.do_not_track() def healthz(): return {'status': 'ok'} diff --git a/pyproject.toml b/pyproject.toml index cc5e128..46ea450 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,12 +2,13 @@ name = "gnocpush" version = "0.1.0" dependencies = [ + "flake8-pyproject", + "flask", + "flask-httpauth", "globalnoc_alertmon_agent", + "prometheus-flask-exporter==0.23.0", "python-dateutil", "requests", - "flask", - "flask-httpauth", - "flake8-pyproject", ] [build-system]