Skip to content

Commit aa4cbfe

Browse files
committed
added filtering and enriching
1 parent 0e0dbd6 commit aa4cbfe

File tree

8 files changed

+501
-0
lines changed

8 files changed

+501
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
$prometheus_script = <<-SCRIPT
2+
echo Downloading Prometheus
3+
wget https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz
4+
echo Getting files
5+
tar xvfz prometheus-2.32.1.linux-amd64.tar.gz
6+
SCRIPT
7+
8+
$exporter_script = <<-SCRIPT
9+
echo Installing prometheus node exporter linux
10+
apt-get -y install prometheus-node-exporter
11+
12+
SCRIPT
13+
14+
Vagrant.configure("2") do |config|
15+
config.vm.provision "shell", inline: <<-SHELL
16+
apt-get update -y
17+
echo "10.0.0.10 prometheus" >> /etc/hosts
18+
echo "10.0.0.11 linux-batch" >> /etc/hosts
19+
echo "10.0.0.12 linux-web" >> /etc/hosts
20+
SHELL
21+
22+
config.vm.define "prometheus" do |prometheus|
23+
prometheus.vm.box = "bento/ubuntu-20.04"
24+
prometheus.vm.hostname = "prometheus"
25+
prometheus.vm.network "private_network", ip: "10.0.0.10"
26+
prometheus.vm.provision "shell", inline: $prometheus_script
27+
prometheus.vm.provider "virtualbox" do |vb|
28+
vb.memory = 4048
29+
vb.cpus = 2
30+
end
31+
end
32+
33+
config.vm.define "linux-batch" do |linuxbatch|
34+
linuxbatch.vm.box = "bento/ubuntu-20.04"
35+
linuxbatch.vm.hostname = "linux-batch"
36+
linuxbatch.vm.network "private_network", ip: "10.0.0.11"
37+
linuxbatch.vm.provision "docker" do |d|
38+
d.run "jaimesalas/prom-batch",
39+
args: "-e PORT=8080 -p 8080:8080"
40+
end
41+
linuxbatch.vm.provision "shell", inline: $exporter_script
42+
linuxbatch.vm.provider "virtualbox" do |vb|
43+
vb.memory = 1012
44+
vb.cpus = 1
45+
end
46+
end
47+
48+
config.vm.define "linux-web" do |linuxweb|
49+
linuxweb.vm.box = "bento/ubuntu-20.04"
50+
linuxweb.vm.hostname = "linux-web"
51+
linuxweb.vm.network "private_network", ip: "10.0.0.12"
52+
linuxweb.vm.provision "docker" do |d|
53+
d.run "jaimesalas/prom-web",
54+
args: "-e PORT=8080 -p 8080:8080"
55+
end
56+
linuxweb.vm.provision "shell", inline: $exporter_script
57+
linuxweb.vm.provider "virtualbox" do |vb|
58+
vb.memory = 1012
59+
vb.cpus = 1
60+
end
61+
end
62+
end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"targets": [
4+
"linux-batch:9100"
5+
],
6+
"labels": {
7+
"os": "linux",
8+
"runtime": "vm"
9+
}
10+
},
11+
{
12+
"targets": [
13+
"linux-batch:8080"
14+
],
15+
"labels": {
16+
"os": "linux",
17+
"runtime": "container"
18+
}
19+
}
20+
]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
global:
2+
scrape_interval: 15s
3+
4+
scrape_configs:
5+
- job_name: "prometheus"
6+
static_configs:
7+
- targets: ["localhost:9090"]
8+
9+
- job_name: "linuxbatch"
10+
static_configs:
11+
- targets: ["linux-batch:9100"]
12+
labels:
13+
os: linux
14+
runtime: vm
15+
16+
- job_name: "batch"
17+
static_configs:
18+
- targets: ["linux-batch:8080"]
19+
labels:
20+
os: linux
21+
runtime: container
22+
23+
- job_name: "linuxweb"
24+
scrape_timeout: 15s # default 10 s
25+
static_configs:
26+
- targets: ["linux-web:9100"]
27+
labels:
28+
os: linux
29+
runtime: vm
30+
31+
- job_name: "web"
32+
metrics_path: /metrics
33+
scheme: http # can include TLS and auth for HTTPS
34+
static_configs:
35+
- targets: ["linux-web:8080"]
36+
labels:
37+
os: linux
38+
runtime: docker
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
global:
2+
scrape_interval: 15s
3+
4+
scrape_configs:
5+
- job_name: "prometheus"
6+
static_configs:
7+
- targets: ["localhost:9090"]
8+
9+
- job_name: "web"
10+
file_sd_configs:
11+
- files:
12+
- "web.json"
13+
14+
- job_name: "batch"
15+
file_sd_configs:
16+
- files:
17+
- "batch.json"
18+
relabel_configs:
19+
- source_labels: [runtime]
20+
regex: container
21+
target_label: runtime
22+
replacement: docker
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
global:
2+
scrape_interval: 15s
3+
4+
scrape_configs:
5+
- job_name: "prometheus"
6+
static_configs:
7+
- targets: ["localhost:9090"]
8+
9+
- job_name: "web"
10+
file_sd_configs:
11+
- files:
12+
- "web.json"
13+
metric_relabel_configs:
14+
- source_labels: [__name__]
15+
regex: "go_.*"
16+
action: drop
17+
- source_labels: [__name__, fstype]
18+
regex: "node_filesystem_free_bytes;(.*)"
19+
replacement: "${1}"
20+
target_label: device
21+
22+
- job_name: "batch"
23+
file_sd_configs:
24+
- files:
25+
- "batch.json"
26+
relabel_configs:
27+
- source_labels: [runtime]
28+
regex: container
29+
target_label: runtime
30+
replacement: docker
31+
metric_relabel_configs:
32+
- source_labels: [__name__]
33+
regex: "go_.*"
34+
action: drop
35+
- source_labels: [__name__, mountpoint]
36+
regex: "node_filesystem_avail_bytes;.*"
37+
action: replace
38+
replacement: ""
39+
target_label: mountpoint

0 commit comments

Comments
 (0)