willsoto / nestjs-prometheus

NestJS module for Prometheus
Apache License 2.0
499 stars 28 forks source link

The response looks like json #2361

Closed 4sfor closed 4 days ago

4sfor commented 5 days ago

The response I get looks like json, however, the response headers are set to text/plain; charset=utf-8; version=0.0.4. Therefore, I get an error in Prometheus - expected equal, got ":" ("INVALID") while parsing: "{\"data\":". http://localhost:3000/api/metrics {"data":"# HELP process_cpu_user_seconds_total Total user CPU time spent in seconds.\n# TYPE process_cpu_user_seconds_total counter\nprocess_cpu_user_seconds_total 0.406\n\n# HELP process_cpu_system_seconds_total Total system CPU time spent in seconds.\n# TYPE process_cpu_system_seconds_total counter\nprocess_cpu_system_seconds_total 0.062\n\n# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.\n# TYPE process_cpu_seconds_total counter\nprocess_cpu_seconds_total 0.468\n\n# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.\n# TYPE process_start_time_seconds gauge\nprocess_start_time_seconds 1726489032\n\n# HELP process_resident_memory_bytes Resident memory size in bytes.\n# TYPE process_resident_memory_bytes gauge\nprocess_resident_memory_bytes 91602944\n\n# HELP nodejs_eventloop_lag_seconds Lag of event loop in seconds.\n# TYPE nodejs_eventloop_lag_seconds gauge\nnodejs_eventloop_lag_seconds 0\n\n# HELP nodejs_eventloop_lag_min_seconds The minimum recorded event loop delay.\n# TYPE nodejs_eventloop_lag_min_seconds gauge\nnodejs_eventloop_lag_min_seconds 0.00909312\n\n# HELP nodejs_eventloop_lag_max_seconds The maximum recorded event loop delay.\n# TYPE nodejs_eventloop_lag_max_seconds gauge\nnodejs_eventloop_lag_max_seconds 0.024494079\n\n

willsoto commented 5 days ago

I don't think that has anything to do with this library in particular. It's likely you have some global interceptor or something that wraps everything into JSON.

Either way, this isn't enough information for me to help you.

4sfor commented 4 days ago

Thanks for the reply. You were right.