grafana: add helper script
Add a helper script and assocated README.rst to explain the interactive development process. Depends-On: https://review.opendev.org/c/opendev/grafyaml/+/833212 Change-Id: Ibbc2b116d0c496655a7ce6bb6971e8270ac32647
This commit is contained in:
parent
1cf5b35fa0
commit
859005d497
14
grafana/README.rst
Normal file
14
grafana/README.rst
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Developing Graphs
|
||||||
|
=================
|
||||||
|
|
||||||
|
The ``run-grafana.sh`` script in this directory will start a Docker
|
||||||
|
container with Grafana listening on port 3000. It will then load the
|
||||||
|
datasources and dashboards in this directory. Repeated runs of the
|
||||||
|
script will re-load the scripts.
|
||||||
|
|
||||||
|
You can log into the instance with the username "admin" and password
|
||||||
|
"password". You can then use the Grafana UI to develop graphs.
|
||||||
|
|
||||||
|
The "share" icon on the graph in the UI can be used to export a JSON
|
||||||
|
file, which your browser will download. You can copy that to this
|
||||||
|
directory (or update existing files) and submit a review.
|
39
grafana/run-grafana.sh
Normal file
39
grafana/run-grafana.sh
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
DOCKER=docker
|
||||||
|
GRAFYAML_DIR=$(pwd)
|
||||||
|
SECRETS_DIR=$(pwd)/grafana-secrets
|
||||||
|
|
||||||
|
if [ ! -d ${SECRETS_DIR} ]; then
|
||||||
|
mkdir -p ${SECRETS_DIR}
|
||||||
|
echo "password" > ${SECRETS_DIR}/admin_password
|
||||||
|
echo "admin" > ${SECRETS_DIR}/admin_user
|
||||||
|
echo "key" > ${SECRETS_DIR}/secret_key
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $(${DOCKER} ps -f "name=grafana-opendev_test" --format '{{.Names}}') \
|
||||||
|
!= 'grafana-opendev_test' ]]; then
|
||||||
|
|
||||||
|
echo "Running Grafana"
|
||||||
|
|
||||||
|
${DOCKER} run -d --rm \
|
||||||
|
--name grafana-opendev_test \
|
||||||
|
-p 3000:3000 \
|
||||||
|
-v ${SECRETS_DIR}:/etc/grafana/secrets \
|
||||||
|
-e GF_AUTH_ANONYMOUS_ENABLED=true \
|
||||||
|
-e GF_USER_ALLOW_SIGN_UP=false \
|
||||||
|
-e GF_SECURITY_ADMIN_PASSWORD__FILE=/etc/grafana/secrets/admin_password \
|
||||||
|
-e GF_SECURITY_ADMIN_USER__FILE=/etc/grafana/secrets/admin_user \
|
||||||
|
-e GF_SECURITY_SECRET_KEY__FILE=/etc/grafana/secrets/secret_key \
|
||||||
|
docker.io/grafana/grafana-oss
|
||||||
|
|
||||||
|
echo "Grafana listening on :3000"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Reloading dashboards"
|
||||||
|
|
||||||
|
${DOCKER} run --rm -t --network=host \
|
||||||
|
-e 'GRAFANA_URL=http://admin:password@localhost:3000' \
|
||||||
|
-v ${GRAFYAML_DIR}:/grafana:ro \
|
||||||
|
opendevorg/grafyaml
|
Loading…
Reference in New Issue
Block a user