Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

[7.x] [logstash] Add support to use pattern files (#883) #1079

Merged
merged 1 commit into from
Feb 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions logstash/README.md
Original file line number Diff line number Diff line change
@@ -129,6 +129,8 @@ useful for the [http input plugin][], for instance.
| `logstashConfig` | Allows you to add any config files in `/usr/share/logstash/config/` such as `logstash.yml` and `log4j2.properties` See [values.yaml][] for an example of the formatting | `{}` |
| `logstashJavaOpts` | Java options for Logstash. This is where you should configure the JVM heap size | `-Xmx1g -Xms1g` |
| `logstashPipeline` | Allows you to add any pipeline files in `/usr/share/logstash/pipeline/` | `{}` |
| `logstashPatternDir` | Allows you to define a custom directory to store patten files | `/usr/share/logstash/patterns/` |
| `logstashPattern` | Allows you to add any pattern files in `logstashPatternDir` | `{}` |
| `maxUnavailable` | The [maxUnavailable][] value for the pod disruption budget. By default this will prevent Kubernetes from having more than 1 unhealthy pod in the node group | `1` |
| `nameOverride` | Overrides the chart name for resources. If not set the name will default to `.Chart.Name` | `""` |
| `nodeAffinity` | Value for the [node affinity settings][] | `{}` |
17 changes: 17 additions & 0 deletions logstash/templates/configmap-pattern.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.logstashPattern }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "logstash.fullname" . }}-pattern
labels:
app: "{{ template "logstash.fullname" . }}"
chart: "{{ .Chart.Name }}"
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
data:
{{- range $path, $config := .Values.logstashPattern }}
{{ $path }}: |
{{ tpl $config $ | indent 4 -}}
{{- end -}}
{{- end -}}
16 changes: 16 additions & 0 deletions logstash/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -55,6 +55,9 @@ spec:
{{- if .Values.logstashPipeline }}
pipelinechecksum: {{ include (print .Template.BasePath "/configmap-pipeline.yaml") . | sha256sum | trunc 63 }}
{{- end }}
{{- if .Values.logstashPattern }}
patternchecksum: {{ include (print .Template.BasePath "/configmap-pattern.yaml") . | sha256sum | trunc 63 }}
{{- end }}
{{- if .Values.secrets }}
secretschecksum: {{ include (print .Template.BasePath "/secret.yaml") . | sha256sum | trunc 63 }}
{{- end }}
@@ -127,6 +130,11 @@ spec:
configMap:
name: {{ template "logstash.fullname" . }}-pipeline
{{- end }}
{{- if .Values.logstashPattern }}
- name: logstashpattern
configMap:
name: {{ template "logstash.fullname" . }}-pattern
{{- end }}
{{- if .Values.extraVolumes }}
{{ tpl .Values.extraVolumes . | indent 8 }}
{{- end }}
@@ -191,6 +199,14 @@ spec:
mountPath: /usr/share/logstash/pipeline/{{ $path }}
subPath: {{ $path }}
{{- end -}}
{{- if .Values.logstashPattern }}
{{- $logstashPatternDir := .Values.logstashPatternDir -}}
{{- range $path, $config := .Values.logstashPattern }}
- name: logstashpattern
mountPath: {{ $logstashPatternDir }}{{ $path }}
subPath: {{ $path }}
{{- end -}}
{{- end -}}
{{- if .Values.extraVolumeMounts }}
{{ tpl .Values.extraVolumeMounts . | indent 10 }}
{{- end }}
19 changes: 19 additions & 0 deletions logstash/tests/logstash_test.py
Original file line number Diff line number Diff line change
@@ -622,6 +622,25 @@ def test_adding_in_pipeline():
)


def test_adding_in_pattern():
config = """
logstashPattern:
pattern.conf: |
DPKG_VERSION [-+~<>\.0-9a-zA-Z]+
"""
r = helm_template(config)
c = r["configmap"][name + "-pattern"]["data"]

assert "pattern.conf" in c

assert "DPKG_VERSION [-+~<>\.0-9a-zA-Z]+" in c["pattern.conf"]

assert (
"patternchecksum"
in r["statefulset"][name]["spec"]["template"]["metadata"]["annotations"]
)


def test_priority_class_name():
config = """
priorityClassName: ""
6 changes: 6 additions & 0 deletions logstash/values.yaml
Original file line number Diff line number Diff line change
@@ -25,6 +25,12 @@ logstashPipeline: {}
# }
# output { stdout { } }

# Allows you to add any pattern files in your custom pattern dir
logstashPatternDir: "/usr/share/logstash/patterns/"
logstashPattern: {}
# pattern.conf: |
# DPKG_VERSION [-+~<>\.0-9a-zA-Z]+

# Extra environment variables to append to this nodeGroup
# This will be appended to the current 'env:' key. You can use any of the kubernetes env
# syntax here