forked from hashicorp/consul
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create templates for grafana and prometheus (hashicorp#802)
* Create templates for grafana and prometheus
- Loading branch information
1 parent
0532464
commit c39b731
Showing
9 changed files
with
2,868 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env bash | ||
|
||
WD=$(dirname "$0") | ||
WD=$(cd "$WD"; pwd) | ||
|
||
set -eux | ||
|
||
TEMPLATES="${WD}/../templates" | ||
DASHBOARDS="${WD}/dashboards" | ||
TMP=$(mktemp -d) | ||
|
||
# create Prometheus template | ||
helm template prometheus prometheus \ | ||
--repo https://prometheus-community.github.io/helm-charts \ | ||
--namespace "replace-me-namespace" \ | ||
--version 13.2.1 \ | ||
-f "${WD}/values/prometheus.yaml" \ | ||
> "${TEMPLATES}/prometheus.yaml" | ||
|
||
# Find and replace `replace-me-namespace` with `{{ .Release.Namespace }}` in Prometheus template. | ||
sed -i'.orig' 's/replace-me-namespace/{{ .Release.Namespace }}/g' "${TEMPLATES}/prometheus.yaml" | ||
# Add a comment to the top of the template file mentioning that the file is auto-generated. | ||
sed -i'.orig' '1i\ | ||
# This file is auto-generated, see addons/gen.sh | ||
' "${TEMPLATES}/prometheus.yaml" | ||
# Add `{{- if .Values.prometheus.enabled }} to the top of the Prometheus template to ensure it is only templated when enabled. | ||
sed -i'.orig' '1i\ | ||
{{- if .Values.prometheus.enabled }} | ||
' "${TEMPLATES}/prometheus.yaml" | ||
# Add `{{- end }} to the bottom of the Prometheus template to ensure it is only templated when enabled (closes the `if` statement). | ||
sed -i'.orig' -e '$a\ | ||
{{- end }}' "${TEMPLATES}/prometheus.yaml" | ||
# Remove the `prometheus.yaml.orig` file that is created as a side-effect of the `sed` command on OS X. | ||
rm "${TEMPLATES}/prometheus.yaml.orig" | ||
|
||
# create Grafana template | ||
{ | ||
helm template grafana grafana \ | ||
--repo https://grafana.github.io/helm-charts \ | ||
--namespace "replace-me-namespace" \ | ||
--version 6.2.1 \ | ||
-f "${WD}/values/grafana.yaml" | ||
|
||
# Set up grafana dashboards and reduce to a single line json to avoid Kubernetes size limits of 1MiB. | ||
< "${DASHBOARDS}/consul-server-monitoring.json" jq -c > "${TMP}/consul-server-monitoring.json" | ||
echo -e "\n---\n" | ||
kubectl create configmap -n "replace-me-namespace" consul-grafana-dashboards \ | ||
--dry-run=client -oyaml \ | ||
--from-file=consul-server-monitoring.json="${TMP}/consul-server-monitoring.json" | ||
|
||
} > "${TEMPLATES}/grafana.yaml" | ||
|
||
# Find and replace `replace-me-namespace` with `{{ .Release.Namespace }}` in Grafana template. | ||
sed -i'.orig' 's/replace-me-namespace/{{ .Release.Namespace }}/g' "${TEMPLATES}/grafana.yaml" | ||
# Add a comment to the top of the template file mentioning that the file is auto-generated. | ||
sed -i'.orig' '1i\ | ||
# This file is auto-generated, see addons/gen.sh | ||
' "${TEMPLATES}/grafana.yaml" | ||
# Add `{{- if .Values.grafana.enabled }} to the top of the Grafana template to ensure it is only templated when enabled. | ||
sed -i'.orig' '1i\ | ||
{{- if .Values.grafana.enabled }} | ||
' "${TEMPLATES}/grafana.yaml" | ||
# Add `{{- end }} to the bottom of the Grafana template to ensure it is only templated when enabled (closes the `if` statement). | ||
sed -i'.orig' -e '$a\ | ||
{{- end }}' "${TEMPLATES}/grafana.yaml" | ||
# Remove the `grafana.yaml.orig` file that is created as a side-effect of the `sed` command on OS X. | ||
rm "${TEMPLATES}/grafana.yaml.orig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
rbac: | ||
create: false | ||
pspEnabled: false | ||
|
||
# Disable test pods | ||
testFramework: | ||
enabled: false | ||
|
||
podLabels: | ||
app: grafana | ||
|
||
podAnnotations: | ||
"consul.hashicorp.com/connect-inject": "false" | ||
|
||
# Disable authentication | ||
admin: | ||
existingSecret: true | ||
ldap: | ||
existingSecret: true | ||
env: | ||
GF_SECURITY_ADMIN_USER: "-" | ||
GF_SECURITY_ADMIN_PASSWORD: "-" | ||
GF_AUTH_BASIC_ENABLED: "false" | ||
GF_AUTH_ANONYMOUS_ENABLED: "true" | ||
GF_AUTH_ANONYMOUS_ORG_ROLE: Admin | ||
|
||
service: | ||
port: 3000 | ||
|
||
# Setup dashboards | ||
dashboardProviders: | ||
dashboardproviders.yaml: | ||
apiVersion: 1 | ||
providers: | ||
- name: 'consul' | ||
orgId: 1 | ||
folder: 'consul' | ||
type: file | ||
disableDeletion: false | ||
options: | ||
path: /var/lib/grafana/dashboards/consul | ||
|
||
dashboardsConfigMaps: | ||
consul: "consul-grafana-dashboards" | ||
|
||
# Configure the prometheus data source. We expect prometheus:9090 in the same namespace. | ||
datasources: | ||
datasources.yaml: | ||
apiVersion: 1 | ||
datasources: | ||
- name: Prometheus | ||
type: prometheus | ||
orgId: 1 | ||
url: http://prometheus:9090 | ||
access: proxy | ||
isDefault: true | ||
jsonData: | ||
timeInterval: 5s | ||
editable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Disable non-essential components | ||
alertmanager: | ||
enabled: false | ||
pushgateway: | ||
enabled: false | ||
kubeStateMetrics: | ||
enabled: false | ||
nodeExporter: | ||
enabled: false | ||
server: | ||
podAnnotations: | ||
"consul.hashicorp.com/connect-inject": "false" | ||
persistentVolume: | ||
enabled: false | ||
service: | ||
servicePort: 9090 | ||
readinessProbeInitialDelay: 0 | ||
# Speed up scraping a bit from the default | ||
global: | ||
scrape_interval: 15s | ||
fullnameOverride: prometheus |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.