0
0
Microservicessystem_design~20 mins

Metrics collection (Prometheus) in Microservices - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Prometheus Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Prometheus Query Output for HTTP Request Count
Given a Prometheus metric http_requests_total that counts all HTTP requests, what is the output of this query?

sum(rate(http_requests_total[5m]))

Assume the metric increments by 10 requests every minute consistently.
Microservices
sum(rate(http_requests_total[5m]))
A0.3333333
B2
C0.1666667
D10
Attempts:
2 left
💡 Hint
Think about how rate calculates per second over the 5-minute window.
Configuration
intermediate
2:00remaining
Prometheus Scrape Configuration for Multiple Targets
Which Prometheus scrape configuration correctly scrapes metrics from two microservices running on ports 8080 and 9090 on the same host?
A
scrape_configs:
  - job_name: 'microservices'
    static_configs:
      - targets: ['localhost:8080 localhost:9090']
B
scrape_configs:
  - job_name: 'microservices'
    static_configs:
      - targets: ['localhost:8080']
      - targets: ['localhost:9090']
C
scrape_configs:
  - job_name: 'microservices'
    static_configs:
      - targets: ['localhost:8080', 'localhost:9090']
D
scrape_configs:
  - job_name: 'microservices'
    static_configs:
      - targets: ['localhost:8080;localhost:9090']
Attempts:
2 left
💡 Hint
Targets should be a list of strings, each string is host:port.
Troubleshoot
advanced
2:00remaining
Diagnosing Missing Metrics in Prometheus
You configured Prometheus to scrape a microservice, but no metrics appear for it in the Prometheus UI. Which of the following is the most likely cause?
APrometheus is scraping metrics but the query used in UI is incorrect.
BPrometheus server is running but the disk is full.
CThe microservice is exposing metrics but Prometheus scrape interval is set to 1 hour.
DThe microservice is not exposing metrics on the configured endpoint.
Attempts:
2 left
💡 Hint
Check if the microservice endpoint for metrics is reachable and returns data.
🔀 Workflow
advanced
2:00remaining
Prometheus Alerting Workflow
Which sequence correctly describes the workflow for alerting when a microservice's error rate exceeds a threshold using Prometheus and Alertmanager?
A2,1,3,4
B1,2,3,4
C1,3,2,4
D3,1,2,4
Attempts:
2 left
💡 Hint
Think about the order from data collection to notification.
Best Practice
expert
2:00remaining
Optimizing Prometheus Metrics for High-Cardinality Labels
Which approach is best to reduce performance issues caused by high-cardinality labels in Prometheus metrics?
ARemove or limit labels that have many unique values, such as user IDs or session tokens.
BIncrease Prometheus scrape interval to reduce data points collected.
CStore all raw metrics in long-term storage without aggregation.
DAdd more labels to better identify each metric uniquely.
Attempts:
2 left
💡 Hint
High-cardinality labels create many time series, which can slow down Prometheus.