This is an automated email from the ASF dual-hosted git repository.
zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-helm-chart.git
The following commit(s) were added to refs/heads/master by this push:
new d047b3a feat(apisix): add service monitor support (#192)
d047b3a is described below
commit d047b3a16e4a918673fd75bbcb2a5029658ce56a
Author: Gallardot <[email protected]>
AuthorDate: Thu Dec 9 17:13:48 2021 +0800
feat(apisix): add service monitor support (#192)
Co-authored-by: Haili Zhang <[email protected]>
---
charts/apisix/templates/configmap.yaml | 9 +++++-
charts/apisix/templates/deployment.yaml | 5 ++++
charts/apisix/templates/servicemonitor.yaml | 43 +++++++++++++++++++++++++++++
charts/apisix/values.yaml | 17 ++++++++++++
4 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/charts/apisix/templates/configmap.yaml
b/charts/apisix/templates/configmap.yaml
index 3ee538d..d01c8fb 100644
--- a/charts/apisix/templates/configmap.yaml
+++ b/charts/apisix/templates/configmap.yaml
@@ -238,8 +238,15 @@ data:
- {{ $plugin }}
{{- end }}
- {{- if or .Values.pluginAttrs .Values.customPlugins.enabled }}
+ {{- if or .Values.pluginAttrs .Values.customPlugins.enabled
.Values.serviceMonitor.enabled}}
plugin_attr:
+ {{- if .Values.serviceMonitor.enabled }}
+ prometheus:
+ export_addr:
+ ip: 0.0.0.0
+ port: {{ .Values.serviceMonitor.containerPort }}
+ export_uri: {{ .Values.serviceMonitor.path }}
+ {{- end }}
{{- if .Values.customPlugins.enabled }}
{{- range $plugin := .Values.customPlugins.plugins }}
{{ $plugin.name }}: {{- $plugin.attrs | toYaml | nindent 8 }}
diff --git a/charts/apisix/templates/deployment.yaml
b/charts/apisix/templates/deployment.yaml
index 610a609..c1e7abb 100644
--- a/charts/apisix/templates/deployment.yaml
+++ b/charts/apisix/templates/deployment.yaml
@@ -63,6 +63,11 @@ spec:
containerPort: {{ .Values.admin.port }}
protocol: TCP
{{- end }}
+ {{- if .Values.serviceMonitor.enabled }}
+ - name: prometheus
+ containerPort: {{ .Values.serviceMonitor.containerPort }}
+ protocol: TCP
+ {{- end }}
readinessProbe:
failureThreshold: 6
initialDelaySeconds: 10
diff --git a/charts/apisix/templates/servicemonitor.yaml
b/charts/apisix/templates/servicemonitor.yaml
new file mode 100644
index 0000000..7fb1d29
--- /dev/null
+++ b/charts/apisix/templates/servicemonitor.yaml
@@ -0,0 +1,43 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+{{- if .Values.serviceMonitor.enabled }}
+apiVersion: monitoring.coreos.com/v1
+kind: ServiceMonitor
+metadata:
+ name: {{ include "apisix.fullname" . }}
+ namespace: {{ .Values.serviceMonitor.namespace | default .Release.Namespace
}}
+ labels:
+ {{- include "apisix.labels" . | nindent 4 }}
+ {{- if .Values.serviceMonitor.labels }}
+ {{- toYaml .Values.serviceMonitor.labels | nindent 4 }}
+ {{- end }}
+ {{- if .Values.serviceMonitor.annotations }}
+ annotations: {{- toYaml .Values.serviceMonitor.annotations | nindent 4 }}
+ {{- end }}
+spec:
+ namespaceSelector:
+ matchNames:
+ - {{ .Values.serviceMonitor.namespace | default .Release.Namespace }}
+ selector:
+ matchLabels:
+ {{- include "apisix.labels" . | nindent 6 }}
+ endpoints:
+ - scheme: http
+ targetPort: prometheus
+ path: {{ .Values.serviceMonitor.path }}
+ interval: {{ .Values.serviceMonitor.interval }}
+{{- end }}
diff --git a/charts/apisix/values.yaml b/charts/apisix/values.yaml
index ccbaa0b..36c6c63 100644
--- a/charts/apisix/values.yaml
+++ b/charts/apisix/values.yaml
@@ -279,6 +279,23 @@ configurationSnippet:
stream: |
+# Observability configuration.
+# ref: https://apisix.apache.org/docs/apisix/plugins/prometheus/
+serviceMonitor:
+ enabled: false
+ # namespace where the serviceMonitor is deployed, by default, it is the same
as the namespace of the apisix
+ namespace: ""
+ # interval at which metrics should be scraped
+ interval: 15s
+ # path of the metrics endpoint
+ path: /apisix/prometheus/metrics
+ # container port where the metrics are exposed
+ containerPort: 9091
+ # @param serviceMonitor.labels ServiceMonitor extra labels
+ labels: {}
+ # @param serviceMonitor.annotations ServiceMonitor annotations
+ annotations: {}
+
# etcd configuration
# use the FQDN address or the IP of the etcd
etcd: