Validation of logstash config


(Vafa Ronaghi) #1

Hello all,
Following situation:
I am running a logstash-5.6.4 in a docker container. This is an ansible project in a gitlab.
Everytime I change something in logstash config, gitlab starts a pipeline to build all required files and
and perform a deployment into docker container.

Is it possible to validate the configuration with "--config.test_and_exit" before its getting deployed to docker container ?

I mean is there any possibility within logstash to do this ?

Thanks in forward
Vafa


(Magnus Bäck) #2

That shouldn't be too hard to do. How are you starting the container (how does Logstash access the configuration files)? What image are you using?


(Vafa Ronaghi) #3

I use standard loghstash image from elastic in version 5.6.4 .
I start the container with a systemctl service file which is also getting created during build process.
Logstash access the configuration within container ,

It is as following:

[Unit]
Description=Logstash 5.6.4
After=docker.service
After=appdata-container-logshipper.mount
Requires=docker.service
OnFailure=notify-failed@%n

[Service]
ExecStartPre=-/usr/bin/docker pull registry/elastic/logstash:5.6.4
ExecStartPre=-/usr/bin/docker rm --force --volumes %n
ExecStart=/usr/bin/docker run --name=%n \
    --user root \
    --add-host "redishub:2.57.0.1" \
    --volume /appdata/log/:/logs \
    --volume /appdata/container/logshipper/logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml:z \
    --volume /appdata/container/logshipper/logstash/config/logstash-jvm.options:/usr/share/logstash/config/jvm.options:z,ro \
    --volume /appdata/container/logshipper/logstash/pipeline:/usr/share/logstash/pipeline:z,ro \
    --volume /appdata/container/logshipper/logstash/patterns:/usr/share/logstash/patterns:z,ro \
    --volume /appdata/container/logshipper/logstash/sincedb:/usr/share/logstash/sincedb:z \
    --env "TZ=Europe/Berlin" \
    --volume /dev/urandom:/dev/random \
    registry/elastic/logstash:5.6.4
ExecStop=/usr/bin/docker stop %n
Restart=always
RestartSec=120
StartLimitInterval=0
TimeoutStartSec=10min

(Magnus Bäck) #4

You can start a container based on that image and supply your own options, including --config.test_and_exit. Make sure you mount the config files into the container but avoid the log and sincedb directory.


(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.