This commit is contained in:
Ruslan Piatrovich
2024-12-13 14:22:21 +03:00
parent be33aa549e
commit f815f629ec
871 changed files with 193 additions and 138036 deletions
+17
View File
@@ -0,0 +1,17 @@
# Используем официальный образ Python
FROM python:3.9-slim
# Устанавливаем рабочую директорию
WORKDIR /app
# Копируем файлы приложения
COPY app.py requirements.txt /app/
# Устанавливаем зависимости
RUN pip install --no-cache-dir -r requirements.txt
# Открываем порт для приложения
EXPOSE 5000
# Запускаем приложение
CMD ["python", "app.py"]
+19
View File
@@ -0,0 +1,19 @@
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)
+2
View File
@@ -0,0 +1,2 @@
Flask
prometheus-client