mirror of
https://github.com/stefanprodan/dockprom.git
synced 2025-05-05 15:32:50 +00:00
Update grafana to v6.5.0-beta1 and utilise provisioning system
This commit is contained in:
parent
30e13842ff
commit
f6aec3bfaa
@ -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}
|
||||
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"name":"Prometheus",
|
||||
"type":"prometheus",
|
||||
"url":"http://prometheus:9090",
|
||||
"access":"proxy",
|
||||
"basicAuth":false
|
||||
}
|
12
grafana/provisioning/dashboards/dashboard.yml
Normal file
12
grafana/provisioning/dashboards/dashboard.yml
Normal 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
|
@ -1,4 +1,4 @@
|
||||
{"dashboard": {
|
||||
{
|
||||
"id": null,
|
||||
"title": "Docker Containers",
|
||||
"description": "Containers metrics",
|
||||
@ -1267,4 +1267,4 @@
|
||||
"version": 8,
|
||||
"links": [],
|
||||
"gnetId": null
|
||||
}}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
{"dashboard": {
|
||||
{
|
||||
"id": null,
|
||||
"title": "Docker Host",
|
||||
"description": "Docker host metrics",
|
||||
@ -1438,4 +1438,4 @@
|
||||
"version": 2,
|
||||
"links": [],
|
||||
"gnetId": null
|
||||
}}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
{"dashboard": {
|
||||
{
|
||||
"id": null,
|
||||
"title": "Monitor Services",
|
||||
"tags": [
|
||||
@ -3409,4 +3409,4 @@
|
||||
"version": 22,
|
||||
"links": [],
|
||||
"gnetId": null
|
||||
}}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
{"dashboard": {
|
||||
{
|
||||
"id": null,
|
||||
"title": "Nginx",
|
||||
"description": "Nginx exporter metrics",
|
||||
@ -395,4 +395,4 @@
|
||||
"version": 9,
|
||||
"links": [],
|
||||
"gnetId": null
|
||||
}}
|
||||
}
|
11
grafana/provisioning/datasources/datasource.yml
Normal file
11
grafana/provisioning/datasources/datasource.yml
Normal 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
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user