expose metrics on port 9000
This commit is contained in:
parent
9e092edfe6
commit
cd072d9e1b
1 changed files with 3 additions and 2 deletions
|
|
@ -7,7 +7,6 @@ from typing import Any, AsyncIterator, Dict, List, Optional, Protocol, Tuple, ca
|
||||||
|
|
||||||
import json_logging
|
import json_logging
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from prometheus_fastapi_instrumentator import Instrumentator
|
|
||||||
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
from fastapi import Depends, FastAPI, HTTPException, Request, status
|
||||||
from fastapi.security import (
|
from fastapi.security import (
|
||||||
HTTPAuthorizationCredentials,
|
HTTPAuthorizationCredentials,
|
||||||
|
|
@ -15,6 +14,8 @@ from fastapi.security import (
|
||||||
HTTPBasicCredentials,
|
HTTPBasicCredentials,
|
||||||
HTTPBearer,
|
HTTPBearer,
|
||||||
)
|
)
|
||||||
|
from prometheus_client import start_http_server
|
||||||
|
from prometheus_fastapi_instrumentator import Instrumentator
|
||||||
|
|
||||||
from ops_bot import alertmanager, aws, pagerduty
|
from ops_bot import alertmanager, aws, pagerduty
|
||||||
from ops_bot.config import BotSettings, RoutingKey, load_config
|
from ops_bot.config import BotSettings, RoutingKey, load_config
|
||||||
|
|
@ -35,7 +36,6 @@ async def matrix_main(matrix_client: MatrixClient) -> None:
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
|
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
|
||||||
instrumentator.expose(app)
|
|
||||||
config_fname = os.environ.get("BOT_CONFIG_FILE", "config.yaml")
|
config_fname = os.environ.get("BOT_CONFIG_FILE", "config.yaml")
|
||||||
bot_settings = load_config(config_fname)
|
bot_settings = load_config(config_fname)
|
||||||
c = MatrixClient(settings=bot_settings.matrix, join_rooms=bot_settings.get_rooms())
|
c = MatrixClient(settings=bot_settings.matrix, join_rooms=bot_settings.get_rooms())
|
||||||
|
|
@ -46,6 +46,7 @@ async def lifespan(app: FastAPI) -> AsyncIterator[None]:
|
||||||
await app.state.matrix_client.shutdown()
|
await app.state.matrix_client.shutdown()
|
||||||
|
|
||||||
|
|
||||||
|
start_http_server(9000)
|
||||||
app = FastAPI(lifespan=lifespan)
|
app = FastAPI(lifespan=lifespan)
|
||||||
instrumentator = Instrumentator().instrument(app)
|
instrumentator = Instrumentator().instrument(app)
|
||||||
bearer_security = HTTPBearer(auto_error=False)
|
bearer_security = HTTPBearer(auto_error=False)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue