Created
August 10, 2018 12:24
-
-
Save jm42/5c3a0bd83fa0290c093c801b4a01cec7 to your computer and use it in GitHub Desktop.
Prometheus Vagrant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby sw=2 ts=2 : | |
Vagrant.configure("2") do |config| | |
config.vm.box = "debian/jessie64" | |
config.vm.define "prom-server" do |prom| | |
prom.vm.hostname = "prom.local" | |
prom.vm.network "private_network", ip: "192.168.42.63" | |
prom.vm.synced_folder ".", "/vagrant", disabled: true | |
prom.vm.provision "shell", inline: <<-SCRIPT | |
VERSION=2.3.2 | |
cd /opt | |
if [ ! -f prometheus-$VERSION.linux-amd64.tar.gz ]; then | |
wget -q https://github.com/prometheus/prometheus/releases/download/v$VERSION/prometheus-$VERSION.linux-amd64.tar.gz | |
tar -C /opt -xf prometheus-$VERSION.linux-amd64.tar.gz | |
fi | |
cat <<CONFIG > prometheus.yml | |
global: | |
scrape_interval: 15s | |
evaluation_interval: 15s | |
scrape_configs: | |
- job_name: prom | |
scrape_interval: 5s | |
static_configs: | |
- targets: ['localhost:9090'] | |
- job_name: node | |
static_configs: | |
- targets: ['192.168.42.64:9100'] | |
CONFIG | |
cat <<DAEMON > /etc/systemd/system/prometheus.service | |
[Unit] | |
Description=Prometheus | |
After=network-online.target | |
[Service] | |
Restart=on-failure | |
ExecStart=/opt/prometheus-$VERSION.linux-amd64/prometheus --config.file=/opt/prometheus.yml | |
[Install] | |
WantedBy=multi-user.target | |
DAEMON | |
systemctl daemon-reload | |
systemctl start prometheus | |
systemctl enable prometheus | |
SCRIPT | |
end | |
config.vm.define "node" do |node| | |
node.vm.hostname = "node.local" | |
node.vm.network "private_network", ip: "192.168.42.64" | |
node.vm.synced_folder ".", "/vagrant", disabled: true | |
node.vm.provision "shell", inline: <<-SCRIPT | |
VERSION=0.16.0 | |
cd /opt | |
if [ ! -f node_exporter-$VERSION.linux-amd64.tar.gz ]; then | |
wget -q https://github.com/prometheus/node_exporter/releases/download/v$VERSION/node_exporter-$VERSION.linux-amd64.tar.gz | |
tar -C /opt -xf node_exporter-$VERSION.linux-amd64.tar.gz | |
fi | |
cat <<DAEMON > /etc/systemd/system/node_exporter.service | |
[Unit] | |
Description=Node Exporter | |
After=network-online.target | |
[Service] | |
Restart=on-failure | |
ExecStart=/opt/node_exporter-$VERSION.linux-amd64/node_exporter | |
[Install] | |
WantedBy=multi-user.target | |
DAEMON | |
systemctl daemon-reload | |
systemctl start node_exporter | |
systemctl enable node_exporter | |
SCRIPT | |
end | |
config.vm.define "grafana" do |graph| | |
graph.vm.hostname = "graph.local" | |
graph.vm.network "private_network", ip: "192.168.42.65" | |
graph.vm.synced_folder ".", "/vagrant", disabled: true | |
graph.vm.provision "shell", inline: <<-SCRIPT | |
VERSION=5.2.2 | |
apt-get -y install libfontconfig | |
cd /opt | |
if [ ! -f grafana_${VERSION}_amd64.deb ]; then | |
wget -q wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_${VERSION}_amd64.deb | |
dpkg -i grafana_${VERSION}_amd64.deb | |
fi | |
systemctl start grafana-server | |
systemctl enable grafana-server | |
SCRIPT | |
end | |
["vmware_fusion", "vmware_workstation", "virtualbox"].each do |provider| | |
config.vm.provider provider do |v, override| | |
v.memory = 512 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment