Bird
Raised Fist0
Microservicessystem_design~20 mins

Dashboards (Grafana) in Microservices - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Grafana Dashboard Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Grafana query?
Given a Prometheus query in Grafana:
sum(rate(http_requests_total[5m])) by (service)
What does this query show on the dashboard?
AThe current number of active HTTP connections per service.
BThe total count of HTTP requests for all services since the server started.
CThe error rate of HTTP requests per service over the last 5 minutes.
DThe total number of HTTP requests per service over the last 5 minutes, averaged per second.
Attempts:
2 left
💡 Hint
Think about what 'rate' and 'sum by' do in Prometheus queries.
Configuration
intermediate
2:00remaining
Which Grafana configuration snippet correctly sets up a Prometheus data source?
Select the correct YAML snippet to configure a Prometheus data source in Grafana's provisioning files.
A
apiVersion: 1
datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://prometheus:9090
    isDefault: true
B
apiVersion: 1
datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://prometheus:8080
    isDefault: true
C
apiVersion: 1
datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://localhost:8080
    isDefault: true
D
apiVersion: 1
datasources:
  - name: Prometheus
    type: prometheus
    access: direct
    url: https://prometheus:9090
    isDefault: false
Attempts:
2 left
💡 Hint
Check the apiVersion, URL port, and access mode for Prometheus defaults.
🔀 Workflow
advanced
2:00remaining
Order the steps to create a new Grafana dashboard for microservices metrics
Arrange these steps in the correct order to create a new Grafana dashboard displaying microservices metrics.
A1,2,3,4
B3,2,1,4
C1,3,2,4
D2,1,3,4
Attempts:
2 left
💡 Hint
Think about the natural flow from login to saving the dashboard.
Troubleshoot
advanced
2:00remaining
Why does this Grafana panel show 'No data' for a valid Prometheus query?
A Grafana panel with a Prometheus query returns 'No data' even though the query works in Prometheus UI. What is the most likely cause?
AThe Grafana user does not have permission to view the dashboard.
BThe query syntax is invalid in Grafana but valid in Prometheus UI.
CThe Prometheus data source URL in Grafana is incorrect or unreachable.
DThe panel refresh interval is set to a very high value.
Attempts:
2 left
💡 Hint
Check connectivity between Grafana and Prometheus.
Best Practice
expert
2:00remaining
Which practice improves Grafana dashboard performance for microservices monitoring?
Choose the best practice to optimize Grafana dashboards that monitor many microservices with high metric volume.
AIncrease dashboard refresh rate to update data every second.
BUse templating variables to filter services and reduce displayed data.
CAdd many panels with detailed queries for each microservice.
DDisable caching to always show the latest data.
Attempts:
2 left
💡 Hint
Think about reducing data load and improving usability.

Practice

(1/5)
1. What is the main purpose of a Grafana dashboard in microservices monitoring?
easy
A. To visually display system data for easy monitoring
B. To write code for microservices
C. To store microservice source files
D. To deploy microservices automatically

Solution

  1. Step 1: Understand Grafana's role

    Grafana is a tool used to create dashboards that show data visually.
  2. Step 2: Connect purpose to microservices

    Dashboards help monitor microservices by showing their data clearly.
  3. Final Answer:

    To visually display system data for easy monitoring -> Option A
  4. Quick Check:

    Grafana dashboards = Visual monitoring [OK]
Hint: Dashboards show data visually to monitor systems fast [OK]
Common Mistakes:
  • Confusing dashboards with code editors
  • Thinking dashboards deploy services
  • Assuming dashboards store source code
2. Which of the following is the correct way to add a new panel in a Grafana dashboard?
easy
A. Write a new SQL query in the dashboard settings
B. Click the '+' icon and select 'Add Panel'
C. Restart the Grafana server
D. Edit the microservice code

Solution

  1. Step 1: Identify how to add panels in Grafana

    Grafana uses a '+' icon to add new panels visually.
  2. Step 2: Eliminate unrelated actions

    Writing SQL or restarting server does not add panels directly.
  3. Final Answer:

    Click the '+' icon and select 'Add Panel' -> Option B
  4. Quick Check:

    Add panel = '+' icon click [OK]
Hint: Use '+' icon to add panels quickly [OK]
Common Mistakes:
  • Trying to add panels by restarting Grafana
  • Confusing panel addition with code editing
  • Assuming SQL query alone adds panels
3. Given this Grafana query panel configuration:
SELECT mean("response_time") FROM "service_metrics" WHERE $timeFilter GROUP BY time($__interval) fill(null)
What will this panel display?
medium
A. List of all service names
B. Total number of requests received
C. Current CPU usage of the server
D. Average response time over time intervals

Solution

  1. Step 1: Analyze the SQL query

    The query calculates the mean (average) of "response_time" from "service_metrics" grouped by time intervals.
  2. Step 2: Understand the output meaning

    This means the panel shows average response time over time, not counts or other metrics.
  3. Final Answer:

    Average response time over time intervals -> Option D
  4. Quick Check:

    mean(response_time) = average response time [OK]
Hint: mean() shows average values in Grafana queries [OK]
Common Mistakes:
  • Confusing mean with total count
  • Assuming query lists service names
  • Thinking it shows CPU usage
4. You created a Grafana dashboard but the panels show 'No data'. What is the most likely cause?
medium
A. The data source is not connected or misconfigured
B. The dashboard theme is set to dark mode
C. The Grafana server needs a restart
D. The microservice code has a syntax error

Solution

  1. Step 1: Identify common reasons for 'No data'

    Panels show 'No data' usually when the data source is missing or wrong.
  2. Step 2: Exclude unrelated causes

    Theme or server restart rarely cause no data; code errors don't affect Grafana data directly.
  3. Final Answer:

    The data source is not connected or misconfigured -> Option A
  4. Quick Check:

    No data = data source issue [OK]
Hint: Check data source connection first if no data appears [OK]
Common Mistakes:
  • Restarting server unnecessarily
  • Changing theme expecting data fix
  • Blaming microservice code syntax
5. You want to create a Grafana dashboard that shows error rates for multiple microservices over the last 24 hours. Which steps should you follow?
hard
A. Use Grafana to deploy microservices and monitor logs
B. Write microservice code to log errors, then restart Grafana server
C. Connect data source, create a dashboard, add panels with queries filtering errors by service and time
D. Install Grafana plugins, then export dashboard JSON without queries

Solution

  1. Step 1: Connect the correct data source

    Grafana needs a data source with microservice metrics to query error rates.
  2. Step 2: Create dashboard and add panels with queries

    Panels should query error counts filtered by service name and last 24 hours.
  3. Step 3: Customize time range and filters

    Set time filter to last 24 hours and group by service for clear visualization.
  4. Final Answer:

    Connect data source, create a dashboard, add panels with queries filtering errors by service and time -> Option C
  5. Quick Check:

    Data source + queries + filters = dashboard [OK]
Hint: Always start with data source, then build queries in panels [OK]
Common Mistakes:
  • Skipping data source connection
  • Trying to deploy microservices via Grafana
  • Exporting dashboards without queries