diff --git a/engine/admin/prometheus.md b/engine/admin/prometheus.md index 51f7c2e939..87e0791b2f 100644 --- a/engine/admin/prometheus.md +++ b/engine/admin/prometheus.md @@ -57,7 +57,8 @@ need a slightly different configuration.
@@ -130,7 +131,7 @@ scrape_configs: # scheme defaults to 'http'. static_configs: - - targets: ['localhost:9090'] + - targets: ['docker.for.mac.localhost:9090'] - job_name: 'docker' # metrics_path defaults to '/metrics' @@ -140,20 +141,61 @@ scrape_configs: - targets: ['192.168.65.1:9323'] ``` -
+ +
+ +```yml +# 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). + + # Attach these labels to any time series or alerts when communicating with + # external systems (federation, remote storage, Alertmanager). + external_labels: + monitor: 'codelab-monitor' + +# Load rules once and periodically evaluate them according to the global 'evaluation_interval'. +rule_files: + # - "first.rules" + # - "second.rules" + +# 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=` to any timeseries scraped from this config. + - job_name: 'prometheus' + + # metrics_path defaults to '/metrics' + # scheme defaults to 'http'. + + static_configs: + - targets: ['docker.for.win.localhost:9090'] + + - job_name: 'docker' + # metrics_path defaults to '/metrics' + # scheme defaults to 'http'. + + static_configs: + - targets: ['192.168.65.1:9323'] +``` + +
Next, start a single-replica Prometheus service using this configuration.
-
+
```bash $ docker service create --replicas 1 --name my-prometheus \ @@ -163,6 +205,16 @@ $ docker service create --replicas 1 --name my-prometheus \ ```
+
+ +```bash +$ docker service create --replicas 1 --name my-prometheus \ + --mount type=bind,source=/tmp/prometheus.yml,destination=/etc/prometheus/prometheus.yml \ + --publish 9090:9090/tcp \ + prom/prometheus +``` + +
```powershell @@ -172,7 +224,7 @@ PS C:\> docker service create --replicas 1 --name my-prometheus prom/prometheus ``` -
+
Verify that the Docker target is listed at http://localhost:9090/targets/.