u
This commit is contained in:
@@ -65,7 +65,16 @@ export function register(app, basePath = '') {
|
||||
* get:
|
||||
* tags: [Health]
|
||||
* summary: Health latency history
|
||||
* description: Returns the database healthcheck latency (ms) as three series, each oldest first with unix-ms timestamps. `raw` holds the per-minute samples of the last 3 hours; `avg` and `max` hold the 30-minute aggregates (over the last 4 hours of samples) kept for 30 days. Requires a valid JWT; no company selection needed.
|
||||
* description: Returns the database healthcheck latency (ms), each series oldest first with unix-ms timestamps. By default (`range=3h`) only `raw` is returned, the per-minute samples of the last 3 hours. With `range=all` the 30-day `avg` and `max` series (30-minute aggregates over the last 4 hours of samples) are included as well. Requires a valid JWT; no company selection needed.
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: range
|
||||
* required: false
|
||||
* schema:
|
||||
* type: string
|
||||
* enum: [3h, all]
|
||||
* default: 3h
|
||||
* description: "`3h` (default) returns only the per-minute samples of the last 3 hours; `all` also includes the 30-day avg and max series."
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Latency series
|
||||
@@ -101,9 +110,13 @@ export function register(app, basePath = '') {
|
||||
*/
|
||||
// #region GET /health/latency
|
||||
|
||||
app.get(`${basePath}/health/latency`, async (_request, response) => {
|
||||
app.get(`${basePath}/health/latency`, async (request, response) => {
|
||||
try {
|
||||
response.json(await getLatencySeries());
|
||||
const { range = '3h' } = request.query;
|
||||
if (range !== '3h' && range !== 'all') {
|
||||
return response.status(400).json({ error: 'range must be 3h or all' });
|
||||
}
|
||||
response.json(await getLatencySeries({ range }));
|
||||
} catch (error) {
|
||||
console.error('GET /health/latency failed:', error);
|
||||
response.status(500).json({ error: error.message });
|
||||
|
||||
Reference in New Issue
Block a user