0
0
Dockerdevops~20 mins

Prometheus for Docker monitoring - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Prometheus Docker Monitoring Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Prometheus Docker container startup output
You run the following command to start Prometheus in Docker with a custom configuration file. What is the expected output in the Docker logs indicating Prometheus started successfully?
Docker
docker run -d --name prometheus -p 9090:9090 -v /home/user/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
Alevel=warn ts=... msg="Deprecated flag used" ...
BError: failed to load config file: open /etc/prometheus/prometheus.yml: no such file or directory
Clevel=info ts=... msg="Starting Prometheus" ...
Dlevel=error ts=... msg="Failed to bind to port 9090" ...
Attempts:
2 left
💡 Hint
Look for a log message that confirms Prometheus started without errors.
Configuration
intermediate
2:00remaining
Prometheus scrape config for Docker containers
Which Prometheus scrape configuration snippet correctly scrapes metrics from Docker containers exposing metrics on port 9100?
A
scrape_configs:
  - job_name: 'docker'
    static_configs:
      - targets: ['localhost:9100']
B
scrape_configs:
  - job_name: 'docker'
    docker_sd_configs:
      - host: 'unix:///var/run/docker.sock'
        port: 9100
C
scrape_configs:
  - job_name: 'docker'
    file_sd_configs:
      - files: ['/etc/prometheus/docker_targets.yml']
D
scrape_configs:
  - job_name: 'docker'
    kubernetes_sd_configs:
      - role: pod
Attempts:
2 left
💡 Hint
Docker service discovery uses the Docker socket and port configuration.
Troubleshoot
advanced
2:00remaining
Prometheus cannot scrape Docker container metrics
You configured Prometheus to scrape Docker containers on port 9100, but no metrics appear in Prometheus UI. Which is the most likely cause?
ADocker containers do not expose metrics on port 9100
BPrometheus configuration file has invalid YAML syntax
CPrometheus port 9090 is blocked by firewall
DPrometheus container lacks access to Docker socket
Attempts:
2 left
💡 Hint
Prometheus needs permission to access Docker socket for service discovery.
🔀 Workflow
advanced
3:00remaining
Steps to monitor Docker containers with Prometheus
What is the correct order of steps to set up Prometheus monitoring for Docker containers exposing metrics on port 9100?
A1,2,3,4
B2,1,3,4
C1,3,2,4
D3,2,1,4
Attempts:
2 left
💡 Hint
Think about starting containers first, then Prometheus, then configuration, then verification.
Best Practice
expert
3:00remaining
Best practice for Prometheus Docker monitoring security
Which option is the best practice to securely run Prometheus monitoring Docker containers without exposing the Docker socket to Prometheus container?
AUse a Prometheus exporter sidecar container per Docker container
BMount the Docker socket read-only into Prometheus container
CRun Prometheus on the host machine with full Docker socket access
DDisable Docker socket access and scrape metrics via container IPs only
Attempts:
2 left
💡 Hint
Consider isolation and minimal permissions for security.