Skip to content

Instantly share code, notes, and snippets.

@MasterAler
Created February 16, 2022 15:28
Show Gist options
  • Save MasterAler/7dd10dfc3e2242e628b17d177c7dc9b5 to your computer and use it in GitHub Desktop.
Save MasterAler/7dd10dfc3e2242e628b17d177c7dc9b5 to your computer and use it in GitHub Desktop.
Prometheus quick-start with Grafana
apiVersion: 1
datasources:
- name: prometheus
type: prometheus
access: proxy
url: http://127.0.0.1:9090/
version: 1
isDefault: true
jsonData:
timeInterval: '30s'
editable: true
global:
scrape_interval: 5s
scrape_configs:
- job_name: local_node_exporter
static_configs:
- targets: ['127.0.0.1:9100']
- job_name: local_service_1
static_configs:
- targets: ['127.0.0.1:8810']
- job_name: local_service_2
static_configs:
- targets: ['127.0.0.1:80011']
#!/bin/bash
case "$1" in
start)
docker run --name prometheus \
-v $(pwd)/prom.yml:/etc/prometheus/prometheus.yml \
-v prometheus_storage:/prometheus \
--net host --rm --detach \
prom/prometheus:v2.33.3
docker run --name prometheus-node-exporter \
-v /sys:/host/sys \
-v /:/host/root \
--net host --rm --detach \
prom/node-exporter:latest \
--path.sysfs=/host/sys \
--path.rootfs=/host/root \
--collector.filesystem.mount-points-exclude='^/(host|etc|dev|proc|sys)($|/)'
docker run --name grafana \
-eGF_AUTH_ANONYMOUS_ENABLED=true \
-eGF_AUTH_ANONYMOUS_ORG_ROLE=Admin \
-v grafana-storage:/var/lib/grafana \
-v $(pwd)/grafana_datasource_prometheus.yml:/etc/grafana/provisioning/datasources/prom.yml \
--net host --rm --detach \
grafana/grafana-oss:8.3.6
echo "Started"
IP= $(ip a|grep -Eo '192.[0-9.]+'|head -n1) # place your IP here if needed
if [[ ! -z $IP ]]; then
echo "Prometheus: http://${IP}:9090/"
echo "Grafana: http://${IP}:3000/"
fi;
;;
stop)
docker stop prometheus prometheus-node-exporter grafana
echo "Stopped"
;;
clean)
docker volume rm prometheus_storage grafana-storage
echo "Cleaned"
;;
*)
echo "Usage: $0 [start|stop|clean]"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment