Skip to content

Commit 503ca0e

Browse files
author
wuvs
committed
feat(grafana): allow user to install plugins
1 parent 26b9b4a commit 503ca0e

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

grafana/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100
| <a name="amqp_publisher_exchange"></a> [AMQP_PUBLISHER_EXCHANGE](#amqp_publisher_exchange) | no default | AMQP Publisher Exchange |
101101
| <a name="dashboard_json"></a> [DASHBOARD_JSON](#dashboard_json) | true | Poll a location for json files that contain dashboards |
102102
| <a name="dashboard_json_path"></a> [DASHBOARD_JSON_PATH](#dashboard_json_path) | /usr/share/grafana/dashboards | Location to scan for json dashboards |
103+
| <a name="plugins_path"></a> [PLUGINS_PATH](#plugins_path) | /var/lib/grafana/plugins | Path to where grafana can install plugins |
104+
| <a name="gf_install_plugins"></a> [GF_INSTALL_PLUGINS](#gf_install_plugins) | no default | Pass the plugins as a comma seperated list |
103105

104106
## Development
105107
The provided `Makefile` has various targets to help support building and publishing new images into a kubernetes cluster.

grafana/rootfs/usr/share/grafana/grafana.ini.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ data = {{ default "/var/lib/grafana" .DATA_PATH }}
1717
#
1818
logs = {{ default "/var/log" .LOG_PATH }}
1919

20+
#
21+
# Directory where grafana will automatically scan and look for plugins
22+
#
23+
plugins = {{ default "/var/lib/grafana/plugins" .PLUGINS_PATH }}
24+
2025
#################################### Server ####################################
2126
[server]
2227
# Protocol (http or https)

grafana/rootfs/usr/share/grafana/start-grafana

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ echo "###########################################"
2626
cat /usr/share/grafana/grafana.ini
2727
echo "###########################################"
2828
echo "###########################################"
29+
30+
GF_PATHS_PLUGINS=${PLUGINS_PATH:-"/var/lib/grafana/plugins"}
31+
if [ ! -z "${GF_INSTALL_PLUGINS}" ]; then
32+
echo "Installing Grafana plugins..."
33+
OLDIFS=$IFS
34+
IFS=','
35+
for plugin in ${GF_INSTALL_PLUGINS}; do
36+
echo "Installing ${plugin} ..."
37+
grafana-cli --pluginsDir "${GF_PATHS_PLUGINS}" plugins install ${plugin}
38+
echo ""
39+
echo "Done installing ${plugin}"
40+
done
41+
IFS=$OLDIFS
42+
fi
43+
2944
set -m
3045
echo "Starting Grafana in the background"
3146
exec /usr/sbin/grafana-server -config /usr/share/grafana/grafana.ini -homepath /usr/share/grafana &

0 commit comments

Comments
 (0)