From 503ca0ea937c2487bbf6bffd8c7ec8075f0f805b Mon Sep 17 00:00:00 2001 From: wuvs Date: Thu, 9 Feb 2017 14:14:32 +0700 Subject: [PATCH] feat(grafana): allow user to install plugins --- grafana/README.md | 2 ++ grafana/rootfs/usr/share/grafana/grafana.ini.tpl | 5 +++++ grafana/rootfs/usr/share/grafana/start-grafana | 15 +++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/grafana/README.md b/grafana/README.md index 2cfcbc1..6510672 100644 --- a/grafana/README.md +++ b/grafana/README.md @@ -100,6 +100,8 @@ | [AMQP_PUBLISHER_EXCHANGE](#amqp_publisher_exchange) | no default | AMQP Publisher Exchange | | [DASHBOARD_JSON](#dashboard_json) | true | Poll a location for json files that contain dashboards | | [DASHBOARD_JSON_PATH](#dashboard_json_path) | /usr/share/grafana/dashboards | Location to scan for json dashboards | +| [PLUGINS_PATH](#plugins_path) | /var/lib/grafana/plugins | Path to where grafana can install plugins | +| [GF_INSTALL_PLUGINS](#gf_install_plugins) | no default | Pass the plugins as a comma seperated list | ## Development The provided `Makefile` has various targets to help support building and publishing new images into a kubernetes cluster. diff --git a/grafana/rootfs/usr/share/grafana/grafana.ini.tpl b/grafana/rootfs/usr/share/grafana/grafana.ini.tpl index b09079a..04d40a5 100644 --- a/grafana/rootfs/usr/share/grafana/grafana.ini.tpl +++ b/grafana/rootfs/usr/share/grafana/grafana.ini.tpl @@ -17,6 +17,11 @@ data = {{ default "/var/lib/grafana" .DATA_PATH }} # logs = {{ default "/var/log" .LOG_PATH }} +# +# Directory where grafana will automatically scan and look for plugins +# +plugins = {{ default "/var/lib/grafana/plugins" .PLUGINS_PATH }} + #################################### Server #################################### [server] # Protocol (http or https) diff --git a/grafana/rootfs/usr/share/grafana/start-grafana b/grafana/rootfs/usr/share/grafana/start-grafana index 863de74..90f8df1 100755 --- a/grafana/rootfs/usr/share/grafana/start-grafana +++ b/grafana/rootfs/usr/share/grafana/start-grafana @@ -26,6 +26,21 @@ echo "###########################################" cat /usr/share/grafana/grafana.ini echo "###########################################" echo "###########################################" + +GF_PATHS_PLUGINS=${PLUGINS_PATH:-"/var/lib/grafana/plugins"} +if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then + echo "Installing Grafana plugins..." + OLDIFS=$IFS + IFS=',' + for plugin in ${GF_INSTALL_PLUGINS}; do + echo "Installing ${plugin} ..." + grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${plugin} + echo "" + echo "Done installing ${plugin}" + done + IFS=$OLDIFS +fi + set -m echo "Starting Grafana in the background" exec /usr/sbin/grafana-server -config /usr/share/grafana/grafana.ini -homepath /usr/share/grafana &