back: add a /metrics.json endpoint

This commit is contained in:
Ludwig Behm 2022-02-02 23:47:36 +01:00
parent 456c2ffab5
commit 40c05a7905
1 changed files with 5 additions and 0 deletions

View File

@ -9,10 +9,15 @@ export class PrometheusController {
});
this.App.get("/metrics", this.metrics.bind(this));
this.App.get("/metrics.json", this.metricsAsJSON.bind(this));
}
private metrics(res: HttpResponse, req: HttpRequest): void {
res.writeHeader("Content-Type", register.contentType);
res.end(register.metrics());
}
private metricsAsJSON(res: HttpResponse, req: HttpRequest): void {
res.writeHeader('Content-Type', 'application/json');
res.end(JSON.stringify(register.getMetricsAsJSON()));
}
}