Merge changes I1efdc490,I220d90d3,I405f09f7,I392b2ddf,I84062d6e

* changes:
  Relabel the instance label for prometheus and loki metrics
  Add dashboard for Loki metrics
  Add dashboard to monitor Prometheus data
  Only show Gerrit instances in the instance dropdowns
  Create a configmap per dashboard
This commit is contained in:
Thomas Dräbing 2020-04-08 13:17:58 +00:00 committed by Gerrit Code Review
commit b34c47f817
11 changed files with 6624 additions and 41 deletions

View file

@ -339,20 +339,7 @@ notifiers: {}
##
## `path` must be /var/lib/grafana/dashboards/<provider_name>
##
dashboardProviders:
dashboardproviders.yaml:
apiVersion: 1
providers:
- name: 'gerrit'
orgId: 1
folder: ''
type: file
disableDeletion: true
editable: #@ data.values.grafana.dashboards.editable
updateIntervalSeconds: 60
allowUiUpdates: #@ data.values.grafana.dashboards.editable
options:
path: /var/lib/grafana/dashboards/gerrit
dashboardProviders: {}
## Configure grafana dashboard to import
## NOTE: To use dashboards you must also enable/configure dashboardProviders
@ -385,8 +372,7 @@ dashboards: {}
## example-dashboard.json: |
## RAW_JSON
##
dashboardsConfigMaps:
gerrit: "grafana-dashboards"
dashboardsConfigMaps: {}
## Grafana's primary configuration
## NOTE: values in map will be converted to ini format
@ -461,14 +447,14 @@ sidecar:
# skipTlsVerify Set to true to skip tls verification for kube api calls
# skipTlsVerify: true
dashboards:
enabled: false
enabled: true
## Method to use to detect ConfigMap changes. With WATCH the sidecar will do a WATCH requests, with SLEEP it will list all ConfigMaps, then sleep for 60 seconds.
watchMethod: WATCH
SCProvider: true
# label that the configmaps with dashboards are marked with
label: grafana_dashboard
# folder in the pod that should hold the collected dashboards (unless `defaultFolderName` is set)
folder: /tmp/dashboards
folder: /var/dashboards
# The default folder name, it will create a subfolder under the `folder` and put dashboards in there instead
defaultFolderName: null
# If specified, the sidecar will search for dashboard config-maps inside this namespace.
@ -486,9 +472,9 @@ sidecar:
# type of the provider
type: file
# disableDelete to activate a import-only behaviour
disableDelete: false
disableDelete: true
# allow updating provisioned dashboards from the UI
allowUiUpdates: false
allowUiUpdates: #@ data.values.grafana.dashboards.editable
datasources:
enabled: false
## Method to use to detect ConfigMap changes. With WATCH the sidecar will do a WATCH requests, with SLEEP it will list all ConfigMaps, then sleep for 60 seconds.

View file

@ -1149,10 +1149,20 @@ serverFiles:
static_configs:
- targets:
- localhost:9090
relabel_configs:
- source_labels: ["__address__"]
regex: ".*"
target_label: instance
replacement: #@ "prometheus-{}".format(data.values.namespace)
- job_name: loki
static_configs:
- targets:
- #@ "loki-{}.{}.svc.cluster.local:3100".format(data.values.namespace, data.values.namespace)
relabel_configs:
- source_labels: ["__address__"]
regex: ".*"
target_label: instance
replacement: #@ "loki-{}".format(data.values.namespace)
# A scrape configuration for running Prometheus on a Kubernetes cluster.
# This uses separate scrape configs for cluster components (i.e. API server, node)

View file

@ -638,14 +638,14 @@
"value": ""
},
"datasource": "Prometheus",
"definition": "label_values(instance)",
"definition": "label_values(git_upload_pack_phase_writing_total, instance)",
"hide": 0,
"includeAll": false,
"label": "Gerrit Instance",
"multi": false,
"name": "instance",
"options": [],
"query": "label_values(instance)",
"query": "label_values(git_upload_pack_phase_writing_total, instance)",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
@ -680,4 +680,4 @@
"title": "Caches",
"uid": "vHQVaGsWk",
"version": 15
}
}

View file

