mirror of
https://github.com/stefanprodan/dockprom.git
synced 2025-05-05 23:42:51 +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"
|
org.label-schema.group: "monitoring"
|
||||||
|
|
||||||
grafana:
|
grafana:
|
||||||
image: grafana/grafana:6.3.6
|
image: grafana/grafana:6.5.0-beta1
|
||||||
container_name: grafana
|
container_name: grafana
|
||||||
volumes:
|
volumes:
|
||||||
- grafana_data:/var/lib/grafana
|
- grafana_data:/var/lib/grafana
|
||||||
- ./grafana/datasources:/etc/grafana/datasources
|
- ./grafana/provisioning:/etc/grafana/provisioning
|
||||||
- ./grafana/dashboards:/etc/grafana/dashboards
|
|
||||||
- ./grafana/setup.sh:/setup.sh
|
|
||||||
entrypoint: /setup.sh
|
|
||||||
environment:
|
environment:
|
||||||
- GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
|
- GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
|
||||||
- GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-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,
|
"id": null,
|
||||||
"title": "Docker Containers",
|
"title": "Docker Containers",
|
||||||
"description": "Containers metrics",
|
"description": "Containers metrics",
|
||||||
@ -1267,4 +1267,4 @@
|
|||||||
"version": 8,
|
"version": 8,
|
||||||
"links": [],
|
"links": [],
|
||||||
"gnetId": null
|
"gnetId": null
|
||||||
}}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
{"dashboard": {
|
{
|
||||||
"id": null,
|
"id": null,
|
||||||
"title": "Docker Host",
|
"title": "Docker Host",
|
||||||
"description": "Docker host metrics",
|
"description": "Docker host metrics",
|
||||||
@ -1438,4 +1438,4 @@
|
|||||||
"version": 2,
|
"version": 2,
|
||||||
"links": [],
|
"links": [],
|
||||||
"gnetId": null
|
"gnetId": null
|
||||||
}}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
{"dashboard": {
|
{
|
||||||
"id": null,
|
"id": null,
|
||||||
"title": "Monitor Services",
|
"title": "Monitor Services",
|
||||||
"tags": [
|
"tags": [
|
||||||
@ -3409,4 +3409,4 @@
|
|||||||
"version": 22,
|
"version": 22,
|
||||||
"links": [],
|
"links": [],
|
||||||
"gnetId": null
|
"gnetId": null
|
||||||
}}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
{"dashboard": {
|
{
|
||||||
"id": null,
|
"id": null,
|
||||||
"title": "Nginx",
|
"title": "Nginx",
|
||||||
"description": "Nginx exporter metrics",
|
"description": "Nginx exporter metrics",
|
||||||
@ -395,4 +395,4 @@
|
|||||||
"version": 9,
|
"version": 9,
|
||||||
"links": [],
|
"links": [],
|
||||||
"gnetId": null
|
"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