Skip to content

Commit 6aa6d8c

Browse files
committed
feat(drycc-addons):add prometheus
1 parent d509ceb commit 6aa6d8c

31 files changed

Lines changed: 5252 additions & 0 deletions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright VMware, Inc.
2+
# SPDX-License-Identifier: APACHE-2.0
3+
4+
annotations:
5+
category: Analytics
6+
licenses: Apache-2.0
7+
apiVersion: v2
8+
appVersion: 2.47.0
9+
dependencies:
10+
- name: common
11+
repository: oci://registry.drycc.cc/charts
12+
tags:
13+
- drycc-common
14+
version: ~1.1.2
15+
description: Prometheus is an open source monitoring and alerting system. It enables sysadmins to monitor their infrastructures by collecting metrics from configured targets at given intervals.
16+
home: https://github.com/prometheus/prometheus
17+
icon: https://drycc.com/assets/stacks/prometheus/img/prometheus-stack-220x234.png
18+
keywords:
19+
- prometheus
20+
- monitoring
21+
maintainers:
22+
- name: Drycc
23+
url: https://github.com/drycc/charts
24+
name: prometheus
25+
sources:
26+
- https://github.com/drycc/containers/tree/main/drycc/prometheus
27+
- https://github.com/prometheus/prometheus
28+
- https://github.com/prometheus-community/helm-charts
29+
version: 0.2.3
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
CHART NAME: {{ .Chart.Name }}
2+
CHART VERSION: {{ .Chart.Version }}
3+
APP VERSION: {{ .Chart.AppVersion }}
4+
5+
** Please be patient while the chart is being deployed **
6+
7+
{{- if .Values.diagnosticMode.enabled }}
8+
The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:
9+
10+
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
11+
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}
12+
13+
Get the list of pods by executing:
14+
15+
kubectl get pods --namespace {{ include "common.names.namespace" . | quote }} -l app.kubernetes.io/instance={{ .Release.Name }}
16+
17+
Access the pod you want to debug by executing
18+
19+
kubectl exec --namespace {{ include "common.names.namespace" . | quote }} -ti <NAME OF THE POD> -- bash
20+
21+
In order to replicate the container startup scripts execute this command:
22+
23+
/opt/drycc/prometheus/bin/prometheus --config.file=/opt/drycc/prometheus/conf/prometheus.yml --storage.tsdb.path=/opt/drycc/prometheus/data --web.console.libraries=/opt/drycc/prometheus/conf/console_libraries --web.console.templates=/opt/drycc/prometheus/conf/consoles
24+
25+
{{- else }}
26+
27+
Prometheus can be accessed via port "{{ .Values.server.service.ports.http }}" on the following DNS name from within your cluster:
28+
29+
{{ template "common.names.fullname" . }}.{{ include "common.names.namespace" . }}.svc.cluster.local
30+
31+
To access Prometheus from outside the cluster execute the following commands:
32+
33+
{{- if .Values.server.ingress.enabled }}
34+
35+
You should be able to access your new Prometheus installation through
36+
37+
{{ ternary "https" "http" .Values.server.ingress.tls }}://{{ .Values.server.ingress.hostname }}
38+
39+
{{- else if contains "LoadBalancer" .Values.server.service.type }}
40+
41+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
42+
Watch the status with: 'kubectl get svc --namespace {{ include "common.names.namespace" . }} -w {{ template "common.names.fullname" . }}'
43+
44+
{{- $port:=.Values.server.service.ports.http | toString }}
45+
46+
export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.names.namespace" . }} {{ template "common.names.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
47+
echo "Prometheus URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.server.service.ports.http }}{{ end }}/"
48+
49+
{{- else if contains "ClusterIP" .Values.server.service.type }}
50+
51+
echo "Prometheus URL: http://127.0.0.1:9090/"
52+
kubectl port-forward --namespace {{ include "common.names.namespace" . }} svc/{{ template "common.names.fullname" . }} 9090:{{ .Values.server.service.ports.http }}
53+
54+
{{- else if contains "NodePort" .Values.server.service.type }}
55+
56+
export NODE_PORT=$(kubectl get --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "common.names.fullname" . }})
57+
export NODE_IP=$(kubectl get nodes --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
58+
echo "Prometheus URL: http://$NODE_IP:$NODE_PORT/"
59+
60+
{{- end }}
61+
62+
{{- if and .Values.server.thanos.create }}
63+
64+
Thanos Sidecar can be accessed via port "{{ .Values.server.thanos.service.ports.grpc }}" on the following DNS name from within your cluster:
65+
66+
{{ template "prometheus.thanos-sidecar.fullname" . }}.{{ include "common.names.namespace" . }}.svc.cluster.local
67+
68+
{{- if .Values.server.thanos.ingress.enabled }}
69+
70+
You should be able to access your new Thanos Sidecar installation through
71+
72+
{{ ternary "https" "http" .Values.server.thanos.ingress.tls }}://{{ .Values.server.thanos.ingress.hostname }}
73+
74+
{{- end }}
75+
{{- end }}
76+
{{- end }}
77+
78+
{{- if .Values.alertmanager.enabled }}
79+
80+
Watch the Alertmanager StatefulSet status using the command:
81+
82+
kubectl get sts -w --namespace {{ include "common.names.namespace" . }} -l app.kubernetes.io/name={{ template "prometheus.alertmanager.fullname" . }},app.kubernetes.io/instance={{ .Release.Name }}
83+
84+
Alertmanager can be accessed via port "{{ .Values.alertmanager.service.ports.http }}" on the following DNS name from within your cluster:
85+
86+
{{ template "prometheus.alertmanager.fullname" . }}.{{ include "common.names.namespace" . }}.svc.cluster.local
87+
88+
To access Alertmanager from outside the cluster execute the following commands:
89+
90+
{{- if .Values.alertmanager.ingress.enabled }}
91+
92+
You should be able to access your new Prometheus installation through
93+
94+
{{ ternary "https" "http" .Values.alertmanager.ingress.tls }}://{{ .Values.alertmanager.ingress.hostname }}
95+
96+
{{- else if contains "LoadBalancer" .Values.alertmanager.service.type }}
97+
98+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
99+
Watch the status with: 'kubectl get svc --namespace {{ include "common.names.namespace" . }} -w {{ template "prometheus.alertmanager.fullname" . }}'
100+
101+
{{- $port:=.Values.alertmanager.service.ports.http | toString }}
102+
103+
export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.names.namespace" . }} {{ template "prometheus.alertmanager.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
104+
echo "Alertmanager URL: http://$SERVICE_IP{{- if ne $port "80" }}:{{ .Values.alertmanager.service.ports.http }}{{ end }}/"
105+
106+
{{- else if contains "ClusterIP" .Values.alertmanager.service.type }}
107+
108+
echo "Alertmanager URL: http://127.0.0.1:9093/"
109+
kubectl port-forward --namespace {{ include "common.names.namespace" . }} svc/{{ template "prometheus.alertmanager.fullname" . }} 9093:{{ .Values.alertmanager.service.ports.http }}
110+
111+
{{- else if contains "NodePort" .Values.alertmanager.service.type }}
112+
113+
export NODE_PORT=$(kubectl get --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "prometheus.alertmanager.fullname" . }})
114+
export NODE_IP=$(kubectl get nodes --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
115+
echo "Alertmanager URL: http://$NODE_IP:$NODE_PORT/"
116+
117+
{{- end }}
118+
{{- end }}
119+
120+
{{- include "common.warnings.rollingTag" .Values.server.image }}
121+
{{- include "common.warnings.rollingTag" .Values.server.thanos.image }}
122+
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}
123+
{{- include "prometheus.server.validateValues" . }}
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
{{/*
2+
Copyright VMware, Inc.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
6+
{{/*
7+
Return the proper image name
8+
*/}}
9+
{{- define "prometheus.server.image" -}}
10+
{{ include "common.images.image" (dict "imageRoot" .Values.server.image "global" .Values.global) }}
11+
{{- end -}}
12+
13+
{{/*
14+
Return the proper image name
15+
*/}}
16+
{{- define "prometheus.alertmanager.image" -}}
17+
{{ include "common.images.image" (dict "imageRoot" .Values.alertmanager.image "global" .Values.global) }}
18+
{{- end -}}
19+
20+
{{/*
21+
Return the proper image name
22+
*/}}
23+
{{- define "prometheus.server.thanosImage" -}}
24+
{{ include "common.images.image" (dict "imageRoot" .Values.server.thanos.image "global" .Values.global) }}
25+
{{- end -}}
26+
27+
{{/*
28+
Return Prometheus server name
29+
*/}}
30+
{{- define "prometheus.server.fullname" -}}
31+
{{- printf "%s-server" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
32+
{{- end -}}
33+
34+
{{/*
35+
Return Prometheus server name
36+
*/}}
37+
{{- define "prometheus.server.fullname.namespace" -}}
38+
{{- printf "%s-server" (include "common.names.fullname.namespace" .) | trunc 63 | trimSuffix "-" }}
39+
{{- end -}}
40+
41+
{{/*
42+
Return the proper image name (for the init container volume-permissions image)
43+
*/}}
44+
{{- define "prometheus.volumePermissions.image" -}}
45+
{{- include "common.images.image" ( dict "imageRoot" .Values.volumePermissions.image "global" .Values.global ) -}}
46+
{{- end -}}
47+
48+
{{/*
49+
Return the proper Docker Image Registry Secret Names
50+
*/}}
51+
{{- define "prometheus.imagePullSecrets" -}}
52+
{{- include "common.images.pullSecrets" (dict "images" (list .Values.server.image .Values.volumePermissions.image .Values.server.thanos.image .Values.alertmanager.image) "global" .Values.global) -}}
53+
{{- end -}}
54+
55+
{{/*
56+
Create the name of the service account to use
57+
*/}}
58+
{{- define "prometheus.server.serviceAccountName" -}}
59+
{{- if .Values.server.serviceAccount.create -}}
60+
{{ default (include "prometheus.server.fullname" .) .Values.server.serviceAccount.name }}
61+
{{- else -}}
62+
{{ default "default" .Values.server.serviceAccount.name }}
63+
{{- end -}}
64+
{{- end -}}
65+
66+
{{/*
67+
Compile all warnings into a single message.
68+
*/}}
69+
{{- define "prometheus.server.validateValues" -}}
70+
{{- $messages := list -}}
71+
{{- $messages := append $messages (include "prometheus.server.validateValues.thanosObjectStorageConfig" .) -}}
72+
{{- $messages := without $messages "" -}}
73+
{{- $message := join "\n" $messages -}}
74+
75+
{{- if $message -}}
76+
{{- printf "\nVALUES VALIDATION:\n%s" $message -}}
77+
{{- end -}}
78+
{{- end -}}
79+
80+
{{/*
81+
Validate thanos objectStorageConfig.
82+
*/}}
83+
{{- define "prometheus.server.validateValues.thanosObjectStorageConfig" -}}
84+
{{- if (and .Values.server.thanos.objectStorageConfig (or (not (hasKey .Values.server.thanos.objectStorageConfig "secretKey")) (not (hasKey .Values.server.thanos.objectStorageConfig "secretName")) ))}}
85+
{{- printf "'server.thanos.objectStorageConfig.secretKey' and 'server.thanos.objectStorageConfi.secretName' are mandatory" }}
86+
{{- end }}
87+
{{- end }}
88+
89+
{{/*
90+
Get the Prometheus configuration configmap.
91+
*/}}
92+
{{- define "prometheus.server.configmapName" -}}
93+
{{- if .Values.server.existingConfigmap -}}
94+
{{- include "common.tplvalues.render" (dict "value" .Values.server.existingConfigmap "context" .) -}}
95+
{{- else }}
96+
{{- include "prometheus.server.fullname" . -}}
97+
{{- end -}}
98+
{{- end -}}
99+
100+
{{/*
101+
Get the Prometheus configuration configmap key.
102+
*/}}
103+
{{- define "prometheus.server.configmapKey" -}}
104+
{{- if .Values.server.existingConfigmapKey -}}
105+
{{- include "common.tplvalues.render" (dict "value" .Values.server.existingConfigmapKey "context" .) -}}
106+
{{- else }}
107+
{{- printf "prometheus.yaml" -}}
108+
{{- end -}}
109+
{{- end -}}
110+
111+
{{/*
112+
Get the Prometheus Alertmanager configuration configmap key.
113+
*/}}
114+
{{- define "prometheus.alertmanager.configmapKey" -}}
115+
{{- if .Values.alertmanager.existingConfigmapKey -}}
116+
{{- include "common.tplvalues.render" (dict "value" .Values.alertmanager.existingConfigmapKey "context" .) -}}
117+
{{- else }}
118+
{{- printf "alertmanager.yaml" -}}
119+
{{- end -}}
120+
{{- end -}}
121+
122+
{{/*
123+
Create the name of the service account to use in alertmanager
124+
*/}}
125+
{{- define "prometheus.alertmanager.serviceAccountName" -}}
126+
{{- if .Values.alertmanager.serviceAccount.create -}}
127+
{{ default (include "prometheus.alertmanager.fullname" .) .Values.alertmanager.serviceAccount.name }}
128+
{{- else -}}
129+
{{ default "default" .Values.alertmanager.serviceAccount.name }}
130+
{{- end -}}
131+
{{- end -}}
132+
133+
{{/*
134+
Return Thanos sidecar service/ingress name
135+
*/}}
136+
{{- define "prometheus.thanos-sidecar.fullname" -}}
137+
{{- printf "%s-thanos" (include "common.names.fullname" .) }}
138+
{{- end -}}
139+
140+
{{/*
141+
Return Alertmanager name
142+
*/}}
143+
{{- define "prometheus.alertmanager.fullname" -}}
144+
{{- printf "%s-alertmanager" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }}
145+
{{- end -}}
146+
147+
{{/*
148+
Get the Alertmanager configuration configmap.
149+
*/}}
150+
{{- define "prometheus.alertmanager.configmapName" -}}
151+
{{- if .Values.alertmanager.existingConfigmap -}}
152+
{{- include "common.tplvalues.render" (dict "value" .Values.alertmanager.existingConfigmap "context" .) -}}
153+
{{- else }}
154+
{{- include "prometheus.alertmanager.fullname" . -}}
155+
{{- end -}}
156+
{{- end -}}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{{/*
2+
Copyright VMware, Inc.
3+
SPDX-License-Identifier: APACHE-2.0
4+
*/}}
5+
6+
{{/*
7+
Return the prometheus scrape configuration for kubernetes objects.
8+
Usage:
9+
{{ include "prometheus.scrape_config" (dict "component" "alertmanager" "context" $) }}
10+
*/}}
11+
{{- define "prometheus.scrape_config" -}}
12+
kubernetes_sd_configs:
13+
- role: endpoints
14+
namespaces:
15+
names:
16+
- {{ include "common.names.namespace" .context }}
17+
metrics_path: /metrics
18+
relabel_configs:
19+
- source_labels:
20+
- job
21+
target_label: __tmp_prometheus_job_name
22+
- action: keep
23+
source_labels:
24+
- __meta_kubernetes_service_label_app_kubernetes_io_component
25+
- __meta_kubernetes_service_labelpresent_app_kubernetes_io_component
26+
regex: ({{ .component }});true
27+
- action: keep
28+
source_labels:
29+
- __meta_kubernetes_service_label_app_kubernetes_io_instance
30+
- __meta_kubernetes_service_labelpresent_app_kubernetes_io_instance
31+
regex: ({{ .context.Release.Name }});true
32+
- action: keep
33+
source_labels:
34+
- __meta_kubernetes_service_label_app_kubernetes_io_name
35+
- __meta_kubernetes_service_labelpresent_app_kubernetes_io_name
36+
regex: (prometheus);true
37+
- action: keep
38+
source_labels:
39+
- __meta_kubernetes_endpoint_port_name
40+
regex: http
41+
- source_labels:
42+
- __meta_kubernetes_endpoint_address_target_kind
43+
- __meta_kubernetes_endpoint_address_target_name
44+
separator: ;
45+
regex: Node;(.*)
46+
replacement: ${1}
47+
target_label: node
48+
- source_labels:
49+
- __meta_kubernetes_endpoint_address_target_kind
50+
- __meta_kubernetes_endpoint_address_target_name
51+
separator: ;
52+
regex: Pod;(.*)
53+
replacement: ${1}
54+
target_label: pod
55+
- source_labels:
56+
- __meta_kubernetes_namespace
57+
target_label: namespace
58+
- source_labels:
59+
- __meta_kubernetes_service_name
60+
target_label: service
61+
- source_labels:
62+
- __meta_kubernetes_pod_name
63+
target_label: pod
64+
- source_labels:
65+
- __meta_kubernetes_pod_container_name
66+
target_label: container
67+
- action: drop
68+
source_labels:
69+
- __meta_kubernetes_pod_phase
70+
regex: (Failed|Succeeded)
71+
- source_labels:
72+
- __meta_kubernetes_service_name
73+
target_label: job
74+
replacement: ${1}
75+
- target_label: endpoint
76+
replacement: http
77+
- source_labels:
78+
- __address__
79+
target_label: __tmp_hash
80+
modulus: 1
81+
action: hashmod
82+
- source_labels:
83+
- __tmp_hash
84+
regex: 0
85+
action: keep
86+
{{- end -}}

0 commit comments

Comments
 (0)