Complete the code to add Prometheus metrics endpoint in Spring Boot.
@Bean public [1] prometheusMeterRegistry() { return new PrometheusMeterRegistry(PrometheusConfig.DEFAULT); }
The PrometheusMeterRegistry bean exposes metrics in Prometheus format for scraping.
Complete the configuration property to enable Prometheus endpoint in Spring Boot.
management.endpoints.web.exposure.include=[1]Setting management.endpoints.web.exposure.include=prometheus exposes the Prometheus metrics endpoint.
Fix the error in Prometheus scrape configuration for Spring Boot app in prometheus.yml.
- job_name: 'springboot-app' static_configs: - targets: ['localhost:[1]']
Spring Boot actuator Prometheus endpoint usually runs on port 8081 when management.server.port is set differently.
Fill both blanks to configure Grafana datasource for Prometheus.
apiVersion: 1 datasources: - name: Prometheus type: [1] url: http://localhost:[2]
Grafana datasource type for Prometheus is 'prometheus' and default Prometheus server port is 9090.
Fill all three blanks to create a Prometheus query in Grafana to show HTTP request count by status code.
sum(rate(http_server_requests_seconds_count[1][5m])) by ([2], [3])
The query filters by job label and groups results by HTTP status and method.