Bird
Raised Fist0
Kubernetesdevops~20 mins

Grafana for visualization in Kubernetes - 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 Visualization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Grafana Pod Status Check
You deployed Grafana on Kubernetes using a Helm chart. What is the output of the command kubectl get pods -l app.kubernetes.io/name=grafana if the pod is running correctly?
Kubernetes
kubectl get pods -l app.kubernetes.io/name=grafana
A
NAME                       READY   STATUS    RESTARTS   AGE
grafana-5d7f9c9d7f-abc12   1/1     CrashLoopBackOff   3          5m
B
NAME                       READY   STATUS    RESTARTS   AGE
grafana-5d7f9c9d7f-abc12   0/1     Pending   0          5m
CError from server (NotFound): pods not found
D
NAME                       READY   STATUS    RESTARTS   AGE
grafana-5d7f9c9d7f-abc12   1/1     Running   0          5m
Attempts:
2 left
💡 Hint
Look for the pod with label app.kubernetes.io/name=grafana and check its STATUS column.
Configuration
intermediate
2:00remaining
Configuring Grafana Data Source
Which YAML snippet correctly configures a Prometheus data source for Grafana in a Kubernetes ConfigMap?
A
apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-datasource
  namespace: monitoring
data:
  prometheus.yaml: |
    apiVersion: 2
    datasources:
    - name: Prometheus
      type: prometheus
      url: http://prometheus-server.monitoring.svc.cluster.local
      access: proxy
      isDefault: true
B
apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-datasource
  namespace: monitoring
data:
  prometheus.yaml: |
    apiVersion: 1
    datasources:
    - name: Prometheus
      type: prometheus
      url: https://prometheus-server.monitoring.svc.cluster.local
      access: direct
      isDefault: false
C
apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-datasource
  namespace: monitoring
data:
  prometheus.yaml: |
    apiVersion: 1
    datasources:
    - name: Prometheus
      type: prometheus
      url: http://prometheus-server.monitoring.svc.cluster.local
      access: proxy
      isDefault: true
D
apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-datasource
  namespace: monitoring
data:
  prometheus.yaml: |
    apiVersion: 1
    datasources:
    - name: Prometheus
      type: prometheus
      url: http://prometheus-server.monitoring.svc.cluster.local
      access: proxy
      isDefault: false
Attempts:
2 left
💡 Hint
Check the apiVersion, URL scheme, access mode, and default flag for Grafana data sources.
🔀 Workflow
advanced
2:30remaining
Steps to Enable Persistent Storage for Grafana
What is the correct order of steps to enable persistent storage for Grafana in Kubernetes using a PersistentVolumeClaim (PVC)?
A3,4,1,2
B1,3,4,2
C1,4,3,2
D3,1,4,2
Attempts:
2 left
💡 Hint
Think about defining storage first, then requesting it, applying configs, and finally using it in deployment.
Troubleshoot
advanced
2:00remaining
Grafana Dashboard Not Loading
You installed Grafana on Kubernetes, but the dashboard page shows a 503 Service Unavailable error. Which is the most likely cause?
AThe Grafana service is exposed as ClusterIP but you are accessing it externally without port forwarding.
BThe Grafana pod is in CrashLoopBackOff state due to misconfiguration.
CThe Prometheus data source URL is set to HTTP instead of HTTPS.
DThe PersistentVolumeClaim is bound but has insufficient storage capacity.
Attempts:
2 left
💡 Hint
Consider how you access Grafana service and its exposure type in Kubernetes.
Best Practice
expert
3:00remaining
Securing Grafana Access in Kubernetes
Which approach is the best practice to secure Grafana access in a Kubernetes cluster?
AUse an Ingress controller with TLS termination and enable Grafana authentication with OAuth or LDAP.
BExpose Grafana service as NodePort and rely on Kubernetes network policies for security.
CSet Grafana admin password to a simple value and restrict access by IP whitelist in Grafana settings.
DDisable authentication in Grafana and restrict access by limiting service exposure to ClusterIP only.
Attempts:
2 left
💡 Hint
Think about encryption, authentication, and controlled external access.

Practice

(1/5)
1. What is the main purpose of Grafana in a Kubernetes environment?
easy
A. To visualize and monitor data from Kubernetes clusters
B. To deploy applications automatically
C. To manage Kubernetes user permissions
D. To store container images

