From 738f2c6d2a5db49a9bfd9092632d91a838a603f3 Mon Sep 17 00:00:00 2001 From: Tom Hendrikx Date: Sun, 4 Feb 2024 17:09:50 +0100 Subject: [PATCH] Add validation for the logstash configuration --- .github/workflows/test_config_syntax.yml | 12 ++++++++++++ .../{run_tests.yml => test_grok_patterns.yml} | 2 +- test_config_syntax.sh | 9 +++++++++ runtests.sh => test_grok_patterns.sh | 0 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test_config_syntax.yml rename .github/workflows/{run_tests.yml => test_grok_patterns.yml} (94%) create mode 100755 test_config_syntax.sh rename runtests.sh => test_grok_patterns.sh (100%) diff --git a/.github/workflows/test_config_syntax.yml b/.github/workflows/test_config_syntax.yml new file mode 100644 index 0000000..baca5b9 --- /dev/null +++ b/.github/workflows/test_config_syntax.yml @@ -0,0 +1,12 @@ +on: [push] +jobs: + test-syntax: + runs-on: ubuntu-latest + container: + image: logstash:8.12.0 + volumes: + - $(pwd)/../../postfix.grok:/etc/logstash/patterns.d/postfix.grok + - $(pwd)/../../50-filter-postfix.conf:/usr/share/logstash/pipeline/50-filter-postfix.conf + steps: + - name: Validate configuration file syntax + run: logstash --config.test_and_exit -f /usr/share/logstash/pipeline/50-filter-postfix.conf diff --git a/.github/workflows/run_tests.yml b/.github/workflows/test_grok_patterns.yml similarity index 94% rename from .github/workflows/run_tests.yml rename to .github/workflows/test_grok_patterns.yml index 6617931..332dda1 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/test_grok_patterns.yml @@ -1,6 +1,6 @@ on: [push] jobs: - test: + test-patterns: runs-on: ubuntu-latest steps: diff --git a/test_config_syntax.sh b/test_config_syntax.sh new file mode 100755 index 0000000..a48c9c0 --- /dev/null +++ b/test_config_syntax.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +set -eux + +docker run --rm -it \ + --volume $(pwd)/postfix.grok:/etc/logstash/patterns.d/postfix.grok \ + --volume $(pwd)/50-filter-postfix.conf:/usr/share/logstash/pipeline/50-filter-postfix.conf \ + logstash:8.12.0 \ + logstash --config.test_and_exit -f /usr/share/logstash/pipeline/50-filter-postfix.conf diff --git a/runtests.sh b/test_grok_patterns.sh similarity index 100% rename from runtests.sh rename to test_grok_patterns.sh