Browse Source

Déploiement d'un dashboard templatisé par défaut

tags/pkg/stable/eole-2.7.0/1.0.0-0
William Petit 5 months ago
parent
commit
7023209d9b
2 changed files with 19512 additions and 20065 deletions
  1. 0
    91
      postservice/88_grafana
  2. 19512
    19974
      tmpl/grafana-node-dashboard.json

+ 0
- 91
postservice/88_grafana View File

@@ -1,91 +0,0 @@
1
-#!/usr/bin/env bash
2
-
3
-
4
-function importDataSource()
5
-{
6
-    local grURL="${1}/api/datasources"  # Grafana API URL
7
-    local dsName=${2} # Datasource Name
8
-    local dsURL="${3}" # Datasource URL
9
-    local dsType="prometheus" # Datasource type
10
-
11
-    cmd="curl"
12
-
13
-
14
-    data=$(cat <<__EOF__
15
-{"name":"${dsName}","type":"${dsType}","url":"${dsURL}","access":"direct"}
16
-__EOF__
17
-    )
18
-
19
-    echo -ne "\tCreating datasource for Prometheus "
20
-    res=$(${cmd} "${grURL}" -H "Content-Type: application-json" --data-binary "${data}" 2>&1 )
21
-    excode=${?}
22
-    case $res in
23
-        *"already exists"*)
24
-            echo " ... [Exists]"
25
-            ;;
26
-        *"Datasource added"*)
27
-            echo " ... [OK]"
28
-            ;;
29
-        *)
30
-            echo " ... Ooops ${res}"
31
-            ;;
32
-    esac
33
-}
34
-
35
-function importDashboardFromMarket()
36
-{
37
-    local grURL="${1}/api/dashboards/import" # API URL to create new Dashboard
38
-    local dsName="${2}"                  # Datasource name (to link dashboard to data)
39
-    local dhID="${3}"                    # Dashboard ID in the market
40
-    local dhRev="${4}"                   # Dashboard Revision to download
41
-    local tmpFile=$(mktemp)
42
-    local dhFile=$(mktemp)
43
-
44
-    # URL To download the json file for dashboard
45
-    local pubDashBoardURL="https://grafana.com/api/dashboards/${dhID}/revisions/${dhRev}/download"
46
-
47
-    local cmd="curl"
48
-
49
-    local dh=$(${cmd} --silent ${pubDashBoardURL} 2>&1)
50
-
51
-    cat <<_EOF_ > ${tmpFile}
52
-{
53
-  "inputs": [ { "name":"DS_LOCALHOST", "type":"datasource", "pluginId":"prometheus", "value":"${dsName}" } ],
54
-  "dashboard": { "title": "Surveillance Système", ${dh:1:-1} },
55
-  "folderId": 0,
56
-  "overwrite": true
57
-}
58
-_EOF_
59
-
60
-    res=$(${cmd} "${grURL}" -H "Content-Type: application-json" --data-binary "@${tmpFile}" 2>&1 )
61
-    excode=${?}
62
-    case $res in
63
-        *"\"imported\":true"*)
64
-            echo " ... [Overwrited]"
65
-            ;;
66
-        *"Datasource added"*)
67
-            echo " ... [OK]"
68
-            ;;
69
-        *)
70
-            echo " ... Ooops ${res}"
71
-            ;;
72
-    esac
73
-#    rm -rf ${tmpFile}
74
-}
75
-
76
-grafanaHost=$(CreoleGet srvGrafanaIP 127.0.0.1)
77
-grafanaPort=$(CreoleGet srvGrafanaPort 3000)
78
-grafanaUser="admin"
79
-grafanaPasswd=$(CreoleGet grafana_admin_passwd admin)
80
-grafanaURL="http://${grafanaUser}:${grafanaPasswd}@${grafanaHost}:${grafanaPort}"
81
-datasource_name=$(CreoleGet promDataSource "prometheus")
82
-promHost=$(CreoleGet adresse_ip_eth0)
83
-promPort='9090'
84
-datasourceURL="http://${promHost}:${promPort}"
85
-
86
-importDataSource ${grafanaURL} ${datasource_name} ${datasourceURL}
87
-echo
88
-echo -ne "\tImporting Node Exporter Full Dashboard "
89
-importDashboardFromMarket ${grafanaURL} ${datasource_name} 1860 11
90
-
91
-rm -rf ${dashBoardFile}

+ 19512
- 19974
tmpl/grafana-node-dashboard.json
File diff suppressed because it is too large
View File


Loading…
Cancel
Save