-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from zotonic/skeleton
Skeleton of logstasher
- Loading branch information
Showing
16 changed files
with
565 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report of bug for logstasher | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
## `logstasher` version | ||
[Put release version here and update tag link(0.0.0) ...](https://github.com/zotonic/logstasher.git) | ||
|
||
## `OS` version | ||
<!-- Put the `OS` version ... --> | ||
|
||
## Steps to reproduce | ||
<!-- (Optional)Describe steps to reproduce bug ... --> | ||
|
||
## Current behavior | ||
<!-- Describe current behavior ... --> | ||
|
||
## Expected behavior | ||
<!-- Describe expected behavior ... --> | ||
|
||
## Config | ||
<!-- (Optional)Put configuration ... --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for logstasher | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
## `logstasher` version | ||
[Put release version here and update tag link(0.0.0)...](https://github.com/zotonic/logstasher.git) | ||
|
||
## `OS` version | ||
<!-- Put the `OS` version ... --> | ||
|
||
## Description | ||
* **Motivation** | ||
<!-- (Optional)Describe motivation ... --> | ||
* **Proposal** | ||
<!-- (Optional)Describe proposal of the solution ... --> | ||
|
||
## Current behavior | ||
<!-- (Optional)Describe current behavior ... --> | ||
|
||
## Expected behavior | ||
<!-- (Optional)Describe expected behavior ... --> | ||
|
||
## Config | ||
<!-- (Optional)Put configuration ... --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
name: Other Issues | ||
about: Something that's are not covered by the other templates | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
--- | ||
|
||
<!-- Please consider opening a discussion if this is not really an issue --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches: [ $default-branch ] | ||
release: | ||
types: | ||
- created | ||
workflow_dispatch: | ||
|
||
jobs: | ||
ubuntu: | ||
name: "Ubuntu" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
otp: [22.3, 23.3, 24.2] | ||
rebar: [3.18.0] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: ${{matrix.otp}} | ||
rebar3-version: ${{matrix.rebar}} | ||
- name: Tests | ||
run: rebar3 test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Publish to hex.pm | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
publish: | ||
name: "Ubuntu" | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
otp: [24.2] | ||
rebar: [3.18.0] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: ${{matrix.otp}} | ||
rebar3-version: ${{matrix.rebar}} | ||
- name: Publish to Hex.pm | ||
env: | ||
HEX_API_KEY: ${{ secrets.HEX_API_KEY }} | ||
run: | | ||
rebar3 edoc_extensions | ||
rebar3 hex publish -r hexpm --yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,96 @@ | ||
# logstasher | ||
[![Hex.pm Version][hexpm version]][hexpm] | ||
[![Hex.pm Downloads][hexpm downloads]][hexpm] | ||
[![Hex.pm Documentation][hexdocs documentation]][hexdocs] | ||
[![Build Status][gh badge]][gh] | ||
[![Erlang Versions][erlang version badge]][gh] | ||
|
||
Erlang Logger formatter for logstash | ||
|
||
<!-- Badges --> | ||
[hexpm]: https://hex.pm/packages/logstasher | ||
[hexpm version]: https://img.shields.io/hexpm/v/logstasher.svg?style=flat-square | ||
[hexpm downloads]: https://img.shields.io/hexpm/dt/logstasher.svg?style=flat-square | ||
[hexdocs documentation]: https://img.shields.io/badge/hex-docs-purple.svg?style=flat-square | ||
[hexdocs]: https://hexdocs.pm/logstasher | ||
[gh]: https://github.com/zotonic/logstasher/actions/workflows/ci.yml | ||
[gh badge]: https://img.shields.io/github/workflow/status/zotonic/logstasher/CI?style=flat-square | ||
[erlang version badge]: https://img.shields.io/badge/erlang-22.0%20to%2024.2.1-blue.svg?style=flat-square | ||
|
||
|
||
## Hex package | ||
|
||
In `rebar.config`, add the logstasher Hex package to the deps: | ||
|
||
```erlang | ||
{deps, [ | ||
{logstasher, "~> 1.0.0"} | ||
]}. | ||
|
||
``` | ||
|
||
## Erlang Configuration | ||
|
||
In `sys.config`, enable `logstasher_h` as a Logger handler and configure the `logstasher` | ||
application: | ||
|
||
|
||
```erlang | ||
[ | ||
{kernel, [ | ||
{logger, [ | ||
{handler, logstash, logstasher_h, | ||
#{ | ||
level => info | ||
} | ||
} | ||
]} | ||
]}, | ||
|
||
{logstasher, [ | ||
{transport, udp}, % tcp | udp | console | ||
{host, "localhost"}, % inet:hostname() | ||
{port, 5000} % inet:port_number() | ||
]} | ||
]. | ||
``` | ||
|
||
After this, also add the `logstasher` application to your `.app.src` file: | ||
|
||
```erlang | ||
{applications, [ | ||
.... | ||
logstasher, | ||
.... | ||
]}, | ||
``` | ||
|
||
## Logstash Configuration | ||
|
||
```ruby | ||
input { | ||
udp { | ||
codec => json | ||
port => 5000 | ||
queue_size => 10000 | ||
workers => 10 | ||
type => default_log_type | ||
} | ||
} | ||
output { | ||
stdout {} | ||
elasticsearch { | ||
protocol => http | ||
} | ||
} | ||
``` | ||
|
||
## Send data to logstash | ||
|
||
It is possible to send other data to logstash: | ||
|
||
```erlang | ||
logstasher:send_message(<<"Hello world!">>, #{ some => <<"fields">> }). | ||
``` | ||
|
||
A timestamp will be added to the message. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[ | ||
{kernel, [ | ||
{logger, [ | ||
{handler, logstash, logstasher_h, | ||
#{ | ||
level => info%, | ||
%config => #{ | ||
% host => "localhost", | ||
% port => 8080 | ||
%} | ||
} | ||
} | ||
]} | ||
]}, | ||
|
||
{logstasher, [ | ||
{transport, tcp}, % tcp | udp | ||
{host , "localhost"}, % inet:hostname() | ||
{port, 8080} % inet:port_number() | ||
]} | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{erl_opts, [debug_info]}. | ||
|
||
{deps, [ | ||
{jsx, "3.1.0"} | ||
]}. | ||
|
||
{minimum_otp_vsn, "22"}. | ||
|
||
{project_plugins, [ | ||
{rebar3_hex, "~> 7.0.1"}, | ||
{rebar3_edoc_extensions, "~> 0.2.5"} | ||
]}. | ||
|
||
{dialyzer, [{warnings, [no_return, unmatched_returns, error_handling, underspecs]}]}. | ||
|
||
{xref_checks, | ||
[deprecated_function_calls, exports_not_used, locals_not_used, undefined_function_calls]}. | ||
|
||
{cover_enabled, true}. | ||
|
||
{cover_opts, [verbose]}. | ||
|
||
{alias, | ||
[{test, [compile, xref, dialyzer, {ct, "--verbose"}, cover, edoc]}]}. | ||
|
||
{shell, [ | ||
{config, "config/sys.config"}, | ||
{apps, [logstasher]} | ||
]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{"1.2.0", | ||
[{<<"jsx">>,{pkg,<<"jsx">>,<<"3.1.0">>},0}]}. | ||
[ | ||
{pkg_hash,[ | ||
{<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>}]}, | ||
{pkg_hash_ext,[ | ||
{<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>}]} | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{application, logstasher, [ | ||
{description, "The logstasher is Erlang Logger formatter for logstash"}, | ||
{vsn, git}, | ||
{registered, []}, | ||
{mod, {logstasher_app, []}}, | ||
{applications, [ | ||
kernel, | ||
stdlib, | ||
jsx | ||
]}, | ||
{env,[]}, | ||
{modules, []}, | ||
|
||
{licenses, ["Apache-2.0"]}, | ||
{links, [{"github", "https://github.com/zotonic/logstasher.git"}]} | ||
]}. |
Oops, something went wrong.