# 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', 'cadvisor:8080', 'nodeexporter:9100'] 

Next, create a Dockerfile using the command touch Dockerfile  and edit it using vi : 

#Base Image is prometheus FROM ibmcom/prometheus:v2.8.0 #Insert the config file COPY prometheus.yml /etc/prometheus/prometheus.yml 

Having done this, you can issue the following command to build the image: docker build -t prometheus:v2.8.0 . Be sure to include the dot at the end of the command. 

Because Prometheus is the component that stores the monitored data, you should store this data to persistent storage by using a Docker volume. You can create a Docker volume by using the command docker volume create prometheus-data . 

The command to start your Prometheus instance would then be the following: 

docker run --name prometheus --network monitoring -v prometheus-data:/prometheus -p 9090:9090 -d prometheus:v2.8.0 

To verify that Prometheus is up and running, point a browser to the zCX address through port 9090, as shown in Figure 7-5 on page 173. 

