Code Monkey home page Code Monkey logo

boson's Introduction

boson

A command line tool to send lines from through STDIN to the webhook endpoint.

Usage

Usage of boson:
  -body string
        HTTP body for webhook request
  -dry-run
        Run this application with dry-run (i.e. it doesn't send any requests to the webhook endpoint)
  -every-line
        Run with every-line mode. This mode sends all of lines to the webhook endpoint
  -filter-regexp string
        Regexp for line filtering, run with regexp-filter mode; it allows using regexp group and it can use matched groups as "{{ $1 }}", "{{ $2 }}"...
  -header value
        HTTP header for webhook (example: "Content-Type: application/json"). It replaces "{{ line }}" token with got line string and "{{ $N }}" token with correspond group
  -http-method string
        HTTP method for webhook request (default "POST")
  -timeout-sec int
        HTTP timeout for webhook request (default 0, i.e. no-timeout)
  -url string
        URL for webhook endpoint. It replaces "{{ line }}" token with got line string and "{{ $N }}" token with correspond group
  -url-encode-body-replacement
        Encode the replacement of the body (i.e. the contents of "{{ line }}" and "{{ $N }}") of webhook request with url (percent) encoding; for "application/x-www-form-urlencoded"

Example: Send every line to the webhook endpoint

tail -F something.log | boson --every-line --header "Content-Type: application/json" --header "X-Test: Heigh-Ho" --url http://localhost:8080 --body '{"message":"{{ line }}"}'

Example: Send only matched line with a regular expression to the webhook endpoint

tail -F something.log | boson --filter-regexp="^\[error].+" --header "Content-Type: application/json" --header "X-Test: Heigh-Ho" --url http://localhost:8080 --body '{"message":"{{ line }}"}'

Example: Send only matched line with a regular expression with grouping to the webhook endpoint

echo "2020/08/05 18:11:25 [error] hello" | boson --filter-regexp="^(\d+/\d+/\d+ \d+:\d+:\d+) \[error] (.+)" --header "Content-Type: application/json" --header "X-Test: Heigh-Ho" --url http://localhost:8080 --body '{"timestamp":"{{ $1 }}","message":"{{ $2 }}"}'

Author

moznion ([email protected])

boson's People

Contributors

moznion avatar

Stargazers

Akira Sawada avatar Géraud CONTINSOUZAS avatar Márcio Almada avatar uzulla / Junichi Ishida avatar Kei Arima avatar Lubomir Anastasov avatar Masayuki Matsuki avatar

Watchers

James Cloos avatar  avatar  avatar

boson's Issues

Incorrect README's usage ?

I tried this tool ! but not fire.

$ tail -f a |./boson -url "https://notify-api.line.me/api/notify" --header "Content-Type: application/x-www-form-urlencoded" --header "Authorization: Bearer XXX" -body "message=fire"

Bellow line worked.

$ tail -f a |./boson -url "https://notify-api.line.me/api/notify" --header "Content-Type: application/x-www-form-urlencoded" --header "Authorization: Bearer XXX" --body "message=fire"

So, README.md's usage need to be change -body --body.

thanks!

Will url-encode-body break data?

url-encode-body function is great! thanks!

But I got post error from some web api.

$ tail -f /some.log | ~/boson  -url "https://notify-api.line.me/api/notify" --header "Content-Type: application/x-www-form-urlencoded" --header "Authorization: Bearer XXXX" --body "message=got_error:{{ line }}" -url-encode-body
2020/08/04 16:31:57 [error] failed to send data to the webhook destination; statusCode = 400
2020/08/04 16:31:57 [error] failed to send data to the webhook destination; statusCode = 400
2020/08/04 16:31:57 [error] failed to send data to the webhook destination; statusCode = 400
2020/08/04 16:31:57 [error] failed to send data to the webhook destination; statusCode = 400
2020/08/04 16:31:57 [error] failed to send data to the webhook destination; statusCode = 400
2020/08/04 16:31:57 [error] failed to send data to the webhook destination; statusCode = 400
2020/08/04 16:31:57 [error] failed to send data to the webhook destination; statusCode = 400
2020/08/04 16:31:57 [error] failed to send data to the webhook destination; statusCode = 400
2020/08/04 16:31:57 [error] failed to send data to the webhook destination; statusCode = 400
2020/08/04 16:31:57 [error] failed to send data to the webhook destination; statusCode = 400

Could I check post body ?

thanks.

got `socket: too many open files`

I'm using boson for log watch and send alert to line notify.
(over some monthes)

lately, over the weeks. I got some errors.

2020/10/23 12:39:32 [error] Post "https://notify-api.line.me/api/notify": dial tcp: lookup notify-api.line.me on 192.168.0.1:53: dial udp 192.168.0.1:53: socket: too many open files

(same error output around 20 times when one log wrote. 192.168.0.1 is dns resolve server.)

boson was not crashed. but not sent to LINE notify.

I restarted and I will watch the situation.

env: Linux XXXXX 3.10.0-1062.12.1.el7.x86_64 #1 SMP Tue Feb 4 23:02:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
exec: tail -n 1 -F error.log | ~/boson  -url "https://notify-api.line.me/api/notify" --header "Content-Type: application/x-www-form-urlencoded" --header "Authorization: Bearer XXX" --body "message=got error: {{ line }}" --url-encode-body-replacement
deamonize method: screen with detached.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.