Skip to content

Commit

Permalink
Merge pull request #428 from stakwork/setup/grafana-prometheus
Browse files Browse the repository at this point in the history
chore: setup grafana and prometheus
  • Loading branch information
tobi-bams authored Dec 19, 2024
2 parents b275a41 + 423c6d7 commit 85aeb3f
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
24 changes: 24 additions & 0 deletions prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
global:
scrape_interval: 10s

scrape_configs:
- job_name: 'swarms'
ec2_sd_configs:
- region: us-east-1
port: 9100
scheme: http # Ensure Prometheus uses HTTP
relabel_configs:
# Keep only the EC2 instances with the tag Swarm set to superadmin
- source_labels: [__meta_ec2_tag_Swarm]
regex: superadmin
action: keep

# Extract the public IP from EC2 metadata and assign it to __address__
- source_labels: [__meta_ec2_public_ip]
regex: (.*)
target_label: __address__
replacement: "${1}:9100"

# Label the instances with their name and availability zone
- source_labels: [__meta_ec2_tag_Name, __meta_ec2_availability_zone]
target_label: instance
10 changes: 10 additions & 0 deletions second-brain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ services:
- AWS_S3_BUCKET_NAME=$AWS_S3_BUCKET_NAME
- GITHUB_REQUEST_TOKEN=$GITHUB_REQUEST_TOKEN
- SINGLE_AUDIO_OR_VIDEO_EPISODE_WORKFLOW_ID=$SINGLE_AUDIO_OR_VIDEO_EPISODE_WORKFLOW_ID
node_exporter:
image: quay.io/prometheus/node-exporter:latest
container_name: node_exporter
command:
- '--path.rootfs=/host'
network_mode: host
pid: host
restart: unless-stopped
volumes:
- '/:/host:ro,rslave'

networks:
sphinx-swarm:
Expand Down
43 changes: 43 additions & 0 deletions superadmin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,50 @@ services:
- AWS_USER_ROLE=$AWS_USER_ROLE
- GITHUB_REQUEST_TOKEN=$GITHUB_REQUEST_TOKEN
- SINGLE_AUDIO_OR_VIDEO_EPISODE_WORKFLOW_ID=$SINGLE_AUDIO_OR_VIDEO_EPISODE_WORKFLOW_ID
prometheus:
image: prom/prometheus
container_name: prometheus
networks:
- sphinx-swarm
command:
- '--config.file=/etc/prometheus/prometheus.yml'
ports:
- 9090:9090
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.prometheus.rule=Host(`prometheus.${HOST}`)"
- "traefik.http.services.prometheus.loadbalancer.server.port=9090"
- "traefik.http.routers.prometheus.tls=true"
- "traefik.http.routers.prometheus.tls.certresolver=myresolver"
- "traefik.http.routers.prometheus.entrypoints=websecure"
volumes:
- ./prometheus:/etc/prometheus
- prom_data:/prometheus
grafana:
image: grafana/grafana
container_name: grafana
networks:
- sphinx-swarm
ports:
- 3000:3000
restart: unless-stopped
labels:
- "traefik.enable=true"
- "traefik.http.routers.grafana.rule=Host(`grafana.${HOST}`)"
- "traefik.http.services.grafana.loadbalancer.server.port=3000"
- "traefik.http.routers.grafana.tls=true"
- "traefik.http.routers.grafana.tls.certresolver=myresolver"
- "traefik.http.routers.grafana.entrypoints=websecure"
environment:
- GF_SECURITY_ADMIN_USER=$GF_SECURITY_ADMIN_USER
- GF_SECURITY_ADMIN_PASSWORD=$GF_SECURITY_ADMIN_PASSWORD
volumes:
- ./grafana:/etc/grafana/provisioning/datasources

networks:
sphinx-swarm:
external: true

volumes:
prom_data:

0 comments on commit 85aeb3f

Please sign in to comment.