Update grafana to v6.5.0-beta1 and utilise provisioning system

This commit is contained in:
Amir Zarrinkafsh 2019-11-18 21:15:07 +11:00
parent 30e13842ff
commit f6aec3bfaa
No known key found for this signature in database
GPG Key ID: ECDB8EF9E77E4EBF
9 changed files with 33 additions and 102 deletions

View File

@ -85,14 +85,11 @@ services:
org.label-schema.group: "monitoring"
grafana:
image: grafana/grafana:6.3.6
image: grafana/grafana:6.5.0-beta1
container_name: grafana
volumes:
- grafana_data:/var/lib/grafana
- ./grafana/datasources:/etc/grafana/datasources
- ./grafana/dashboards:/etc/grafana/dashboards
- ./grafana/setup.sh:/setup.sh
entrypoint: /setup.sh
- ./grafana/provisioning:/etc/grafana/provisioning
environment:
- GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}

View File

@ -1,7 +0,0 @@
{
"name":"Prometheus",
"type":"prometheus",
"url":"http://prometheus:9090",
"access":"proxy",
"basicAuth":false
}

View File

@ -0,0 +1,12 @@
apiVersion: 1
providers:
- name: 'Prometheus'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
allowUiUpdates: true
options:
path: /etc/grafana/provisioning/dashboards

View File

@ -1,4 +1,4 @@
{"dashboard": {
{
"id": null,
"title": "Docker Containers",
"description": "Containers metrics",
@ -1267,4 +1267,4 @@
"version": 8,
"links": [],
"gnetId": null
}}
}

View File

@ -1,4 +1,4 @@
{"dashboard": {
{
"id": null,
"title": "Docker Host",
"description": "Docker host metrics",
@ -1438,4 +1438,4 @@
"version": 2,
"links": [],
"gnetId": null
}}
}

View File

@ -1,4 +1,4 @@
{"dashboard": {
{
"id": null,
"title": "Monitor Services",
"tags": [
@ -3409,4 +3409,4 @@
"version": 22,
"links": [],
"gnetId": null
}}
}

View File

@ -1,4 +1,4 @@
{"dashboard": {
{
"id": null,
"title": "Nginx",
"description": "Nginx exporter metrics",
@ -395,4 +395,4 @@
"version": 9,
"links": [],
"gnetId": null
}}
}

View File

@ -0,0 +1,11 @@
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
orgId: 1
url: http://prometheus:9090
basicAuth: false
isDefault: true
editable: true

View File

@ -1,82 +0,0 @@
#!/bin/bash
# Taken from https://github.com/grafana/grafana-docker/issues/74
# Script to configure grafana datasources and dashboards.
# Intended to be run before grafana entrypoint...
# Image: grafana/grafana:4.1.2
# ENTRYPOINT [\"/run.sh\"]"
GRAFANA_URL=${GRAFANA_URL:-http://$GF_SECURITY_ADMIN_USER:$GF_SECURITY_ADMIN_PASSWORD@localhost:3000}
#GRAFANA_URL=http://grafana-plain.k8s.playground1.aws.ad.zopa.com
DATASOURCES_PATH=${DATASOURCES_PATH:-/etc/grafana/datasources}
DASHBOARDS_PATH=${DASHBOARDS_PATH:-/etc/grafana/dashboards}
# Generic function to call the Vault API
grafana_api() {
local verb=$1
local url=$2
local params=$3
local bodyfile=$4
local response
local cmd
cmd="curl -L -s --fail -H \"Accept: application/json\" -H \"Content-Type: application/json\" -X ${verb} -k ${GRAFANA_URL}${url}"
[[ -n "${params}" ]] && cmd="${cmd} -d \"${params}\""
[[ -n "${bodyfile}" ]] && cmd="${cmd} --data @${bodyfile}"
echo "Running ${cmd}"
eval ${cmd} || return 1
return 0
}
wait_for_api() {
while ! grafana_api GET /api/user/preferences
do
sleep 5
done
}
install_datasources() {
local datasource
for datasource in ${DATASOURCES_PATH}/*.json
do
if [[ -f "${datasource}" ]]; then
echo "Installing datasource ${datasource}"
if grafana_api POST /api/datasources "" "${datasource}"; then
echo "installed ok"
else
echo "install failed"
fi
fi
done
}
install_dashboards() {
local dashboard
for dashboard in ${DASHBOARDS_PATH}/*.json
do
if [[ -f "${dashboard}" ]]; then
echo "Installing dashboard ${dashboard}"
if grafana_api POST /api/dashboards/db "" "${dashboard}"; then
echo "installed ok"
else
echo "install failed"
fi
fi
done
}
configure_grafana() {
wait_for_api
install_datasources
install_dashboards
}
echo "Running configure_grafana in the background..."
configure_grafana &
/run.sh
exit 0