from flask import Flask, Response from prometheus_client import Counter, generate_latest app = Flask(__name__) # Создаем счётчик запросов к корневому эндпоинту REQUEST_COUNT = Counter('app_requests_total', 'Total app HTTP requests', ['method', 'endpoint']) @app.route('/') def hello_world(): REQUEST_COUNT.labels(method='GET', endpoint='/').inc() return 'Hello, World!' @app.route('/metrics') def metrics(): return Response(generate_latest(), mimetype='text/plain') if __name__ == '__main__': app.run(host='0.0.0.0', port=5000)