0
0
Spring Bootframework~10 mins

Prometheus and Grafana integration concept in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add Prometheus metrics endpoint in Spring Boot.

Spring Boot
@Bean
public [1] prometheusMeterRegistry() {
    return new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
}
Drag options to blanks, or click blank then click option'
APrometheusMeterRegistry
BMeterRegistry
CMetricsEndpoint
DCollectorRegistry
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic MeterRegistry instead of PrometheusMeterRegistry
Confusing CollectorRegistry with MeterRegistry
2fill in blank
medium

Complete the configuration property to enable Prometheus endpoint in Spring Boot.

Spring Boot
management.endpoints.web.exposure.include=[1]
Drag options to blanks, or click blank then click option'
Ahealth
Bmetrics
Cprometheus
Dinfo
Attempts:
3 left
💡 Hint
Common Mistakes
Exposing only 'metrics' does not expose Prometheus endpoint
Using 'health' or 'info' which are unrelated endpoints
3fill in blank
hard

Fix the error in Prometheus scrape configuration for Spring Boot app in prometheus.yml.

Spring Boot
- job_name: 'springboot-app'
  static_configs:
    - targets: ['localhost:[1]']
Drag options to blanks, or click blank then click option'
A8080
B8081
C9091
D9090
Attempts:
3 left
💡 Hint
Common Mistakes
Using 8080 which is the main app port, not management port
Using 9090 which is default Prometheus server port
4fill in blank
hard

Fill both blanks to configure Grafana datasource for Prometheus.

Spring Boot
apiVersion: 1
datasources:
- name: Prometheus
  type: [1]
  url: http://localhost:[2]
Drag options to blanks, or click blank then click option'
Aprometheus
B9090
C8080
Dinfluxdb
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'influxdb' as datasource type for Prometheus
Using wrong port like 8080 for Prometheus server
5fill in blank
hard

Fill all three blanks to create a Prometheus query in Grafana to show HTTP request count by status code.

Spring Boot
sum(rate(http_server_requests_seconds_count[1][5m])) by ([2], [3])
Drag options to blanks, or click blank then click option'
A{job="springboot-app"}
Bstatus
Cmethod
Dinstance
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong label names like 'instance' instead of 'method'
Missing curly braces in filter expression