init
This commit is contained in:
@@ -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"]
|
||||
@@ -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)
|
||||
@@ -0,0 +1,2 @@
|
||||
Flask
|
||||
prometheus-client
|
||||
Reference in New Issue
Block a user