@ -421,14 +421,14 @@
"value": ""
},
"datasource": "Prometheus",
"definition": "label_values(instance)",
"definition": "label_values(git_upload_pack_phase_writing_total, instance)",
"hide": 0,
"includeAll": false,
"label": "Gerrit Instance",
"multi": false,
"name": "instance",
"options": [],
"query": "label_values(instance)",
"query": "label_values(git_upload_pack_phase_writing_total, instance)",
"refresh": 1,
"regex": "",
"skipUrlSync": false,

View file

@ -1161,14 +1161,14 @@
"value": ""
},
"datasource": "Prometheus",
"definition": "label_values(instance)",
"definition": "label_values(git_upload_pack_phase_writing_total, instance)",
"hide": 0,
"includeAll": false,
"label": "Gerrit Instance",
"multi": false,
"name": "instance",
"options": [],
"query": "label_values(instance)",
"query": "label_values(git_upload_pack_phase_writing_total, instance)",
"refresh": 1,
"regex": "",
"skipUrlSync": false,

View file

@ -722,14 +722,14 @@
"value": ""
},
"datasource": "Prometheus",
"definition": "label_values(instance)",
"definition": "label_values(git_upload_pack_phase_writing_total, instance)",
"hide": 0,
"includeAll": false,
"label": "Gerrit Instance",
"multi": false,
"name": "instance",
"options": [],
"query": "label_values(instance)",
"query": "label_values(git_upload_pack_phase_writing_total, instance)",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
@ -764,4 +764,4 @@
"title": "Process",
"uid": "MeOVgCPWz",
"version": 4
}
}

View file

@ -1062,14 +1062,14 @@
"value": ""
},
"datasource": "Prometheus",
"definition": "label_values(instance)",
"definition": "label_values(git_upload_pack_phase_writing_total, instance)",
"hide": 0,
"includeAll": false,
"label": "Gerrit Instance",
"multi": false,
"name": "instance",
"options": [],
"query": "label_values(instance)",
"query": "label_values(git_upload_pack_phase_writing_total, instance)",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
@ -1104,4 +1104,4 @@
"title": "Queues",
"uid": "Zh_ncGsWk",
"version": 5
}
}

View file

@ -207,14 +207,14 @@
"value": ""
},
"datasource": "Prometheus",
"definition": "label_values(instance)",
"definition": "label_values(git_upload_pack_phase_writing_total, instance)",
"hide": 0,
"includeAll": false,
"label": "Gerrit Instance",
"multi": false,
"name": "instance",
"options": [],
"query": "label_values(instance)",
"query": "label_values(git_upload_pack_phase_writing_total, instance)",
"refresh": 1,
"regex": "",
"skipUrlSync": false,

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -74,6 +74,23 @@ function addHtpasswdEntryEncrypted() {
sops --set "$COMPONENT['htpasswd'] \"$HTPASSWD\"" $TMP_CONFIG
}
function addDashboards() {
for dashboard in dashboards/*; do
local DASHBOARD_NAME="${dashboard%.json}"
local DASHBOARD_NAME="${DASHBOARD_NAME#"dashboards/"}"
kubectl create configmap $DASHBOARD_NAME \
--from-file=$dashboard \
--dry-run=true \
--namespace=$NAMESPACE \
-o yaml > $OUTPUT/dashboards/$DASHBOARD_NAME.dashboard.yaml
yq w -i $OUTPUT/dashboards/$DASHBOARD_NAME.dashboard.yaml \
metadata.labels.grafana_dashboard $DASHBOARD_NAME
done
}
function runYtt() {
ytt \
-f charts/namespace.yaml \
@ -100,18 +117,16 @@ else
echo -e "#@data/values\n---\n$(sops -d $TMP_CONFIG)" | runYtt -
fi
# Create configmap with dashboards
kubectl create configmap grafana-dashboards \
--from-file=./dashboards \
--dry-run=true \
--namespace=$NAMESPACE \
-o yaml > $OUTPUT/configuration/dashboards.cm.yaml
# Create configmaps with dashboards
mkdir -p $OUTPUT/dashboards
addDashboards
test -n "$DRYRUN" && exit 0
# Install loose components
kubectl apply -f $OUTPUT/namespace.yaml
kubectl apply -f $OUTPUT/configuration
kubectl apply -f $OUTPUT/dashboardsq
kubectl apply -f $OUTPUT/storage
# Add Loki helm repository