Use a "local" command for configuring Grafana
Currently the grafana-configure.sh script is executed in a job. So if the Grafana Pod is re-created all the pre-configured Grafana dashboards are lost. This commit fixes the bug by using a "local" post command instead of a "single" post command for the execution of grafana-configure.sh. Change-Id: I9368b010da684ac7f2c352b920b7df1785fd0e78
This commit is contained in:
parent
c727f9c3fc
commit
07ff4d8544
|
@ -1,14 +1,14 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "Waiting for Grafana to come up..."
|
||||
until $(curl --fail --output /dev/null --silent http://{{ grafana_user }}:{{ grafana_password }}@{{ grafana_host }}:{{ grafana_port }}/api/org); do
|
||||
until $(curl --fail --output /dev/null --silent http://{{ grafana_user }}:{{ grafana_password }}@localhost:{{ grafana_port }}/api/org); do
|
||||
printf "."
|
||||
sleep 2
|
||||
done
|
||||
echo -e "Grafana is up and running.\n"
|
||||
|
||||
echo "Creating InfluxDB datasource..."
|
||||
curl -i -XPOST -H "Accept: application/json" -H "Content-Type: application/json" "http://{{ grafana_user }}:{{ grafana_password }}@{{ grafana_host }}:{{ grafana_port }}/api/datasources" -d '
|
||||
curl -i -XPOST -H "Accept: application/json" -H "Content-Type: application/json" "http://{{ grafana_user }}:{{ grafana_password }}@localhost:{{ grafana_port }}/api/datasources" -d '
|
||||
{
|
||||
"name": "CCP InfluxDB",
|
||||
"type": "influxdb",
|
||||
|
@ -28,7 +28,7 @@ echo -e "InfluxDB datasource was successfully created.\n"
|
|||
echo "Importing default dashboards..."
|
||||
for dashboard in /dashboards/*.json; do
|
||||
echo -e "\tImporting ${dashboard}..."
|
||||
curl -i -XPOST --data "@${dashboard}" -H "Accept: application/json" -H "Content-Type: application/json" "http://{{ grafana_user }}:{{ grafana_password}}@{{ grafana_host }}:{{ grafana_port }}/api/dashboards/db"
|
||||
curl -i -XPOST --data "@${dashboard}" -H "Accept: application/json" -H "Content-Type: application/json" "http://{{ grafana_user }}:{{ grafana_password}}@localhost:{{ grafana_port }}/api/dashboards/db"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error importing ${dashboard}"
|
||||
exit 1
|
||||
|
|
|
@ -10,12 +10,12 @@ service:
|
|||
liveness: "true"
|
||||
daemon:
|
||||
command: /usr/sbin/grafana-server --homepath=/usr/share/grafana --config=/etc/grafana/grafana.ini cfg:default.paths.data=/var/lib/grafana cfg:default.paths.logs=/var/log/grafana
|
||||
files:
|
||||
- grafana-configure.sh
|
||||
post:
|
||||
- name: grafana-configure
|
||||
type: single
|
||||
type: local
|
||||
command: /opt/ccp/bin/grafana-configure.sh
|
||||
files:
|
||||
- grafana-configure.sh
|
||||
volumes:
|
||||
- name: grafana-data
|
||||
type: empty-dir
|
||||
|
|
Loading…
Reference in New Issue