feat: metrics endpoint for frontend
This commit is contained in:
parent
3a1e822b63
commit
a86047ec79
1 changed files with 16 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ from sqlalchemy.sql import and_
|
||||||
|
|
||||||
from src.auth.service import authed_dependency
|
from src.auth.service import authed_dependency
|
||||||
from src.database import db_dependency
|
from src.database import db_dependency
|
||||||
|
from src.prometheus import prometheus
|
||||||
|
|
||||||
from src.misp.models import Domain
|
from src.misp.models import Domain
|
||||||
from src.misp.schemas import MispUpdatePutRequest, MispUpdatePutResponse
|
from src.misp.schemas import MispUpdatePutRequest, MispUpdatePutResponse
|
||||||
|
|
@ -20,6 +21,21 @@ router = APIRouter(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/dashboard_metrics", include_in_schema=False)
|
||||||
|
async def dashboard_metrics():
|
||||||
|
"""
|
||||||
|
Endpoint for UI status bar. JSONifies required Prometheus metrics.
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
"blocked_domain_count": prometheus.blocked_domain_count._value.get(),
|
||||||
|
"TIMER_STATE": prometheus.TIMER_STATE._value,
|
||||||
|
"MISP_STATE": prometheus.MISP_STATE._value,
|
||||||
|
"last_update_complete_time": prometheus.last_update_complete_time._value.get(),
|
||||||
|
"last_update_length": prometheus.last_update_length._value.get(),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@router.put("/manual_update", response_model=MispUpdatePutResponse)
|
@router.put("/manual_update", response_model=MispUpdatePutResponse)
|
||||||
async def manual_misp_update(request: Request, update_request: MispUpdatePutRequest, background_tasks: BackgroundTasks):
|
async def manual_misp_update(request: Request, update_request: MispUpdatePutRequest, background_tasks: BackgroundTasks):
|
||||||
published_time = update_request.published_timestamp
|
published_time = update_request.published_timestamp
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue