2021-03-30 04:30:23 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								# A example scrape configuration for running Prometheus with Docker.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								scrape_configs:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # Make Prometheus scrape itself for metrics.
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-12 18:47:47 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  - job_name: "prometheus"
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-30 04:30:23 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    static_configs:
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-12 18:47:47 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      - targets: ["localhost:9090"]
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-30 04:30:23 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # Create a job for Docker daemon.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  #
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # This example requires Docker daemon to be configured to expose
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # Prometheus metrics, as documented here:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # https://docs.docker.com/config/daemon/prometheus/
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-12 18:47:47 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  - job_name: "docker"
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-30 04:30:23 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    static_configs:
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-12 18:47:47 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      - targets: ["localhost:9323"]
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-30 04:30:23 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # Create a job for Docker Swarm containers.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  #
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # This example works with cadvisor running using:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  # docker run --detach --name cadvisor -l prometheus-job=cadvisor
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  #     --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock,ro
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  #     --mount type=bind,src=/,dst=/rootfs,ro
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  #     --mount type=bind,src=/var/run,dst=/var/run
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  #     --mount type=bind,src=/sys,dst=/sys,ro
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  #     --mount type=bind,src=/var/lib/docker,dst=/var/lib/docker,ro
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  #     google/cadvisor -docker_only
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-12 18:47:47 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  - job_name: "docker-containers"
							 | 
						
					
						
							
								
									
										
										
										
											2021-03-30 04:30:23 +08:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    docker_sd_configs:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      - host: unix:///var/run/docker.sock # You can also use http/https to connect to the Docker daemon.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    relabel_configs:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      # Only keep containers that have a `prometheus-job` label.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      - source_labels: [__meta_docker_container_label_prometheus_job]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        regex: .+
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        action: keep
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      # Use the task labels that are prefixed by `prometheus-`.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      - regex: __meta_docker_container_label_prometheus_(.+)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        action: labelmap
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        replacement: $1
							 |