Skip to content

Commit

Permalink
minor fixes to grafana scripts
Browse files Browse the repository at this point in the history
  Updated scripts to
  - use network instead of link
  - use podman or docker

Signed-off-by: Vimal Kumar <vimal78@gmail.com>
  • Loading branch information
vimalk78 committed Nov 25, 2023
1 parent 3674dbc commit 0a2b0c1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
8 changes: 6 additions & 2 deletions scripts/grafana/start-prometheus.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ then
exit 1
fi

CTR_RUN=${CTR_RUN:-docker}

mkdir -p grafana_volume/dashboards
mkdir -p prometheus_volume

Expand Down Expand Up @@ -36,10 +38,12 @@ else
curl -o grafana_volume/dashboards/pcm-dashboard.json $1/dashboard/prometheus
fi

echo "Starting prometheus network"
${CTR_RUN} network create prometheus-network
echo Starting prometheus
docker run --name prometheus -d -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml -v $PWD/prometheus_volume:/prometheus prom/prometheus
${CTR_RUN} run --name prometheus --network prometheus-network -d -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml:Z -v $PWD/prometheus_volume:/prometheus:Z quay.io/prometheus/prometheus:latest
echo Starting grafana
docker run -d --link=prometheus --name=grafana -p 3000:3000 -v $PWD/grafana_volume:/var/lib/grafana -v $PWD/provisioning:/etc/grafana/provisioning grafana/grafana
${CTR_RUN} run -d --network=prometheus-network --name=grafana -p 3000:3000 -v $PWD/grafana_volume:/var/lib/grafana:Z -v $PWD/provisioning:/etc/grafana/provisioning:Z docker.io/grafana/grafana:latest

echo Start browser at http://localhost:3000/ and login with admin user, password admin

9 changes: 6 additions & 3 deletions scripts/grafana/start.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ then
exit 1
fi

CTR_RUN=${CTR_RUN:-docker}

# check if argument is file, create the telegraf.conf accordingly
if [ -f "$1" ]; then
Expand Down Expand Up @@ -45,12 +46,14 @@ cp automatic_influxdb.yml provisioning/datasources/automatic.yml
echo Downloading PCM dashboard
curl -o grafana_volume/dashboards/pcm-dashboard.json $1/dashboard

echo "Creating influxdb network"
${CTR_RUN} network create influxdb-network
echo Starting influxdb
docker run -d --name influxdb -p 8083:8083 -p 8086:8086 -v $PWD/influxdb_volume:/var/lib/influxdb influxdb:1.8.0-alpine
${CTR_RUN} run -d --name influxdb -p 8083:8083 -p 8086:8086 -v $PWD/influxdb_volume:/var/lib/influxdb influxdb:1.8.0-alpine --network influxdb-network
echo Starting telegraf
docker run -d --name telegraf --link=influxdb -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro telegraf
${CTR_RUN} run -d --name telegraf --network=influxdb -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro telegraf
echo Starting grafana
docker run -d --link=influxdb --name grafana -p 3000:3000 -v $PWD/provisioning:/etc/grafana/provisioning -v $PWD/grafana_volume:/var/lib/grafana grafana/grafana
${CTR_RUN} run -d --network=influxdb --name grafana -p 3000:3000 -v $PWD/provisioning:/etc/grafana/provisioning -v $PWD/grafana_volume:/var/lib/grafana grafana/grafana

echo Start browser at http://localhost:3000/ and login with admin user, password admin

5 changes: 3 additions & 2 deletions scripts/grafana/stop.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

CTR_RUN=${CTR_RUN:-docker}
for c in grafana telegraf influxdb prometheus; do

id=`docker ps -a -q --filter="name=$c" --format="{{.ID}}"`
id=`${CTR_RUN} ps -a -q --filter="name=$c" --format="{{.ID}}"`
if [ ! -z "$id" ]
then
echo Stopping and deleting $c
docker rm $(docker stop $id)
${CTR_RUN} rm $(${CTR_RUN} stop $id)
fi
done

0 comments on commit 0a2b0c1

Please sign in to comment.