Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Logstash keystore command performance #7027

Closed
kaisecheng opened this issue Jul 17, 2023 · 0 comments · Fixed by #7642
Closed

Improve Logstash keystore command performance #7027

kaisecheng opened this issue Jul 17, 2023 · 0 comments · Fixed by #7642
Labels
>enhancement Enhancement of existing functionality :logstash

Comments

@kaisecheng
Copy link
Contributor

kaisecheng commented Jul 17, 2023

Logstash keystore init container slows down the startup process. To update the keystore, logstash-keystore command starts and stops jvm for each key. The process is proportion to the number of keys. In the local env, adding 10 keys takes six minutes to get Logstash ready.

Logstash keystore command should allow adding keys in a batch.

Config to reproduce the issue

apiVersion: v1
kind: Secret
metadata:
  name: logstash-secure-settings
stringData:
  A: a
  B: b
  C: c
  D: d
  E: e
  F: f
  G: g
  H: h
  I: i
  J: j
---
apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
  name: logstash-sample
spec:
  version: 8.8.0
  count: 1
  pipelines:
    - pipeline.id: main
      config.string: |-
        input { exec { command => 'uptime' interval => 10 } }
        filter {
          if ("${HELLO:}" != "") {
            mutate { add_tag => ["awesome"] }
          }
        }
  secureSettings:
    - secretName: logstash-secure-settings

relates: elastic/logstash#15186

@kaisecheng kaisecheng added >enhancement Enhancement of existing functionality :logstash labels Jul 17, 2023
kaisecheng added a commit to kaisecheng/cloud-on-k8s that referenced this issue Mar 18, 2024
pebrc pushed a commit that referenced this issue Mar 22, 2024
Fixes: #7027

Logstash has performance issue when init container creates keystore with a couple of keys. 
Since Logstash 8.12.0, `logstash-keystore` command supports adding multiple keys in one operation. 
This PR uses the command to add keys in a batch. The minimum version of Logstash currently running in ECK is 8.12.0

The steps to create keystore in Logstash
```bash
# create keystore without password
echo 'y' | bin/logstash-keystore create 
# add keys one and two
bin/logstash-keystore add one two
Enter value for one: # input ASCII and non-empty string, and then press <enter>
Added 'one' to the Logstash keystore.
Enter value for two:
Added 'two' to the Logstash keystore.
```

The following resources should start approximately in a minute
```yaml
apiVersion: v1
kind: Secret
metadata:
  name: logstash-secure-settings
stringData:
  HELLO: HALLO
  A: "1"
  B: "2"
  C: "3"
  D: "4"
  E: "5"
  F: "6"
  G: "7"
  H: "8"
  I: "9"
  J: "10"
---
apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
  name: logstash-sample
spec:
  version: 8.12.0
  count: 1
  pipelines:
    - pipeline.id: main
      config.string: |-
        input { exec { command => 'uptime' interval => 10 } }
        filter {
          if ("${HELLO:}" != "") {
            mutate { add_tag => ["${A}", "${B}", "${C}", "${D}", "${E}", "${F}", "${G}", "${H}", "${I}", "${J}"] }
          }
        }
  secureSettings:
    - secretName: logstash-secure-settings
```


---------

Co-authored-by: Rob Bavey <rob.bavey@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement Enhancement of existing functionality :logstash
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant