https://github.com/athoune/yangtze
Watch for text pattern using tokens and radix tree.
https://github.com/athoune/yangtze
golang-library logging
Last synced: 5 months ago
JSON representation
Watch for text pattern using tokens and radix tree.
- Host: GitHub
- URL: https://github.com/athoune/yangtze
- Owner: athoune
- Created: 2017-12-23T23:07:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-03-29T17:15:49.000Z (over 2 years ago)
- Last Synced: 2024-07-04T03:01:28.456Z (almost 2 years ago)
- Topics: golang-library, logging
- Language: Go
- Size: 68.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Security: SECURITY.md
Awesome Lists containing this project
README
Yangtze (长江 Yángzǐ Jiāng)
===========================
[](https://drone.garambrogne.net/athoune/yangtze)
Watch for text pattern using tokens and radix tree.
Yangtze target is filtering massive flow of logs.
Syntax
------
The pattern syntax is crude. The line is split on tokens. Tokens contain letter, digit, `_` and `-`, all other things disapear.
The pattern syntax use specific tokens.
* `.` one token
* `?` zero or one token
* `...` one or more tokens
Example
-------
One boring example from my `/var/log/auth.log` :
Mar 7 17:51:50 sd-127470 sshd[12455]: Failed password for invalid user cron from 51.15.72.126 port 59758 ssh2
Mar 7 17:51:33 sd-127470 sshd[12453]: Failed password for root from 182.100.67.129 port 58472 ssh2
The pattern should be :
Failed password for ... from ... port . ssh2
API
---
```golang
idx, err := index.NewSimpleIndex()
err = i.AddPatternBytes([]byte("Failed password for ... from ... port . ssh2"))
_, ok := i.ReadLine([]byte("Mar 7 17:51:50 sd-127470 sshd[12455]: Failed password for invalid user cron from 51.15.72.126 port 59758 ssh2"))
```
Licence
-------
3 terms BSD licence, ©2017 Mathieu Lecarme