I have a NestJs application that I have installed @willsoto/nestjs-prometheus
.
I have put it into my application in the app.module.ts
@Module({
imports: [
... Omitted ...
PrometheusModule.register({
path: '/metrics',
defaultMetrics: {
enabled: true,
}
}),
],
controllers: [MetricsController]
})
export class AppModule {}
The MetricsController exposes the metrics endpoint on port 80 (where the application is)
@Controller('metrics')
export class MetricsController {
@Public()
@Get()
async getMetrics(@Res() res: Response) {
res.set('Content-Type', register.contentType);
res.end(await register.metrics());
}
}
When I curl the endpoint for /metrics I get a long list of metrics starting with this
# HELP process_cpu_user_seconds_total Total user CPU time spent in seconds.
# TYPE process_cpu_user_seconds_total counter
process_cpu_user_seconds_total 18.527647
# HELP process_cpu_system_seconds_total Total system CPU time spent in seconds.
# TYPE process_cpu_system_seconds_total counter
process_cpu_system_seconds_total 5.060076
In my deployment for my service I have added the prometheus scraping
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: intakes-svc
svcCat: intakes-svc
name: intakes-svc
namespace: vista-center
spec:
replicas: 1
selector:
matchLabels:
app: intakes-svc
svcCat: intakes-svc
strategy:
type: Recreate
template:
metadata:
labels:
app: intakes-svc
svcCat: intakes-svc
annotations:
prometheus.io/scrape: 'true'
prometheus.io/path: '/metrics'
prometheus.io/port: '80'
spec:
containers:
- name: intakes-svc
image: intakes-svc
imagePullPolicy: IfNotPresent
In the Lens Metrics page of Lens settings for Docker Desktop I have enabled “Bundled Promethetheus metrics stack”, “Bundled kube-state-metrics stack” and “Bundled node-exporter stack”.
When I look at metrics in Lens for the pod in question I don’t see anything even though when I look at the prometheus pod I see CPU activity in the metrics graph.
In Prometheus dashboard when I examine the scrape targets I don’t see my microservice. Am I configuring this incorrectly?
Thanks in advance