diff --git a/deploy.sh b/deploy.sh index 472b59753637925008462be7d0ef9cb005f355d8..4d79635e12a544a21a0c7f86f96694fc05c923a7 100755 --- a/deploy.sh +++ b/deploy.sh @@ -224,6 +224,8 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring" # Updated Grafana API URL GRAFANA_URL_UPDATED="http://${GRAFANA_USERNAME}:${TFS_GRAFANA_PASSWORD}@${GRAFANA_HOSTNAME}:${GRAFANA_PORT}${GRAFANA_BASEURL}" + echo "export GRAFANA_URL_UPDATED=${GRAFANA_URL_UPDATED}" >> $ENV_VARS_SCRIPT + echo "Connecting to grafana at URL: ${GRAFANA_URL_DEFAULT}..." # Configure Grafana Admin Password @@ -239,22 +241,30 @@ if [[ "$TFS_COMPONENTS" == *"webui"* ]] && [[ "$TFS_COMPONENTS" == *"monitoring" # TODO: replace user, password and database by variables to be saved echo "Creating a datasource..." curl -X POST -H "Content-Type: application/json" -H "Accept: application/json" -d '{ + "access" : "proxy", "type" : "postgres", "name" : "monitoringdb", - "access" : "proxy", + "url" : "monitoringservice:8812", + "database" : "monitoring", "user" : "admin", "password" : "quest", + "basicAuth" : false, "isDefault": true, - "database" : "qdb", - "sslmode" :"disable" + "jsonData" : { + "sslmode" : "disable", + "postgresVersion" : 1100 + }, + "secureJsonFields" : { + "password" : true + } }' ${GRAFANA_URL_UPDATED}/api/datasources echo # Create Monitoring Dashboard # Ref: https://grafana.com/docs/grafana/latest/http_api/dashboard/ curl -X POST -H "Content-Type: application/json" \ - -d '@src/webui/grafana_dashboard.json' \ - ${GRAFANA_URL_UPDATED}/api/dashboards/db + -d '@src/webui/grafana_dashboard.json' \ + ${GRAFANA_URL_UPDATED}/api/dashboards/db echo DASHBOARD_URL="${GRAFANA_URL_UPDATED}/api/dashboards/uid/tf-l3-monit" diff --git a/scripts/show_logs_monitoring.sh b/scripts/show_logs_monitoring.sh index bd37d0d142f76d532219f1dcdcbd229914d3b0b5..520a9da1c652553eb90acd083caf5724275f4efe 100755 --- a/scripts/show_logs_monitoring.sh +++ b/scripts/show_logs_monitoring.sh @@ -24,4 +24,4 @@ export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} # Automated steps start here ######################################################################################################################## -kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/monitoringservice -c server +kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/monitoringserver diff --git a/src/webui/grafana_dashboard.json b/src/webui/grafana_dashboard.json index a845ac20c7861b86fd1931452b7802b3f1e57aa8..49148825a973aecca5901ffac2249fed6057f4d0 100644 --- a/src/webui/grafana_dashboard.json +++ b/src/webui/grafana_dashboard.json @@ -193,19 +193,19 @@ "tags": [ { "key": "device_id", - "operator": "=~", + "operator": "=", "value": "/^$device_id$/" }, { "condition": "AND", "key": "endpoint_id", - "operator": "=~", + "operator": "=", "value": "/^$endpoint_id$/" }, { "condition": "AND", "key": "kpi_sample_type", - "operator": "=~", + "operator": "=", "value": "/^$kpi_sample_type$/" } ] @@ -236,7 +236,7 @@ ] }, "datasource": null, - "definition": "SHOW TAG VALUES FROM samples WITH KEY=\"device_id\"", + "definition": "SELECT DISTINCT device_id FROM monitoring;", "description": null, "error": null, "hide": 0, @@ -245,7 +245,7 @@ "multi": true, "name": "device_id", "options": [], - "query": "SHOW TAG VALUES FROM samples WITH KEY=\"device_id\"", + "query": "SELECT DISTINCT device_id FROM monitoring;", "refresh": 2, "regex": "", "skipUrlSync": false, @@ -264,7 +264,7 @@ ] }, "datasource": null, - "definition": "SHOW TAG VALUES FROM samples WITH KEY=\"endpoint_id\" WHERE \"device_id\"=~/^$device_id$/", + "definition": "SELECT DISTINCT endpoint_id FROM monitoring WHERE device_id IN (${device_id})", "description": null, "error": null, "hide": 0, @@ -273,7 +273,7 @@ "multi": true, "name": "endpoint_id", "options": [], - "query": "SHOW TAG VALUES FROM samples WITH KEY=\"endpoint_id\" WHERE \"device_id\"=~/^$device_id$/", + "query": "SELECT DISTINCT endpoint_id FROM monitoring WHERE device_id IN (${device_id})", "refresh": 2, "regex": "", "skipUrlSync": false, @@ -292,7 +292,7 @@ ] }, "datasource": null, - "definition": "SHOW TAG VALUES FROM samples WITH KEY=\"kpi_sample_type\"", + "definition": "SELECT DISTINCT kpi_sample_type FROM monitoring;", "description": null, "error": null, "hide": 0, @@ -301,7 +301,7 @@ "multi": true, "name": "kpi_sample_type", "options": [], - "query": "SHOW TAG VALUES FROM samples WITH KEY=\"kpi_sample_type\"", + "query": "SELECT DISTINCT kpi_sample_type FROM monitoring;", "refresh": 2, "regex": "", "skipUrlSync": false,