Skip to content

requilence/logspout-regexp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logspout-regexp

A minimalistic adapter for github.com/gliderlabs/logspout to match docker containers logs with regexp and notify in case the match found.

Currently, supporting Telegram and StdErr as output.

How to build

Follow the instructions in https://github.com/gliderlabs/logspout/tree/master/custom on how to build your own Logspout container with custom modules.

Basically just copy the contents of the custom folder and include:

package main

import (
  _ "github.com/requilence/logspout-regexp"
)

in modules.go. Or just clone this repo and use logspout-module dir from this repo.

Then you can run docker build -t logspout-regexp . inside this dir.

How to use

Use by setting a docker environment variable: ROUTE_URIS=regexp://bot?file=regexps.txt&hide_matched_string=1"

The default transport is stderr, but this adapter mainly created to work with Telegram. You should put the right bot's token(you've got from @BotFather and chat's id.

Here is an example: ROUTE_URIS=regexp+tg://bot?file=regexps.txt&throttle_seconds=600&hide_matched_string=1&chat=123&token=112233444:AAEfzA2_Q-FnUfasuib2_DAfdsn23jnK5s6QcQ"

Full command to run docker container with logspout-regexp:

docker run --name="logspout" \
    --volume=/var/run/docker.sock:/var/run/docker.sock \
    --mount type=bind,source=$(pwd)/regexps.txt,target=/regexps.txt \
    -e "ROUTE_URIS=regexp+tg://bot?file=regexps.txt&throttle_seconds=600&hide_matched_string=1&chat=123&token=112233444:AAEfzA2_Q-FnUfasuib2_DAfdsn23jnK5s6QcQ" \
    logspout-regexp:latest

Regexps file

In your regexps.txt you can put regexps to match containers logs. Each line should be a new regexp:

(?i)([A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,24})
part_of_sensitive_info

About

logspout regexp adapter to match docker containers logs and send them to Telegram chat

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published