0

I have an application (Logstash) running on a Linux VM and the settings for it are on a GitLab repo. What I want is for the VM to pull the latest version of the settings file and restart the service when I push an update to the repo.

What is the easiest way of achieving this?

1

There's no "easiest" way per se, there's the better way for you. I'd recommend using a configuration management tool like Chef or Puppet (for a pull model) for which there's already resources to configure and handle logstash restarts.

That said logstash is able to watch its config file and reload it itself, quoting elastic.co documentation:

Starting with Logstash 2.3, you can set Logstash to detect and reload configuration changes automatically.

To enable automatic config reloading, start Logstash with the --config.reload.automatic (or -r) command-line option specified. For example:

bin/logstash –f apache.config --config.reload.automatic

So you may just set a crontab to git pull your repository periodically and have logstash reload itself.

0

I would suggest jenkins for this as it can easily integrate wit github, gitlab or any other SCM. Jenkins jobs can be setup such that the build runs whenever you push a commit to the gitlab repo. In the job, you can mention to update the logstash config on the linux VM and then reload/restart your service.

Here are some articles which can help you in proceeding further.

http://fourkitchens.com/blog/article/trigger-jenkins-builds-pushing-github/

https://oncomputingwell.princeton.edu/2018/01/triggering-a-jenkins-build-every-time-changes-are-pushed-to-a-git-branch-on-github/

NOTE: If you want to setup this just for a single node, You can also create a very simple script which should pull from github, say every 5 mins, and if the changes are there, it can update logstash config and simply restart the logstash.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.