From ec33a33cbda91f53cab53cb88ecd98d7b286fed8 Mon Sep 17 00:00:00 2001 From: Tim Luimes Date: Tue, 1 Feb 2022 18:24:51 -0500 Subject: [PATCH] add metrics for admission review responses --- connaisseur/flask_application.py | 2 ++ docs/README.md | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/connaisseur/flask_application.py b/connaisseur/flask_application.py index 418cd3dcb..514ea6833 100644 --- a/connaisseur/flask_application.py +++ b/connaisseur/flask_application.py @@ -47,6 +47,8 @@ def handle_alert_config_error(err): @APP.route("/mutate", methods=["POST"]) +@metrics.counter('mutate_requests_total', 'Total number of mutate requests',labels={'allowed': lambda r: r.get_json(silent=True)['response']['allowed'], + 'status_code': lambda r: r.get_json(silent=True)['response']['status']['code']}) def mutate(): """ Handle the '/mutate' path and accept CREATE and UPDATE requests. diff --git a/docs/README.md b/docs/README.md index 9dc2d6436..56d3bec99 100644 --- a/docs/README.md +++ b/docs/README.md @@ -206,6 +206,14 @@ http_request_total{method="POST",status="200"} 9.0 http_request_created{method="POST",status="200"} 1.6436681947581613e+09 # HELP http_request_exceptions_total Total number of HTTP requests which resulted in an exception # TYPE http_request_exceptions_total counter +# HELP mutate_requests_total Total number of mutate requests +# TYPE mutate_requests_total counter +mutate_requests_total{allowed="False",status_code="403"} 4.0 +mutate_requests_total{allowed="True",status_code="202"} 5.0 +# HELP mutate_requests_created Total number of mutate requests +# TYPE mutate_requests_created gauge +mutate_requests_created{allowed="False",status_code="403"} 1.643760946491879e+09 +mutate_requests_created{allowed="True",status_code="202"} 1.6437609592007663e+09 ``` ## Compatibility