Skip to content

Commit c40b7a4

Browse files
committed
Initial import of code
1 parent 0fc7f2b commit c40b7a4

File tree

5 files changed

+91
-0
lines changed

5 files changed

+91
-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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,36 @@
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+
## Inputs and Outputs ##
9+
10+
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.
11+
12+
### Examples ###
13+
14+
Here's an example for an `input.conf`
15+
16+
```
17+
input {
18+
redis {
19+
host => "localhost"
20+
data_type => "list"
21+
key => "netways-ansible-input"
22+
}
23+
}
24+
```
25+
26+
and one for `output.conf`.
27+
28+
```
29+
output {
30+
redis {
31+
host => "localhost"
32+
data_type => "list"
33+
key => "netways-ansible-output"
34+
}
35+
}
36+
```

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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
target => "ansible"
13+
id => "ansible_kv"
14+
# doesn't take array as tag_on_failure
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)