| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | --- | 
					
						
							| 
									
										
										
										
											2017-10-26 21:53:27 +08:00
										 |  |  | title: Installation | 
					
						
							|  |  |  | sort_rank: 2 | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:53:27 +08:00
										 |  |  | # Installation
 | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | ## Using pre-compiled binaries
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | We provide precompiled binaries for most official Prometheus components. Check | 
					
						
							|  |  |  | out the [download section](https://prometheus.io/download) for a list of all | 
					
						
							|  |  |  | available versions. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## From source
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | For building Prometheus components from source, see the `Makefile` targets in | 
					
						
							|  |  |  | the respective repository. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Using Docker
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-16 19:26:10 +08:00
										 |  |  | All Prometheus services are available as Docker images on | 
					
						
							|  |  |  | [Quay.io](https://quay.io/repository/prometheus/prometheus) or | 
					
						
							| 
									
										
										
										
											2019-07-01 18:56:23 +08:00
										 |  |  | [Docker Hub](https://hub.docker.com/r/prom/prometheus/). | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | Running Prometheus on Docker is as simple as `docker run -p 9090:9090 | 
					
						
							| 
									
										
										
										
											2018-11-16 19:26:10 +08:00
										 |  |  | prom/prometheus`. This starts Prometheus with a sample | 
					
						
							|  |  |  | configuration and exposes it on port 9090. | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | The Prometheus image uses a volume to store the actual metrics. For | 
					
						
							| 
									
										
										
										
											2020-08-31 22:44:08 +08:00
										 |  |  | production deployments it is highly recommended to use a | 
					
						
							|  |  |  | [named volume](https://docs.docker.com/storage/volumes/) | 
					
						
							|  |  |  | to ease managing the data on Prometheus upgrades. | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | To provide your own configuration, there are several options. Here are | 
					
						
							|  |  |  | two examples. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### Volumes & bind-mount
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | Bind-mount your `prometheus.yml` from the host by running: | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | ```bash | 
					
						
							| 
									
										
										
										
											2019-11-02 18:49:36 +08:00
										 |  |  | docker run \ | 
					
						
							|  |  |  |     -p 9090:9090 \ | 
					
						
							| 
									
										
										
										
											2020-08-31 22:44:08 +08:00
										 |  |  |     -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \ | 
					
						
							| 
									
										
										
										
											2019-11-02 18:49:36 +08:00
										 |  |  |     prom/prometheus | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-31 22:44:08 +08:00
										 |  |  | Or bind-mount the directory containing `prometheus.yml` onto | 
					
						
							|  |  |  | `/etc/prometheus` by running: | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | ```bash | 
					
						
							| 
									
										
										
										
											2019-11-02 18:49:36 +08:00
										 |  |  | docker run \ | 
					
						
							|  |  |  |     -p 9090:9090 \ | 
					
						
							|  |  |  |     -v /path/to/config:/etc/prometheus \ | 
					
						
							|  |  |  |     prom/prometheus | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ### Custom image
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | To avoid managing a file on the host and bind-mount it, the | 
					
						
							|  |  |  | configuration can be baked into the image. This works well if the | 
					
						
							|  |  |  | configuration itself is rather static and the same across all | 
					
						
							|  |  |  | environments. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | For this, create a new directory with a Prometheus configuration and a | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | `Dockerfile` like this: | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | ```Dockerfile | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | FROM prom/prometheus | 
					
						
							|  |  |  | ADD prometheus.yml /etc/prometheus/ | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Now build and run it: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | ```bash | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | docker build -t my-prometheus . | 
					
						
							|  |  |  | docker run -p 9090:9090 my-prometheus | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | A more advanced option is to render the configuration dynamically on start | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | with some tooling or even have a daemon update it periodically. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ## Using configuration management systems
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | If you prefer using configuration management systems you might be interested in | 
					
						
							|  |  |  | the following third-party contributions: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | ### Ansible
 | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-28 01:22:27 +08:00
										 |  |  | * [Cloud Alchemy/ansible-prometheus](https://github.com/cloudalchemy/ansible-prometheus) | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | ### Chef
 | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | * [rayrod2030/chef-prometheus](https://github.com/rayrod2030/chef-prometheus) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | ### Puppet
 | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | * [puppet/prometheus](https://forge.puppet.com/puppet/prometheus) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-26 21:42:07 +08:00
										 |  |  | ### SaltStack
 | 
					
						
							| 
									
										
										
										
											2017-10-10 20:58:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-15 22:59:16 +08:00
										 |  |  | * [saltstack-formulas/prometheus-formula](https://github.com/saltstack-formulas/prometheus-formula) |