Skip to content

Commit

Permalink
Merge pull request slackhq#7 from slackhq/line-parser
Browse files Browse the repository at this point in the history
Simple line parser program for go-audit lines
  • Loading branch information
nbrownus authored Dec 1, 2016
2 parents 18e072c + 372a0d3 commit b0c2de2
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ go-audit.yaml
*.test
*.deb
*.out
node_modules
20 changes: 20 additions & 0 deletions contrib/line-parser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## `line-parser`

This program uses [`streamstash`](https://github.com/nbrownus/streamstash) to decode `go-audit` output

It takes log lines from stdin and outputs the decoded json on stdout

### Install

Make sure you have [nodejs](https://nodejs.org/en/download/) installed, the latest LTS version is advised.

Then either run `npm install` within this directory or `npm install -g https://github.com/nbrownus/streamstash#2.0`
to install `streamstash` globally

### Usage

If you already have `go-audit` logging to a local file then your best bet is to run the following command

```
tail -f /path/to/file.log | ./line-parser
```
36 changes: 36 additions & 0 deletions contrib/line-parser/line-parser
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env node

var StreamStash = require('streamstash')

var logger = new StreamStash.Logger({ level: 0 }),
streamStash = new StreamStash({ logger: logger })

process.stdin.on('end', function () {
process.exit(0)
})

streamStash.addInputPlugin(new StreamStash.inputs.StdInInput(
{
streamStash: streamStash,
EventContainer: StreamStash.EventContainer,
logger: logger
}
))

streamStash.addOutputPlugin(new StreamStash.outputs.StdOutOutput(
{
streamStash: streamStash,
logger: logger
}
))

streamStash.addFilter(function (event) {
StreamStash.parsers.goAuditParser(event)

delete event.data['event_source']
delete event.data['_type']

event.next()
})

streamStash.start()
9 changes: 9 additions & 0 deletions contrib/line-parser/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "line-parser",
"description": "Parses go-audit lines from stdin, parses, and outputs on stdout",
"license": "MIT",
"version": "1.0.0",
"dependencies": {
"streamstash": "https://github.com/nbrownus/streamstash#2.0"
}
}

0 comments on commit b0c2de2

Please sign in to comment.