Skip to content

Commit bff2467

Browse files
Merge pull request #258 from marcel-dempers/GsNTg8vvTPXLX7F9
sharding tutorial with prometheus
2 parents 6de04ae + 7b4cd81 commit bff2467

File tree

5 files changed

+104
-1
lines changed

5 files changed

+104
-1
lines changed

monitoring/prometheus/docker-compose.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
networks:
2+
prometheus:
3+
name: prometheus
4+
driver: bridge
15
services:
26
go-application:
37
build:
@@ -6,27 +10,35 @@ services:
610
image: go-application
711
ports:
812
- "80:5000"
13+
networks:
14+
- prometheus
915
python-application:
1016
build:
1117
context: ./python-application
1218
container_name: python-application
1319
image: python-application
1420
ports:
1521
- "81:5000"
22+
networks:
23+
- prometheus
1624
dotnet-application:
1725
build:
1826
context: ./dotnet-application
1927
container_name: dotnet-application
2028
image: dotnet-application
2129
ports:
2230
- "82:5000"
31+
networks:
32+
- prometheus
2333
nodejs-application:
2434
build:
2535
context: ./nodejs-application
2636
container_name: nodejs-application
2737
image: nodejs-application
2838
ports:
2939
- "83:5000"
40+
networks:
41+
- prometheus
3042
prometheus:
3143
container_name: prometheus-svc
3244
image: prom/prometheus:v3.3.0
@@ -35,6 +47,8 @@ services:
3547
command: --config.file=/etc/prometheus/prometheus.yaml
3648
volumes:
3749
- ./prometheus.yaml:/etc/prometheus/prometheus.yaml
50+
networks:
51+
- prometheus
3852
grafana:
3953
image: grafana/grafana:11.6.1
4054
ports:
@@ -43,6 +57,8 @@ services:
4357
- GF_AUTH_BASIC_ENABLED=false
4458
- GF_AUTH_ANONYMOUS_ENABLED=true
4559
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
60+
networks:
61+
- prometheus
4662
grafana-dashboards:
4763
image: alpine:latest
4864
depends_on:
@@ -56,4 +72,6 @@ services:
5672
sleep 5s
5773
cd /grafana
5874
curl --request POST http://grafana:3000/api/datasources --header 'Content-Type: application/json' -d @datasources.json
59-
curl --request POST http://grafana:3000/api/dashboards/db --header 'Content-Type: application/json' -d @dashboard.json"
75+
curl --request POST http://grafana:3000/api/dashboards/db --header 'Content-Type: application/json' -d @dashboard.json"
76+
networks:
77+
- prometheus
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Prometheus Basic Sharding
2+
## a Video reference guide
3+
4+
To run any of the commands, please ensure you open a terminal and navigate to the path where this readme is located.
5+
6+
## Start example applications
7+
8+
To start our example applications, we'll need to navigate to the folder where we have our example services in our docker-compose file
9+
10+
```
11+
cd monitoring\prometheus\
12+
13+
docker compose up -d --build go-application
14+
docker compose up -d --build python-application
15+
docker compose up -d --build dotnet-application
16+
docker compose up -d --build nodejs-application
17+
```
18+
19+
## Start Prometheus
20+
21+
```
22+
cd sharding
23+
docker compose up -d prometheus-00
24+
docker compose up -d prometheus-01
25+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
networks:
2+
prometheus:
3+
name: prometheus
4+
driver: bridge
5+
external: true
6+
services:
7+
prometheus-00:
8+
container_name: prometheus-00
9+
image: prom/prometheus:v3.3.0
10+
ports:
11+
- "9090:9090"
12+
command: --config.file=/etc/prometheus/prometheus.yaml
13+
volumes:
14+
- ./prometheus-00.yaml:/etc/prometheus/prometheus.yaml
15+
networks:
16+
- prometheus
17+
prometheus-01:
18+
container_name: prometheus-01
19+
image: prom/prometheus:v3.3.0
20+
ports:
21+
- "9091:9090"
22+
command: --config.file=/etc/prometheus/prometheus.yaml
23+
volumes:
24+
- ./prometheus-01.yaml:/etc/prometheus/prometheus.yaml
25+
networks:
26+
- prometheus
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
global:
2+
scrape_interval: 5s
3+
evaluation_interval: 30s
4+
scrape_configs:
5+
- job_name: my-application
6+
dns_sd_configs:
7+
- names: ['dotnet-application','nodejs-application','go-application','python-application']
8+
type: A
9+
port: 5000
10+
relabel_configs:
11+
- source_labels: [__address__]
12+
modulus: 2
13+
target_label: __tmp_hash
14+
action: hashmod
15+
- source_labels: [__tmp_hash]
16+
regex: '^0$'
17+
action: keep
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
global:
2+
scrape_interval: 5s
3+
evaluation_interval: 30s
4+
scrape_configs:
5+
- job_name: my-application
6+
dns_sd_configs:
7+
- names: ['dotnet-application','nodejs-application','go-application','python-application']
8+
type: A
9+
port: 5000
10+
relabel_configs:
11+
- source_labels: [__address__]
12+
modulus: 2
13+
target_label: __tmp_hash
14+
action: hashmod
15+
- source_labels: [__tmp_hash]
16+
regex: '^1$'
17+
action: keep

0 commit comments

Comments
 (0)