trust-module-backend/src/metrics.controller.ts

30 lines
851 B
TypeScript

import { Controller, Get, Query } from '@nestjs/common';
import { PrometheusService } from './prometheus.service';
@Controller('metrics')
export class MetricsController {
constructor(private readonly prometheusService: PrometheusService) { }
@Get()
async getMetrics(
@Query('metric') metric: string,
@Query('start') start: number,
@Query('end') end: number,
@Query('step') step: number,
) {
if (start && end && step) {
return this.prometheusService.fetchMetricsRange(metric, start, end, step);
}
return this.prometheusService.fetchMetrics(metric);
}
@Get('/all')
async getAllMetrics() {
return this.prometheusService.fetchAllMetrics();
}
@Get('/all-values')
async getAllMetricsWithValues() {
return this.prometheusService.fetchAllMetricsWithValues();
}
}