Skip to content

Commit 95a0a5d

Browse files
authored
Merge pull request #1 from NETWAYS/initial
Initial import of code
2 parents 0fc7f2b + efcfaa0 commit 95a0a5d

File tree

5 files changed

+94
-0
lines changed

5 files changed

+94
-0
lines changed

.github/workflows/logstash.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Logstash Syntax
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
branches:
8+
- main
9+
pull_request:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Check out code
17+
uses: actions/checkout@v2
18+
19+
- name: Install dependencies
20+
run: |
21+
sudo apt-get update
22+
sudo apt-get install gpg
23+
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
24+
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
25+
sudo apt-get update
26+
sudo apt-get install logstash
27+
mkdir -p /tmp/logstash/data /tmp/logstash/logs
28+
29+
- name: Test with Logstash
30+
run: |
31+
/usr/share/logstash/bin/logstash --path.settings /etc/logstash/ --path.config '*conf' --path.data /tmp/logstash/data --path.logs /tmp/logstash/logs --config.test_and_exit

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
input.conf
2+
output.conf

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
11
# ansible-logstash-pipeline
22
Logstash pipeline for processing Ansible logs
3+
4+
[![CI](https://github.com/netways/ansible-logstash-pipeline/workflows/Logstash%20Syntax/badge.svg?event=push)](https://github.com/netways/ansible-logstash-pipeline/actions?query=workflow%3A%22Logstash+Syntax%22)
5+
6+
Minimalist pipeline to parse Ansible logs on managed hosts
7+
8+
Note, that Ansible uses it's module as part of the process name. So make the condition to route into this pipeline a regex check: `[process][name] =~ "ansible"`.
9+
10+
## Inputs and Outputs ##
11+
12+
If you use files called `input.conf` and `output.conf` they will not collide with this rules, even when you want to pull new versions.
13+
14+
### Examples ###
15+
16+
Here's an example for an `input.conf`
17+
18+
```
19+
input {
20+
redis {
21+
host => "localhost"
22+
data_type => "list"
23+
key => "netways-ansible-input"
24+
}
25+
}
26+
```
27+
28+
and one for `output.conf`.
29+
30+
```
31+
output {
32+
redis {
33+
host => "localhost"
34+
data_type => "list"
35+
key => "netways-ansible-output"
36+
}
37+
}
38+
```

filter-10-module.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
filter {
2+
grok {
3+
match => ["[process][name]","ansible-%{GREEDYDATA:[ansible][module]:string}"]
4+
id => ansible_module
5+
tag_on_failure => ["_grokparsefailure","ansible_module_failed"]
6+
}
7+
}

filter-50-invoked.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
filter {
2+
# remove if if really *every* message starts like this
3+
if [message] =~ /Invoked with/ {
4+
5+
grok {
6+
match => ["message", "Invoked with %{GREEDYDATA:[@metadata][ansiblekv]}"]
7+
id => "ansible_invoked"
8+
tag_on_failure => ["_grokparsefailure","ansible_invoked_failed"]
9+
}
10+
11+
kv {
12+
source => "[@metadata][ansiblekv]"
13+
target => "ansible"
14+
id => "ansible_kv"
15+
# doesn't take array as tag_on_failure
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)