Skip to content

Commit

Permalink
#1806 provide Helm configuration for metric prefix and custom metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Jäckle <thomas.jaeckle@beyonnex.io>
  • Loading branch information
thjaeckle committed Nov 30, 2023
1 parent 40e1e83 commit 1e34080
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/helm-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
k8s:
- v1.26.6
- v1.27.3
- v1.28.3
- v1.28.0
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
10 changes: 7 additions & 3 deletions deployment/helm/ditto/templates/connectivity-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ spec:
env:
{{- if not .Values.global.logging.customConfigFile.enabled }}
- name: DITTO_LOGGING_DISABLE_SYSOUT_LOG
value: "{{ if .Values.global.logging.sysout.enabled }}false{{ else }}true{{ end }}"
value: "{{ printf "%t" .Values.global.logging.sysout.enabled }}"
- name: DITTO_LOGGING_FILE_APPENDER
value: "{{ if .Values.global.logging.logFiles.enabled }}true{{ else }}false{{ end }}"
value: "{{ printf "%t" .Values.global.logging.logFiles.enabled }}"
{{- end }}
- name: DITTO_METRICS_METRIC_PREFIX
value: "{{ .Values.global.metrics.metricsPrefix }}"
- name: SYSTEM_METRICS_ENABLED
value: "{{ .Values.global.metrics.systemMetrics.enabled }}"
- name: DITTO_TRACING_ENABLED
value: "{{ .Values.global.tracing.enabled }}"
- name: DITTO_TRACING_OTEL_TRACE_REPORTER_ENABLED
Expand Down Expand Up @@ -137,7 +141,7 @@ spec:
{{- end }}
{{ join " " .Values.connectivity.systemProps }}
- name: MONGO_DB_SSL_ENABLED
value: "{{ if .Values.dbconfig.connectivity.ssl }}true{{ else }}false{{ end }}"
value: "{{ printf "%t" .Values.dbconfig.connectivity.ssl }}"
- name: MONGO_DB_URI
valueFrom:
secretKeyRef:
Expand Down
8 changes: 6 additions & 2 deletions deployment/helm/ditto/templates/gateway-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,14 @@ spec:
env:
{{- if not .Values.global.logging.customConfigFile.enabled }}
- name: DITTO_LOGGING_DISABLE_SYSOUT_LOG
value: "{{ if .Values.global.logging.sysout.enabled }}false{{ else }}true{{ end }}"
value: "{{ printf "%t" .Values.global.logging.sysout.enabled }}"
- name: DITTO_LOGGING_FILE_APPENDER
value: "{{ if .Values.global.logging.logFiles.enabled }}true{{ else }}false{{ end }}"
value: "{{ printf "%t" .Values.global.logging.logFiles.enabled }}"
{{- end }}
- name: DITTO_METRICS_METRIC_PREFIX
value: "{{ .Values.global.metrics.metricsPrefix }}"
- name: SYSTEM_METRICS_ENABLED
value: "{{ .Values.global.metrics.systemMetrics.enabled }}"
- name: DITTO_TRACING_ENABLED
value: "{{ .Values.global.tracing.enabled }}"
- name: DITTO_TRACING_OTEL_TRACE_REPORTER_ENABLED
Expand Down
10 changes: 7 additions & 3 deletions deployment/helm/ditto/templates/policies-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ spec:
env:
{{- if not .Values.global.logging.customConfigFile.enabled }}
- name: DITTO_LOGGING_DISABLE_SYSOUT_LOG
value: "{{ if .Values.global.logging.sysout.enabled }}false{{ else }}true{{ end }}"
value: "{{ printf "%t" .Values.global.logging.sysout.enabled }}"
- name: DITTO_LOGGING_FILE_APPENDER
value: "{{ if .Values.global.logging.logFiles.enabled }}true{{ else }}false{{ end }}"
value: "{{ printf "%t" .Values.global.logging.logFiles.enabled }}"
{{- end }}
- name: DITTO_METRICS_METRIC_PREFIX
value: "{{ .Values.global.metrics.metricsPrefix }}"
- name: SYSTEM_METRICS_ENABLED
value: "{{ .Values.global.metrics.systemMetrics.enabled }}"
- name: DITTO_TRACING_ENABLED
value: "{{ .Values.global.tracing.enabled }}"
- name: DITTO_TRACING_OTEL_TRACE_REPORTER_ENABLED
Expand Down Expand Up @@ -155,7 +159,7 @@ spec:
{{- end }}
{{ join " " .Values.policies.systemProps }}
- name: MONGO_DB_SSL_ENABLED
value: "{{ if .Values.dbconfig.policies.ssl }}true{{ else }}false{{ end }}"
value: "{{ printf "%t" .Values.dbconfig.policies.ssl }}"
- name: MONGO_DB_URI
valueFrom:
secretKeyRef:
Expand Down
10 changes: 7 additions & 3 deletions deployment/helm/ditto/templates/things-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ spec:
env:
{{- if not .Values.global.logging.customConfigFile.enabled }}
- name: DITTO_LOGGING_DISABLE_SYSOUT_LOG
value: "{{ if .Values.global.logging.sysout.enabled }}false{{ else }}true{{ end }}"
value: "{{ printf "%t" .Values.global.logging.sysout.enabled }}"
- name: DITTO_LOGGING_FILE_APPENDER
value: "{{ if .Values.global.logging.logFiles.enabled }}true{{ else }}false{{ end }}"
value: "{{ printf "%t" .Values.global.logging.logFiles.enabled }}"
{{- end }}
- name: DITTO_METRICS_METRIC_PREFIX
value: "{{ .Values.global.metrics.metricsPrefix }}"
- name: SYSTEM_METRICS_ENABLED
value: "{{ .Values.global.metrics.systemMetrics.enabled }}"
- name: DITTO_TRACING_ENABLED
value: "{{ .Values.global.tracing.enabled }}"
- name: DITTO_TRACING_OTEL_TRACE_REPORTER_ENABLED
Expand Down Expand Up @@ -156,7 +160,7 @@ spec:
'-Dditto.things.wot.to-thing-description.json-template={{ .Values.things.config.wot.tdJsonTemplate | replace "\n" "" | replace "\\\"" "\"" }}'
{{ join " " .Values.things.systemProps }}
- name: MONGO_DB_SSL_ENABLED
value: "{{ if .Values.dbconfig.things.ssl }}true{{ else }}false{{ end }}"
value: "{{ printf "%t" .Values.dbconfig.things.ssl }}"
- name: MONGO_DB_URI
valueFrom:
secretKeyRef:
Expand Down
25 changes: 22 additions & 3 deletions deployment/helm/ditto/templates/thingssearch-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ spec:
env:
{{- if not .Values.global.logging.customConfigFile.enabled }}
- name: DITTO_LOGGING_DISABLE_SYSOUT_LOG
value: "{{ if .Values.global.logging.sysout.enabled }}false{{ else }}true{{ end }}"
value: "{{ printf "%t" .Values.global.logging.sysout.enabled }}"
- name: DITTO_LOGGING_FILE_APPENDER
value: "{{ if .Values.global.logging.logFiles.enabled }}true{{ else }}false{{ end }}"
value: "{{ printf "%t" .Values.global.logging.logFiles.enabled }}"
{{- end }}
- name: DITTO_METRICS_METRIC_PREFIX
value: "{{ .Values.global.metrics.metricsPrefix }}"
- name: SYSTEM_METRICS_ENABLED
value: "{{ .Values.global.metrics.systemMetrics.enabled }}"
- name: DITTO_TRACING_ENABLED
value: "{{ .Values.global.tracing.enabled }}"
- name: DITTO_TRACING_OTEL_TRACE_REPORTER_ENABLED
Expand Down Expand Up @@ -132,9 +136,20 @@ spec:
{{- if .Values.global.logging.customConfigFile.enabled }}
-Dlogback.configurationFile=/opt/ditto/{{ .Values.global.logging.customConfigFile.fileName }}
{{- end }}
{{- range $key, $value := .Values.thingsSearch.config.operatorMetrics.customMetrics }}
"{{ printf "%s%s%s=%t" "-Dditto.search.operator-metrics.custom-metrics." $key ".enabled" $value.enabled }}"
"{{ printf "%s%s%s=%s" "-Dditto.search.operator-metrics.custom-metrics." $key ".scrape-interval" $value.scrapeInterval }}"
{{- range $index, $namespace := $value.namespaces }}
"{{ printf "%s%s%s%d=%s" "-Dditto.search.operator-metrics.custom-metrics." $key ".namespaces." $index $namespace }}"
{{- end }}
"{{ printf "%s%s%s=%s" "-Dditto.search.operator-metrics.custom-metrics." $key ".filter" $value.filter }}"
{{- range $tagKey, $tagValue := $value.tags }}
"{{ printf "%s%s%s%s=%s" "-Dditto.search.operator-metrics.custom-metrics." $key ".tags." $tagKey $tagValue }}"
{{- end }}
{{- end }}
{{ join " " .Values.thingsSearch.systemProps }}
- name: MONGO_DB_SSL_ENABLED
value: "{{ if .Values.dbconfig.thingsSearch.ssl }}true{{ else }}false{{ end }}"
value: "{{ printf "%t" .Values.dbconfig.thingsSearch.ssl }}"
- name: MONGO_DB_URI
valueFrom:
secretKeyRef:
Expand Down Expand Up @@ -204,6 +219,10 @@ spec:
value: "{{ .Values.thingsSearch.config.updater.stream.retrievalParallelism }}"
- name: THINGS_SEARCH_UPDATER_STREAM_PERSISTENCE_PARALLELISM
value: "{{ .Values.thingsSearch.config.updater.stream.persistence.parallelism }}"
- name: THINGS_SEARCH_OPERATOR_METRICS_ENABLED
value: "{{ .Values.thingsSearch.config.operatorMetrics.enabled }}"
- name: THINGS_SEARCH_OPERATOR_METRICS_SCRAPE_INTERVAL
value: "{{ .Values.thingsSearch.config.operatorMetrics.scrapeInterval }}"
- name: ACTIVITY_CHECK_INTERVAL
value: "{{ .Values.thingsSearch.config.updater.activityCheckInterval }}"
- name: BACKGROUND_SYNC_ENABLED
Expand Down
24 changes: 24 additions & 0 deletions deployment/helm/ditto/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ global:
enabled: true
# fileName passed as Java system property "-Dlogback.configurationFile"
fileName: logback.xml
# metrics configuration for Ditto
metrics:
# metricsPrefix defines a prefix to use for all Ditto created metrics (counters, gauges, histograms)
metricsPrefix: ""
# systemMetrics contains the configuration for obtaining system metrics (via Kamon)
systemMetrics:
# enabled if enabled, system metrics are gathered
enabled: true
# tracing configuration for Ditto
tracing:
# enabled whether tracing (via OpenTelemetry) is enabled
Expand Down Expand Up @@ -1069,6 +1077,22 @@ thingsSearch:
throughput: 100
# period the throttle period
period: 30s
# operatorMetrics contains configuration for operator defined custom metrics, using a search "count" with namespaces and filter
operatorMetrics:
# enabled configures whether operator metrics should be enabled or not
enabled: true
# scrapeInterval defines the default scrape interval if a "customMetric" did not specify a custom scrape interval
scrapeInterval: 15m
# customMetrics holds a map of metric-names as key (e.g. "ditto_my_awesome_things") and custom metric config as value
customMetrics:
# ditto_my_awesome_things:
# enabled: true
# scrapeInterval: 5m
# namespaces:
# - "org.eclipse.ditto"
# filter: "eq(attributes/awesome,true)"
# tags:
# foo: bar


## ----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions thingsearch/service/src/main/resources/search.conf
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ ditto {
# built-in query, delivering the total things as metric
total_things {
enabled = true
scrape-interval = 15m # overwrite scrape interval, run each minute
# for all namespaces
namespaces = []
# with an empty filter query, counting all existing things
Expand Down

0 comments on commit 1e34080

Please sign in to comment.