diff --git a/chart/README.md b/chart/README.md index f9195f43..df3ecccb 100644 --- a/chart/README.md +++ b/chart/README.md @@ -4,9 +4,32 @@ ### Logstash configuration -| Name | Description | Value | -| -------------- | --------------------- | ---------------------- | -| `logstash.url` | Logstash instance URL | `http://logstash:9600` | +| Name | Description | Value | +| ----------------------- | --------------------- | ---------------------- | +| `logstash.url` | Logstash instance URL | `http://logstash:9600` | +| `logstash.httpTimeout` | http timeout | `3s` | +| `logstash.httpInsecure` | http insecure | `false` | + +### Web settings + +| Name | Description | Value | +| ---------- | ----------------------------------- | ----- | +| `web.path` | Path under which to expose metrics. | `/` | + +### PodMonitor settings + +| Name | Description | Value | +| ------------------------------ | --------------------------------- | -------------------------- | +| `podMonitor.enabled` | Enable pod monitor creation | `false` | +| `podMonitor.apiVersion` | Set pod monitor apiVersion | `monitoring.coreos.com/v1` | +| `podMonitor.namespace` | Set pod monitor namespace | `""` | +| `podMonitor.labels` | Set pod monitor labels | `{}` | +| `podMonitor.interval` | Set pod monitor interval | `60s` | +| `podMonitor.scrapeTimeout` | Set pod monitor scrapeTimeout | `10s` | +| `podMonitor.honorLabels` | Set pod monitor honorLabels | `true` | +| `podMonitor.scheme` | Set pod monitor scheme | `http` | +| `podMonitor.relabelings` | Set pod monitor relabelings | `[]` | +| `podMonitor.metricRelabelings` | Set pod monitor metricRelabelings | `[]` | ### Image settings @@ -58,6 +81,12 @@ | `deployment.rollingUpdate.maxSurge` | Maximum surge for rolling update | `1` | | `deployment.rollingUpdate.maxUnavailable` | Maximum unavailable for rolling update | `0` | +### metricsPort settings + +| Name | Description | Value | +| ----------------------------- | ---------------- | ------ | +| `deployment.metricsPort.name` | Name of the port | `http` | + ### Service settings | Name | Description | Value | diff --git a/chart/schema.json b/chart/schema.json index 8cde27ba..b01ccf33 100644 --- a/chart/schema.json +++ b/chart/schema.json @@ -9,6 +9,83 @@ "type": "string", "description": "Logstash instance URL", "default": "http://logstash:9600" + }, + "httpTimeout": { + "type": "string", + "description": "http timeout", + "default": "3s" + }, + "httpInsecure": { + "type": "boolean", + "description": "http insecure", + "default": false + } + } + }, + "web": { + "type": "object", + "properties": { + "path": { + "type": "string", + "description": "Path under which to expose metrics.", + "default": "/" + } + } + }, + "podMonitor": { + "type": "object", + "properties": { + "enabled": { + "type": "boolean", + "description": "Enable pod monitor creation", + "default": false + }, + "apiVersion": { + "type": "string", + "description": "Set pod monitor apiVersion", + "default": "monitoring.coreos.com/v1" + }, + "namespace": { + "type": "string", + "description": "Set pod monitor namespace", + "default": "" + }, + "labels": { + "type": "object", + "description": "Set pod monitor labels", + "default": {} + }, + "interval": { + "type": "string", + "description": "Set pod monitor interval", + "default": "60s" + }, + "scrapeTimeout": { + "type": "string", + "description": "Set pod monitor scrapeTimeout", + "default": "10s" + }, + "honorLabels": { + "type": "boolean", + "description": "Set pod monitor honorLabels", + "default": true + }, + "scheme": { + "type": "string", + "description": "Set pod monitor scheme", + "default": "http" + }, + "relabelings": { + "type": "array", + "description": "Set pod monitor relabelings", + "default": [], + "items": {} + }, + "metricRelabelings": { + "type": "array", + "description": "Set pod monitor metricRelabelings", + "default": [], + "items": {} } } }, @@ -187,6 +264,16 @@ "default": 0 } } + }, + "metricsPort": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Name of the port", + "default": "http" + } + } } } }, diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index f5987e57..bc71d116 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -39,3 +39,24 @@ It checks if .Values.image.tag is provided, and if not, it returns a tag with "v {{- printf "v%s" .Chart.AppVersion -}} {{- end -}} {{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "logstash-exporter.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "logstash-exporter.labels" -}} +helm.sh/chart: {{ include "logstash-exporter.chart" . }} +{{- with .Chart.AppVersion }} +app.kubernetes.io/version: {{ . | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- if .Values.commonLabels }} +{{ toYaml .Values.commonLabels }} +{{- end }} +{{- end }} diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml index 3efece3e..f9268323 100644 --- a/chart/templates/deployment.yaml +++ b/chart/templates/deployment.yaml @@ -89,6 +89,10 @@ spec: value: {{ required "logstash.url is required" .Values.logstash.url | quote }} - name: PORT value: {{ required "service.port is required" .Values.service.port | quote }} + - name: HTTP_TIMEOUT + value: {{ required "logstash.httpTimeout is required" .Values.logstash.httpTimeout | quote }} + - name: HTTP_INSECURE + value: {{ required "logstash.httpInsecure is required" .Values.logstash.httpInsecure | quote }} {{- range $key, $value := .Values.deployment.env }} - name: {{ $key | quote }} value: {{ $value | quote }} diff --git a/chart/templates/podmonitor.yaml b/chart/templates/podmonitor.yaml new file mode 100644 index 00000000..847c44aa --- /dev/null +++ b/chart/templates/podmonitor.yaml @@ -0,0 +1,45 @@ +{{- if .Values.podMonitor.enabled }} +apiVersion: {{ .Values.podMonitor.apiVersion }} +kind: PodMonitor +metadata: + name: {{ template "logstash-exporter.fullname" . }} + {{- if .Values.podMonitor.namespace }} + namespace: {{ .Values.podMonitor.namespace }} + {{- end }} + labels: + {{- include "logstash-exporter.labels" . | nindent 4 }} + {{- if .Values.podMonitor.labels }} + {{- toYaml .Values.podMonitor.labels | nindent 4 }} + {{- end }} +spec: + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + podMetricsEndpoints: + - path: {{ .Values.web.path }} + port: {{ .Values.deployment.metricsPort.name }} + {{- if .Values.podMonitor.scheme }} + scheme: {{ .Values.podMonitor.scheme }} + {{- end }} + {{- if .Values.podMonitor.interval }} + interval: {{ .Values.podMonitor.interval }} + {{- end }} + {{- if .Values.podMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.podMonitor.scrapeTimeout }} + {{- end }} + {{- if .Values.podMonitor.honorLabels }} + honorLabels: true + {{- end }} + {{- if .Values.podMonitor.metricRelabelings }} + metricRelabelings: + {{- toYaml .Values.podMonitor.metricRelabelings | nindent 6 }} + {{- end }} + {{- if .Values.podMonitor.relabelings }} + relabelings: + {{- toYaml .Values.podMonitor.relabelings | nindent 6 }} + {{- end }} + selector: + matchLabels: + app: {{ template "logstash-exporter.name" . }} + release: {{ .Release.Name }} +{{- end }} \ No newline at end of file diff --git a/chart/values.yaml b/chart/values.yaml index f36c0a6a..543bf8ba 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -4,6 +4,56 @@ logstash: ## @param logstash.url Logstash instance URL ## url: "http://logstash:9600" + ## @param logstash.httpTimeout http timeout + ## + httpTimeout: "3s" + ## @param logstash.httpInsecure http insecure + ## + httpInsecure: false + +## @section Web settings +## +web: + ## @param web.path Path under which to expose metrics. + ## + path: / + +## @section PodMonitor settings +## +podMonitor: + ## If true, a PodMonitor CRD is created for a Prometheus Operator + ## https://prometheus-operator.dev/docs/operator/api/#monitoring.coreos.com/v1.PodMonitor + ## + ## @param podMonitor.enabled Enable pod monitor creation + ## + enabled: false + ## @param podMonitor.apiVersion Set pod monitor apiVersion + ## + apiVersion: "monitoring.coreos.com/v1" + ## @param podMonitor.namespace Set pod monitor namespace + ## + namespace: "" + ## @param podMonitor.labels Set pod monitor labels + ## + labels: {} + ## @param podMonitor.interval Set pod monitor interval + ## + interval: 60s + ## @param podMonitor.scrapeTimeout Set pod monitor scrapeTimeout + ## + scrapeTimeout: 10s + ## @param podMonitor.honorLabels Set pod monitor honorLabels + ## + honorLabels: true + ## @param podMonitor.scheme Set pod monitor scheme + ## + scheme: http + ## @param podMonitor.relabelings Set pod monitor relabelings + ## + relabelings: [] + ## @param podMonitor.metricRelabelings Set pod monitor metricRelabelings + ## + metricRelabelings: [] ## @section Image settings ## @@ -35,17 +85,9 @@ deployment: restartPolicy: Always ## @param deployment.annotations Additional deployment annotations ## - ## Example: - ## annotations: - ## kubernetes.io/foo: bar - ## annotations: {} ## @param deployment.labels Additional deployment labels ## - ## Example: - ## labels: - ## foo: bar - ## labels: {} ## @param deployment.pullSecret Kubernetes secret for pulling the image ## @@ -120,6 +162,12 @@ deployment: ## @param deployment.rollingUpdate.maxUnavailable Maximum unavailable for rolling update ## maxUnavailable: 0 + ## @section metricsPort settings + ## + metricsPort: + ## @param deployment.metricsPort.name Name of the port + ## + name: http ## @section Service settings ## @@ -151,4 +199,4 @@ serviceAccount: name: "" ## @param serviceAccount.annotations Additional service account annotations ## - annotations: {} + annotations: {} \ No newline at end of file