From 6f501a9f0e93d6d130f1146ff46561b093897e14 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev Date: Thu, 15 Oct 2020 18:10:22 +0500 Subject: [PATCH] add service monitors --- k8s/seaweedfs/templates/filer-service.yaml | 6 ++++++ .../templates/filer-servicemonitor.yaml | 18 ++++++++++++++++++ k8s/seaweedfs/templates/filer-statefulset.yaml | 3 +++ k8s/seaweedfs/templates/s3-deployment.yaml | 3 +++ k8s/seaweedfs/templates/s3-service.yaml | 6 ++++++ k8s/seaweedfs/templates/s3-servicemonitor.yaml | 18 ++++++++++++++++++ k8s/seaweedfs/templates/volume-service.yaml | 8 +++++++- .../templates/volume-servicemonitor.yaml | 18 ++++++++++++++++++ .../templates/volume-statefulset.yaml | 3 +++ k8s/seaweedfs/values.yaml | 3 +++ other/metrics/grafana_seaweedfs_k8s.json | 16 ++++++++-------- 11 files changed, 93 insertions(+), 9 deletions(-) create mode 100644 k8s/seaweedfs/templates/filer-servicemonitor.yaml create mode 100644 k8s/seaweedfs/templates/s3-servicemonitor.yaml create mode 100644 k8s/seaweedfs/templates/volume-servicemonitor.yaml diff --git a/k8s/seaweedfs/templates/filer-service.yaml b/k8s/seaweedfs/templates/filer-service.yaml index 493859e36..debc31f6c 100644 --- a/k8s/seaweedfs/templates/filer-service.yaml +++ b/k8s/seaweedfs/templates/filer-service.yaml @@ -17,6 +17,12 @@ spec: port: {{ .Values.filer.grpcPort }} targetPort: {{ .Values.filer.grpcPort }} protocol: TCP +{{- if .Values.filer.metricsPort }} + - name: "swfs-filer-metrics" + port: {{ .Values.filer.metricsPort }} + targetPort: {{ .Values.filer.metricsPort }} + protocol: TCP +{{- end }} selector: app: {{ template "seaweedfs.name" . }} component: filer \ No newline at end of file diff --git a/k8s/seaweedfs/templates/filer-servicemonitor.yaml b/k8s/seaweedfs/templates/filer-servicemonitor.yaml new file mode 100644 index 000000000..f07f6ebef --- /dev/null +++ b/k8s/seaweedfs/templates/filer-servicemonitor.yaml @@ -0,0 +1,18 @@ +{{- if .Values.filer.metricsPort }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "seaweedfs.name" . }}-filer + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "seaweedfs.name" . }} + component: filer +spec: + endpoints: + - interval: 30s + port: swfs-filer-metrics + scrapeTimeout: 5s + selector: + app: {{ template "seaweedfs.name" . }} + component: filer +{{- end }} \ No newline at end of file diff --git a/k8s/seaweedfs/templates/filer-statefulset.yaml b/k8s/seaweedfs/templates/filer-statefulset.yaml index d1dd851fe..7fe5bb4e3 100644 --- a/k8s/seaweedfs/templates/filer-statefulset.yaml +++ b/k8s/seaweedfs/templates/filer-statefulset.yaml @@ -99,6 +99,9 @@ spec: {{- end }} filer \ -port={{ .Values.filer.port }} \ + {{- if .Values.filer.metricsPort }} + -metricsPort {{ .Values.filer.metricsPort }} \ + {{- end }}} {{- if .Values.filer.redirectOnRead }} -redirectOnRead \ {{- end }} diff --git a/k8s/seaweedfs/templates/s3-deployment.yaml b/k8s/seaweedfs/templates/s3-deployment.yaml index 0e786a6c3..b6115be37 100644 --- a/k8s/seaweedfs/templates/s3-deployment.yaml +++ b/k8s/seaweedfs/templates/s3-deployment.yaml @@ -71,6 +71,9 @@ spec: {{- end }} s3 \ -port={{ .Values.s3.port }} \ + {{- if .Values.s3.metricsPort }} + -metricsPort {{ .Values.s3.metricsPort }} \ + {{- end }}} {{- if .Values.global.enableSecurity }} -cert.file=/usr/local/share/ca-certificates/client/tls.crt \ -key.file=/usr/local/share/ca-certificates/client/tls.key \ diff --git a/k8s/seaweedfs/templates/s3-service.yaml b/k8s/seaweedfs/templates/s3-service.yaml index b088e25fa..b5db3bba1 100644 --- a/k8s/seaweedfs/templates/s3-service.yaml +++ b/k8s/seaweedfs/templates/s3-service.yaml @@ -12,6 +12,12 @@ spec: port: {{ .Values.s3.port }} targetPort: {{ .Values.s3.port }} protocol: TCP +{{- if .Values.s3.metricsPort }} + - name: "swfs-s3-metrics" + port: {{ .Values.filer.s3 }} + targetPort: {{ .Values.s3.metricsPort }} + protocol: TCP +{{- end }}} selector: app: {{ template "seaweedfs.name" . }} component: s3 \ No newline at end of file diff --git a/k8s/seaweedfs/templates/s3-servicemonitor.yaml b/k8s/seaweedfs/templates/s3-servicemonitor.yaml new file mode 100644 index 000000000..03b13ae8e --- /dev/null +++ b/k8s/seaweedfs/templates/s3-servicemonitor.yaml @@ -0,0 +1,18 @@ +{{- if .Values.s3.metricsPort }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "seaweedfs.name" . }}-s3 + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "seaweedfs.name" . }} + component: s3 +spec: + endpoints: + - interval: 30s + port: swfs-s3-metrics + scrapeTimeout: 5s + selector: + app: {{ template "seaweedfs.name" . }} + component: s3 +{{- end }}} \ No newline at end of file diff --git a/k8s/seaweedfs/templates/volume-service.yaml b/k8s/seaweedfs/templates/volume-service.yaml index fc7716681..ea3bf75fa 100644 --- a/k8s/seaweedfs/templates/volume-service.yaml +++ b/k8s/seaweedfs/templates/volume-service.yaml @@ -17,6 +17,12 @@ spec: port: {{ .Values.volume.grpcPort }} targetPort: {{ .Values.volume.grpcPort }} protocol: TCP - selector: +{{- if .Values.volume.metricsPort }} + - name: "swfs-volume-metrics" + port: {{ .Values.volume.metricsPort }} + targetPort: {{ .Values.volume.metricsPort }} + protocol: TCP +{{- end }}} +selector: app: {{ template "seaweedfs.name" . }} component: volume \ No newline at end of file diff --git a/k8s/seaweedfs/templates/volume-servicemonitor.yaml b/k8s/seaweedfs/templates/volume-servicemonitor.yaml new file mode 100644 index 000000000..64b5cf425 --- /dev/null +++ b/k8s/seaweedfs/templates/volume-servicemonitor.yaml @@ -0,0 +1,18 @@ +{{- if .Values.volume.metricsPort }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ template "seaweedfs.name" . }}-volume + namespace: {{ .Release.Namespace }} + labels: + app: {{ template "seaweedfs.name" . }} + component: volume +spec: + endpoints: + - interval: 30s + port: swfs-volume-metrics + scrapeTimeout: 5s + selector: + app: {{ template "seaweedfs.name" . }} + component: volume +{{- end }}} \ No newline at end of file diff --git a/k8s/seaweedfs/templates/volume-statefulset.yaml b/k8s/seaweedfs/templates/volume-statefulset.yaml index 4db8391f9..27fa7888e 100644 --- a/k8s/seaweedfs/templates/volume-statefulset.yaml +++ b/k8s/seaweedfs/templates/volume-statefulset.yaml @@ -76,6 +76,9 @@ spec: {{- end }} volume \ -port={{ .Values.volume.port }} \ + {{- if .Values.volume.metricsPort }} + -metricsPort {{ .Values.volume.metricsPort }} \ + {{- end }}} -dir={{ .Values.volume.dir }} \ -max={{ .Values.volume.maxVolumes }} \ {{- if .Values.volume.rack }} diff --git a/k8s/seaweedfs/values.yaml b/k8s/seaweedfs/values.yaml index 622b9b29e..3fc966453 100644 --- a/k8s/seaweedfs/values.yaml +++ b/k8s/seaweedfs/values.yaml @@ -121,6 +121,7 @@ volume: restartPolicy: null port: 8080 grpcPort: 18080 + metricsPort: 9327 ipBind: "0.0.0.0" replicas: 1 loggingOverrideLevel: null @@ -209,6 +210,7 @@ filer: replicas: 1 port: 8888 grpcPort: 18888 + metricsPort: 9327 loggingOverrideLevel: null # replication type is XYZ: # X number of replica in other data centers @@ -313,6 +315,7 @@ s3: restartPolicy: null replicas: 1 port: 8333 + metricsPort: 9327 loggingOverrideLevel: null # Suffix of the host name, {bucket}.{domainName} diff --git a/other/metrics/grafana_seaweedfs_k8s.json b/other/metrics/grafana_seaweedfs_k8s.json index 93e2e0fb6..6d89a4c34 100644 --- a/other/metrics/grafana_seaweedfs_k8s.json +++ b/other/metrics/grafana_seaweedfs_k8s.json @@ -1891,7 +1891,7 @@ "steppedLine": false, "targets": [ { - "expr": "go_memstats_alloc_bytes{namespace=~\"$namespace\", endpoint=\"sw-filer-exporter\"}", + "expr": "go_memstats_alloc_bytes{namespace=~\"$namespace\", endpoint=\"swfs-filer-metrics\"}", "format": "time_series", "hide": false, "interval": "", @@ -1900,7 +1900,7 @@ "refId": "B" }, { - "expr": "rate(go_memstats_alloc_bytes_total{namespace=~\"$namespace\", endpoint=\"sw-.*-exporter\"}[30s])", + "expr": "rate(go_memstats_alloc_bytes_total{namespace=~\"$namespace\", endpoint=\"swfs-.*-metrics\"}[30s])", "format": "time_series", "hide": false, "interval": "", @@ -1909,7 +1909,7 @@ "refId": "A" }, { - "expr": "go_memstats_stack_inuse_bytes{namespace=~\"$namespace\", endpoint=\"sw-filer-exporter\"}", + "expr": "go_memstats_stack_inuse_bytes{namespace=~\"$namespace\", endpoint=\"swfs-filer-metrics\"}", "format": "time_series", "hide": true, "interval": "", @@ -1918,7 +1918,7 @@ "refId": "C" }, { - "expr": "go_memstats_heap_inuse_bytes{namespace=~\"$namespace\", endpoint=\"sw-filer-exporter\"}", + "expr": "go_memstats_heap_inuse_bytes{namespace=~\"$namespace\", endpoint=\"swfs-filer-metrics\"}", "format": "time_series", "hide": true, "interval": "", @@ -2019,7 +2019,7 @@ "steppedLine": false, "targets": [ { - "expr": "go_gc_duration_seconds{namespace=~\"$namespace\", endpoint=\"sw-filer-exporter\"}", + "expr": "go_gc_duration_seconds{namespace=~\"$namespace\", endpoint=\"swfs-filer-metrics\"}", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -2119,7 +2119,7 @@ "steppedLine": false, "targets": [ { - "expr": "go_goroutines{namespace=~\"$namespace\", endpoint=\"sw-filer-exporter\"}", + "expr": "go_goroutines{namespace=~\"$namespace\", endpoint=\"swfs-filer-metrics\"}", "format": "time_series", "interval": "", "intervalFactor": 2, @@ -2203,7 +2203,7 @@ "value": "s3" }, "datasource": "$DS_PROMETHEUS", - "definition": "label_values({endpoint=\"sw-filer-exporter\"}, namespace)", + "definition": "label_values({endpoint=\"swfs-filer-metrics\"}, namespace)", "hide": 0, "includeAll": false, "label": "namespace", @@ -2216,7 +2216,7 @@ "value": "s3" } ], - "query": "label_values({endpoint=\"sw-filer-exporter\"}, namespace)", + "query": "label_values({endpoint=\"swfs-filer-metrics\"}, namespace)", "refresh": 0, "regex": "", "skipUrlSync": false,