Skip to content

Commit

Permalink
Merge pull request eth-educators#1033 from yorickdowne/main
Browse files Browse the repository at this point in the history
Add grafana-cloud.yml
  • Loading branch information
yorickdowne authored Oct 27, 2022
2 parents d06658c + db44a2e commit 09d1bf5
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ethd
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ upgrade_compose() {
fi
}

prep_prometheus() {
# Create custom-prom.yml if it doesn't exist
if [ ! -f "./prometheus/custom-prom.yml" ]; then
$__as_owner touch "./prometheus/custom-prom.yml"
fi
}

handle_root() {
if [ "${EUID}" -eq 0 ]; then
__as_owner="sudo -u ${OWNER}"
Expand Down Expand Up @@ -1538,7 +1545,7 @@ printhelp() {
echo " logs"
echo " shows logs"
echo " cmd <command>"
echo " executes an arbitrary docker-compose command. Use \"cmd help\" to list them"
echo " executes an arbitrary docker compose command. Use \"cmd help\" to list them"
echo " terminate"
echo " stops the Ethereum node and destroys all data stores"
echo " prune-geth"
Expand All @@ -1547,7 +1554,7 @@ printhelp() {
echo ""
echo "The logs subcommand can be appended by flags and specify the container(s). example: "
echo ""
echo " $me logs -f --tail 500 execution"
echo " $me logs -f --tail 50 execution"
echo " shows logs only for execution service"
echo ""
echo ""
Expand Down Expand Up @@ -1585,6 +1592,7 @@ determine_sudo
handle_root
determine_docker
determine_compose
prep_prometheus

if [ $command = "install" ]; then
$command "$@"
Expand Down
148 changes: 148 additions & 0 deletions grafana-cloud.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Custom Prometheus rules. Use prometheus/custom-prom.yml which will be appended to
# /etc/prometheus/prometheus.yml inside the prometheus container. It will be appended after
# the last scrape target that the entrypoint script adds.
#
# You could add additonal scrape targets as well as additional global sections such as remote-write.
# This file is called grafana-cloud.yml as adding a remote write to Grafana Cloud is likely a
# common use case. It properly is a Prometheus without Grafana and the ability to add custom
# content to prometheus.yml

version: "3.9"
x-logging: &logging
logging:
driver: json-file
options:
max-size: 100m
max-file: "3"
tag: '{{.ImageName}}|{{.Name}}|{{.ImageFullID}}|{{.FullID}}'

services:
prometheus:
restart: "unless-stopped"
build:
context: ./prometheus
image: prometheus:local
volumes:
- prom-data:/prometheus
- ./prometheus/alert_rules.yml:/etc/prometheus/alert_rules.yml
- ./prometheus/custom-prom.yml:/etc/prometheus/custom-prom.yml:ro
- /etc/localtime:/etc/localtime:ro
environment:
- CLIENT=${COMPOSE_FILE}
entrypoint: choose-config.sh
command: ["/bin/prometheus", "--storage.tsdb.path=/prometheus", "--web.console.libraries=/usr/share/prometheus/console_libraries", "--web.console.templates=/usr/share/prometheus/consoles"]
<<: *logging
depends_on:
- node-exporter
- blackbox-exporter
- json-exporter
- cryptowat-exporter
- cadvisor
- ethereum-metrics-exporter

ethereum-metrics-exporter:
restart: "unless-stopped"
build:
context: ./eth-metrics
image: ethereum-metrics-exporter:local
environment:
- CLIENT=${COMPOSE_FILE}
entrypoint:
- docker-entrypoint.sh
- /ethereum-metrics-exporter
<<: *logging

node-exporter:
image: quay.io/prometheus/node-exporter:latest
command:
- '--path.rootfs=/host'
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
# - '--collector.textfile.directory=/etc/node-exporter/'
- '--collector.filesystem.ignored-mount-points=${NODE_EXPORTER_IGNORE_MOUNT_REGEX}'
- '--no-collector.ipvs'
pid: host
restart: unless-stopped
volumes:
- '/:/host:ro,rslave'
- /etc/hostname:/etc/nodename:ro
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /etc/localtime:/etc/localtime:ro
<<: *logging

blackbox-exporter:
restart: "unless-stopped"
image: prom/blackbox-exporter:master
volumes:
- ./prometheus/blackbox.yml:/config/blackbox.yml
- /etc/localtime:/etc/localtime:ro
<<: *logging
command:
- --config.file=/config/blackbox.yml

json-exporter:
restart: "unless-stopped"
image: quay.io/prometheuscommunity/json-exporter
volumes:
- ./prometheus/json.yml:/config/json.yml
- /etc/localtime:/etc/localtime:ro
<<: *logging
command:
- --config.file
- /config/json.yml

cryptowat-exporter:
restart: "unless-stopped"
image: nbarrientos/cryptowat_exporter
volumes:
- /etc/localtime:/etc/localtime:ro
environment:
- CRYPTOWAT_EXCHANGES=kraken
- CRYPTOWAT_PAIRS=ethusd,ethchf
- CRYPTOWAT_CACHESECONDS=300
- TZ=Europe/Zurich
<<: *logging

cadvisor:
image: gcr.io/cadvisor/cadvisor
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /:/rootfs:ro
- /var/run:/var/run
- /sys:/sys:ro
- /var/lib/docker:/var/lib/docker:ro
command:
- --docker_only
- --housekeeping_interval=30s
<<: *logging

promtail:
image: grafana/promtail:latest
user: root
volumes:
- /etc/machine-id:/etc/machine-id:ro
- ./promtail:/etc/promtail
- promtail-data:/tmp
- /var/lib/docker/containers:/var/lib/docker/containers:ro
command:
- '--config.file=/etc/promtail/promtail.yml'
restart: "unless-stopped"
depends_on:
- loki
<<: *logging

loki:
restart: "unless-stopped"
image: grafana/loki:latest
volumes:
- loki-data:/tmp
- ./loki:/etc/loki
command:
- '--config.file=/etc/loki/loki.yml'
<<: *logging

volumes:
prom-data:
loki-data:
promtail-data:
4 changes: 4 additions & 0 deletions prometheus/choose-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ case "$CLIENT" in
*alert* ) cat /etc/prometheus/alert-prom.yml >> /etc/prometheus/prometheus.yml;;
esac

if [ -f "./prometheus/custom-prom.yml" ]; then
cat /etc/prometheus/custom-prom.yml >> /etc/prometheus/prometheus.yml
fi

exec "$@" --config.file=/etc/prometheus/prometheus.yml

0 comments on commit 09d1bf5

Please sign in to comment.