installation.md 2.59 KB
Newer Older
1
---
2 3
title: Installation
sort_rank: 2
4 5
---

6
# Installation
7 8 9 10 11 12 13 14 15 16 17 18 19 20

## 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

21 22
All Prometheus services are available as Docker images on
[Quay.io](https://quay.io/repository/prometheus/prometheus) or
23
[Docker Hub](https://hub.docker.com/r/prom/prometheus/).
24 25

Running Prometheus on Docker is as simple as `docker run -p 9090:9090
26 27
prom/prometheus`. This starts Prometheus with a sample
configuration and exposes it on port 9090.
28 29 30

The Prometheus image uses a volume to store the actual metrics. For
production deployments it is highly recommended to use the
31
[Data Volume Container](https://docs.docker.com/engine/admin/volumes/volumes/)
32 33 34 35 36 37 38
pattern to ease managing the data on Prometheus upgrades.

To provide your own configuration, there are several options. Here are
two examples.

### Volumes & bind-mount

39
Bind-mount your `prometheus.yml` from the host by running:
40

41
```bash
42 43 44 45
docker run \
    -p 9090:9090 \
    -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml \
    prom/prometheus
46 47 48 49
```

Or use an additional volume for the config:

50
```bash
51 52 53 54
docker run \
    -p 9090:9090 \
    -v /path/to/config:/etc/prometheus \
    prom/prometheus
55 56 57 58 59 60 61 62 63 64
```

### 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
65
`Dockerfile` like this:
66

67
```Dockerfile
68 69 70 71 72 73
FROM prom/prometheus
ADD prometheus.yml /etc/prometheus/
```

Now build and run it:

74
```bash
75 76 77 78
docker build -t my-prometheus .
docker run -p 9090:9090 my-prometheus
```

79
A more advanced option is to render the configuration dynamically on start
80 81 82 83 84 85 86
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:

87
### Ansible
88

Roman Demachkovych committed
89
* [Cloud Alchemy/ansible-prometheus](https://github.com/cloudalchemy/ansible-prometheus)
90

91
### Chef
92 93 94

* [rayrod2030/chef-prometheus](https://github.com/rayrod2030/chef-prometheus)

95
### Puppet
96 97 98

* [puppet/prometheus](https://forge.puppet.com/puppet/prometheus)

99
### SaltStack
100

101
* [saltstack-formulas/prometheus-formula](https://github.com/saltstack-formulas/prometheus-formula)