Skip to content

Commit

Permalink
Allow flexible configuration of JMX rules (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 authored Feb 24, 2025
1 parent 341aeeb commit 00bbdf1
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 42 deletions.
1 change: 1 addition & 0 deletions charts/producer-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata:
labels:
app: {{ template "producer-app.name" . }}
chart: {{ template "producer-app.chart" . }}
streams-bootstrap/kind: {{ .Chart.Name }}
release: {{ .Release.Name }}
{{- range $key, $value := .Values.labels }}
{{ $key }}: {{ $value }}
Expand Down
1 change: 1 addition & 0 deletions charts/producer-app/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ metadata:
labels:
app: {{ template "producer-app.name" . }}
chart: {{ template "producer-app.chart" . }}
streams-bootstrap/kind: {{ .Chart.Name }}
release: {{ .Release.Name }}
{{- range $key, $value := .Values.labels }}
{{ $key }}: {{ $value }}
Expand Down
1 change: 1 addition & 0 deletions charts/producer-app/templates/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ metadata:
{{- end }}
labels:
app: {{ template "producer-app.name" . }}
streams-bootstrap/kind: {{ .Chart.Name }}
release: {{ .Release.Name }}
{{- range $key, $value := .Values.podLabels }}
{{ $key }}: {{ $value }}
Expand Down
35 changes: 23 additions & 12 deletions charts/streams-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,32 @@ Alternatively, a YAML file that specifies the values for the parameters can be p

### JMX Configuration

| Parameter | Description | Default |
| ----------------- | ------------------------------------------------- | -------- |
| `jmx.port` | The jmx port which JMX style metrics are exposed. | `5555` |
| `jmx.metricRules` | List of JMX metric rules. | `[".*"]` |
| Parameter | Description | Default |
|------------|---------------------------------------------------|---------|
| `jmx.port` | The jmx port which JMX style metrics are exposed. | `5555` |

### Prometheus JMX Exporter Configuration

| Parameter | Description | Default |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| `prometheus.jmx.enabled` | Whether or not to install Prometheus JMX Exporter as a sidecar container and expose JMX metrics to Prometheus. | `true` |
| `prometheus.jmx.image` | Docker Image for Prometheus JMX Exporter container. | `solsson/kafka-prometheus-jmx-exporter@sha256` |
| `prometheus.jmx.imageTag` | Docker Image Tag for Prometheus JMX Exporter container. | `6f82e2b0464f50da8104acd7363fb9b995001ddff77d248379f8788e78946143` |
| `prometheus.jmx.imagePullPolicy` | Docker Image Pull Policy for Prometheus JMX Exporter container. | `IfNotPresent` |
| `prometheus.jmx.port` | JMX Exporter Port which exposes metrics in Prometheus format for scraping. | `5556` |
| `prometheus.jmx.resources` | JMX Exporter resources configuration. | see [values.yaml](values.yaml) for details |
| Parameter | Description | Default |
|----------------------------------|----------------------------------------------------------------------------------------------------------------|--------------------------------------------|
| `prometheus.jmx.enabled` | Whether or not to install Prometheus JMX Exporter as a sidecar container and expose JMX metrics to Prometheus. | `false` |
| `prometheus.jmx.image` | Docker Image for Prometheus JMX Exporter container. | `bitnami/jmx-exporter` |
| `prometheus.jmx.imageTag` | Docker Image Tag for Prometheus JMX Exporter container. | `1.1.0` |
| `prometheus.jmx.imagePullPolicy` | Docker Image Pull Policy for Prometheus JMX Exporter container. | `Always` |
| `prometheus.jmx.port` | JMX Exporter Port which exposes metrics in Prometheus format for scraping. | `5556` |
| `prometheus.jmx.metricRules` | List of JMX metric rules. | `[pattern: ".*"]` |
| `prometheus.jmx.resources` | JMX Exporter resources configuration. | see [values.yaml](values.yaml) for details |

Prometheus can scrape your metrics by deploying
a [PodMonitor](https://github.com/bakdata/streams-bootstrap/blob/master/monitoring/pod_monitor.yaml) or adding pod
annotations

```yaml
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: 5556 # needs to match prometheus.jmx.port
```
### Auto-Scaling
Expand Down
26 changes: 9 additions & 17 deletions charts/streams-app/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ metadata:
labels:
app: {{ template "streams-app.name" . }}
chart: {{ template "streams-app.chart" . }}
streams-bootstrap/kind: {{ .Chart.Name }}
release: {{ .Release.Name }}
{{- range $key, $value := .Values.labels }}
{{ $key }}: {{ $value }}
Expand All @@ -37,21 +38,18 @@ spec:
release: {{ .Release.Name }}
template:
metadata:
{{- if or .Values.prometheus.jmx.enabled .Values.podAnnotations .Values.files }}
{{- if or .Values.podAnnotations .Values.files }}
annotations:
{{- if .Values.files }}
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- end }}
{{- if .Values.prometheus.jmx.enabled }}
prometheus.io/scrape: "true"
prometheus.io/port: {{ .Values.prometheus.jmx.port | quote }}
{{- end }}
{{- range $key, $value := .Values.podAnnotations }}
{{ $key | quote }}: {{ $value | quote }}
{{- end }}
{{- end }}
labels:
app: {{ template "streams-app.name" . }}
streams-bootstrap/kind: {{ .Chart.Name }}
release: {{ .Release.Name }}
{{- range $key, $value := .Values.podLabels }}
{{ $key }}: {{ $value }}
Expand Down Expand Up @@ -105,10 +103,6 @@ spec:
fieldRef:
fieldPath: metadata.name
{{- end }}
{{- if .Values.prometheus.jmx.enabled }}
- name: KAFKA_JMX_PORT
value: "{{ .Values.jmx.port }}"
{{- end }}
{{- if not .Values.statefulSet }}
- name: "{{ .Values.configurationEnvPrefix }}_VOLATILE_GROUP_INSTANCE_ID"
value: "true"
Expand Down Expand Up @@ -229,18 +223,16 @@ spec:
{{- if .Values.prometheus.jmx.enabled }}
- name: prometheus-jmx-exporter
image: "{{ .Values.prometheus.jmx.image }}:{{ .Values.prometheus.jmx.imageTag }}"
command:
- java
- -XX:+UnlockExperimentalVMOptions
- -XX:+UseCGroupMemoryLimitForHeap
- -XX:MaxRAMFraction=1
- -XshowSettings:vm
- -jar
- jmx_prometheus_httpserver.jar
imagePullPolicy: "{{ .Values.prometheus.jmx.imagePullPolicy }}"
args:
- {{ .Values.prometheus.jmx.port | quote }}
- /etc/jmx-streams-app/jmx-kafka-streams-app-prometheus.yml
env:
- name: JAVA_TOOL_OPTIONS
value: "-XX:MaxRAMPercentage=90.0"
ports:
- containerPort: {{ .Values.prometheus.jmx.port }}
name: prometheus
resources:
{{ toYaml .Values.prometheus.jmx.resources | indent 12 }}
volumeMounts:
Expand Down
5 changes: 1 addition & 4 deletions charts/streams-app/templates/jmx-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,5 @@ data:
lowercaseOutputName: true
lowercaseOutputLabelNames: true
ssl: false
rules:
{{- range .Values.jmx.metricRules}}
- pattern: {{ . | quote }}
{{- end}}
rules: {{ toYaml .Values.prometheus.jmx.metricRules | nindent 4 }}
{{- end }}
19 changes: 10 additions & 9 deletions charts/streams-app/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ readinessProbe: {}
## ref: https://kafka.apache.org/documentation/#connect_monitoring
jmx:
port: 5555
metricRules:
- ".*"

autoscaling:
enabled: false
Expand Down Expand Up @@ -150,20 +148,23 @@ prometheus:
## JMX Exporter Configuration
## ref: https://github.com/prometheus/jmx_exporter
jmx:
enabled: true
image: solsson/kafka-prometheus-jmx-exporter@sha256
imageTag: 6f82e2b0464f50da8104acd7363fb9b995001ddff77d248379f8788e78946143
enabled: false
image: bitnami/jmx-exporter
imageTag: 1.1.0
imagePullPolicy: Always
port: 5556
metricRules:
- pattern: ".*"

## Resources configuration for the JMX exporter container.
## See the `resources` documentation above for details.
resources:
requests:
cpu: 100m
memory: 500Mi
cpu: 10m
memory: 100Mi
limits:
cpu: 300m
memory: 2G
cpu: 100m
memory: 100Mi

# priorityClass
# priorityClassName: ""
Expand Down
14 changes: 14 additions & 0 deletions monitoring/pod_monitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: kafka-streams
spec:
selector:
matchExpressions:
- key: "streams-bootstrap/kind"
operator: In
values:
- streams-app
podMetricsEndpoints:
- path: /metrics
targetPort: 5556

0 comments on commit 00bbdf1

Please sign in to comment.