Introduction
Prometheus is a powerful open-source monitoring and alerting toolkit originally built at SoundCloud. It has become a standard for monitoring in cloud-native environments. Its main features include a multi-dimensional data model, a flexible query language (PromQL), and a variety of visualization options.
In this lab, you will learn the most straightforward way to get a Prometheus instance up and running using Docker. This approach avoids complex installation steps and allows you to start exploring Prometheus quickly. You will pull the official Docker image, run it as a container, and interact with its web interface.
Pull Prometheus Docker Image
In this step, you will pull the official Prometheus Docker image from Docker Hub. Docker Hub is a public registry for Docker images, and prom/prometheus is the official image maintained by the Prometheus team.
The docker pull command downloads the specified image to your local machine, making it available to run as a container.
Execute the following command in your terminal to pull the latest version of the Prometheus image:
docker pull prom/prometheus
You will see output indicating that the image layers are being downloaded. Once completed, the image will be stored locally.
Expected output (version numbers may vary):
Using default tag: latest
latest: Pulling from prom/prometheus
a4ca46b05734: Pull complete
542b5806d2b7: Pull complete
...
Digest: sha256:2c785d4e9af2224941598d142337931a5f8333065916938c6444294020b45f50
Status: Downloaded newer image for prom/prometheus
docker.io/prom/prometheus
Run Prometheus Container on Port 9090
In this step, you will run the Prometheus container using the image you just pulled. We will use the docker run command to create and start the container.
Here's a breakdown of the command options we'll use:
-d: Runs the container in detached mode (in the background).-p 9090:9090: Maps port 9090 of the host machine to port 9090 of the container. Prometheus's web UI runs on port 9090 by default.--name prometheus: Assigns a memorable name,prometheus, to the container for easy reference.prom/prometheus: Specifies the image to use for creating the container.
Run the following command to start your Prometheus container:
docker run -d -p 9090:9090 --name prometheus prom/prometheus
The command will output a long container ID, confirming that the container has started.
To verify that the container is running, you can use the docker ps command, which lists all running containers.
docker ps
You should see the prometheus container in the list, with its status as "Up".
Expected output:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a1b2c3d4e5f6 prom/prometheus "/bin/prometheus --c…" A few seconds ago Up a few seconds 0.0.0.0:9090->9090/tcp prometheus
Access Prometheus Web UI at localhost:9090
In this step, you will access the Prometheus web interface, which is now running and exposed on port 9090. The LabEx environment provides a convenient way to access web services running inside the virtual machine.
Click the +(New Tab) button located at the top of the lab interface.
Select the Web Service option, and enter 9090 as the port.

This will open a new browser tab connected to the services running in your lab environment.
Since we mapped port 9090, the Prometheus UI will be available. You should see the Prometheus Expression Browser, which is the main landing page. This interface allows you to write and execute PromQL queries to explore metrics.

The presence of this page confirms that your Prometheus container is running correctly and is accessible.
Verify Prometheus Service Status
In this step, you will use the Prometheus UI to verify the status and runtime information of the Prometheus service itself.
In the Prometheus web UI that you opened in the previous step, navigate to the status page by clicking on the Status menu in the top navigation bar, and then selecting Runtime & Build Information.
This page displays detailed information about the running Prometheus instance, including its version, build date, and the Go version it was compiled with. This is a good way to confirm that the service is fully operational.
Another way to check the health and metrics of the Prometheus server is by accessing its /metrics endpoint. This endpoint exposes a wealth of internal metrics about Prometheus itself. You can view this data using curl in your terminal.
curl http://localhost:9090/metrics
The output will be a long list of metrics in Prometheus exposition format. Look for a metric like prometheus_build_info to confirm the endpoint is working.
Partial expected output:
## HELP prometheus_build_info A metric with a constant '1' value labeled with the version, revision, branch, and goversion from which prometheus was built.
## TYPE prometheus_build_info gauge
prometheus_build_info{branch="HEAD",goversion="go1.19.5",revision="233d305681c0da67c694b01d832131d173a0552b",version="2.41.0"} 1
...
Explore Default Targets in Prometheus UI
In this step, you will explore the concept of "targets" in Prometheus. A target is an endpoint that Prometheus scrapes (pulls) metrics from. By default, the Prometheus server is configured to monitor itself.
In the Prometheus web UI, navigate to the targets page by clicking on the Status menu and then selecting Targets.
On this page, you will see a list of all configured scrape targets. You should see a target group named prometheus with a single endpoint: http://localhost:9090/metrics. This is the Prometheus server's own metrics endpoint.

Pay attention to the State column. It should show UP in green. This indicates that Prometheus is successfully connecting to the target and scraping its metrics. If there were a problem connecting to the target, the state would be "DOWN". This page is crucial for diagnosing issues with metric collection.
Summary
Congratulations! You have successfully installed and run a Prometheus instance using Docker. This lab provided a hands-on introduction to getting started with one of the most popular monitoring tools in the industry.
In this lab, you have learned how to:
- Pull the official Prometheus Docker image from Docker Hub.
- Run a Prometheus container and map its port to the host.
- Access and navigate the Prometheus web UI.
- Verify the service status through the UI and metrics endpoint.
- Explore the default monitoring target configuration.
You now have a foundational understanding of how to deploy Prometheus. The next steps in your journey could involve learning how to create a custom configuration file to monitor other applications and services.



