Skip to content

Commit

Permalink
Merge pull request #193 from whyscream/validate-config-syntax
Browse files Browse the repository at this point in the history
Validate config syntax
  • Loading branch information
whyscream authored Feb 4, 2024
2 parents e0e8cf5 + 10dfac9 commit 858e0eb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/test_config_syntax.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Validate configuration syntax
on: [push]
jobs:
test-syntax:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
docker run --rm \
--volume ./postfix.grok:/etc/logstash/patterns.d/postfix.grok \
--volume ./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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Test grok patterns
on: [push]
jobs:
test:
test-patterns:
runs-on: ubuntu-latest

steps:
Expand Down
8 changes: 5 additions & 3 deletions ALTERNATIVE-INPUTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ Various other Logstash filters can produce the needed input fields (`program` an
----------------

```
grok {
match => { "message" => "%{SYSLOGTIMESTAMP:timestamp} %{SYSLOGHOST} %{DATA:program}(?:\[%{POSINT}\])?: %{GREEDYDATA:message}" }
overwrite => ["timestamp", "message"]
filter {
grok {
match => { "message" => "%{SYSLOGTIMESTAMP:timestamp} %{SYSLOGHOST} %{DATA:program}(?:\[%{POSINT}\])?: %{GREEDYDATA:message}" }
overwrite => ["timestamp", "message"]
}
}
```

9 changes: 9 additions & 0 deletions test_config_syntax.sh
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.

0 comments on commit 858e0eb

Please sign in to comment.