Solution

  1. Step 1: Understand Grafana's role

    Grafana is a tool designed to create visual dashboards from data sources.
  2. Step 2: Connect Grafana to Kubernetes data

    In Kubernetes, Grafana connects to metrics sources to visualize cluster health and performance.
  3. Final Answer:

    To visualize and monitor data from Kubernetes clusters -> Option A
  4. Quick Check:

    Grafana = Visualization and Monitoring [OK]
Hint: Grafana = Visualize data, not deploy or store [OK]
Common Mistakes:
  • Confusing Grafana with deployment tools
  • Thinking Grafana manages permissions
  • Assuming Grafana stores images
2. Which Kubernetes resource is commonly used to deploy Grafana?
easy
A. Pod
B. Deployment
C. ConfigMap
D. ServiceAccount

Solution

  1. Step 1: Identify deployment method

    Grafana runs as an application that needs to be managed and scaled.
  2. Step 2: Choose Kubernetes resource for managing apps

    Deployments manage pods and allow updates and scaling.
  3. Final Answer:

    Deployment -> Option B
  4. Quick Check:

    Deployments = Manage app lifecycle [OK]
Hint: Use Deployment to run and scale Grafana pods [OK]
Common Mistakes:
  • Using Pod directly without Deployment
  • Confusing ConfigMap with deployment
  • Thinking ServiceAccount deploys apps
3. Given this snippet of a Grafana dashboard JSON, what type of visualization will it create?
{
  "panels": [
    {
      "type": "graph",
      "title": "CPU Usage"
    }
  ]
}
medium
A. A graph chart displaying CPU usage over time
B. A table showing CPU usage data
C. A text panel with CPU usage summary
D. A heatmap of CPU usage

Solution

  1. Step 1: Identify panel type in JSON

    The panel type is "graph", which means a line or bar chart.
  2. Step 2: Match visualization to type

    Graph panels show data trends over time, suitable for CPU usage.
  3. Final Answer:

    A graph chart displaying CPU usage over time -> Option A
  4. Quick Check:

    Panel type 'graph' = Chart visualization [OK]
Hint: Panel type 'graph' means line/bar chart [OK]
Common Mistakes:
  • Confusing 'graph' with 'table'
  • Assuming 'graph' means text
  • Mixing heatmap with graph
4. You deployed Grafana on Kubernetes but the dashboard shows no data. Which fix is most likely correct?
medium
A. Increase the CPU limits of the Grafana pod
B. Restart the Kubernetes cluster
C. Check if the data source is configured and connected properly
D. Delete the Grafana deployment and recreate it

Solution

  1. Step 1: Identify cause of no data in Grafana

    No data usually means Grafana cannot read from its data source.
  2. Step 2: Verify data source configuration

    Ensure the data source (like Prometheus) is added and reachable in Grafana settings.
  3. Final Answer:

    Check if the data source is configured and connected properly -> Option C
  4. Quick Check:

    No data = Check data source connection [OK]
Hint: No data? Verify data source setup first [OK]
Common Mistakes:
  • Restarting cluster unnecessarily
  • Deleting deployment without checking config
  • Changing CPU limits unrelated to data
5. You want to create a Grafana dashboard that shows CPU and memory usage side by side for multiple Kubernetes nodes. Which approach is best?
hard
A. Use a text panel describing CPU and memory usage
B. Use a single panel with combined CPU and memory metrics in one graph
C. Create separate dashboards for CPU and memory usage
D. Create a dashboard JSON with two panels: one for CPU and one for memory, each querying node metrics

Solution

  1. Step 1: Understand dashboard layout needs

    Side by side means multiple panels on one dashboard.
  2. Step 2: Design panels for each metric

    Create one panel for CPU and another for memory, each querying node metrics separately.
  3. Step 3: Avoid combining unrelated metrics in one graph

    Separate panels improve clarity and comparison.
  4. Final Answer:

    Create a dashboard JSON with two panels: one for CPU and one for memory, each querying node metrics -> Option D
  5. Quick Check:

    Separate panels = Clear side-by-side view [OK]
Hint: Use separate panels for different metrics side by side [OK]
Common Mistakes:
  • Combining CPU and memory in one confusing graph
  • Making separate dashboards instead of one
  • Using text panels instead of graphs