Prometheus Server Docker Installation on Windows

Scale Counter Graph

About

Step by step to start a Prometheus Server instance with a Docker container and a bind mount.

Steps

Install docker

Docker - Installation

Create a config file

Create a prometheus.yml file.

Example:

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']
  
  - job_name: 'node_vps'
    static_configs:
    - targets: ['vps.example.com']
    scheme: 'https'

Create a cmd file

In the same directory than the created configuration file prometheus.yml, create the below dos file.

@echo off
REM Create the prom container from the prometheus image

SET SCRIPT_PATH=%~dp0
cd %SCRIPT_PATH%

docker run ^
  --name prom ^
  -d ^
  -p 9090:9090 ^
  -v %cd%:/etc/prometheus ^
  prom/prometheus

where:

  • –name is the name of the container created
  • -d means run in the background (daemon)
  • -p maps the container port 9090 to localhost
  • -v mount the current directory (%cd% ie the path of the script) to the container directory /etc/prometheus

And run it:

prometheus-docker-run.cmd

Access / Start / Stop

docker stop prom
  • you can now start it
docker start prom

Documentation / Reference







Share this page:
Follow us:
Task Runner