Giter VIP home page Giter VIP logo

logstasher's Introduction

Test Dialyzer DocsGitHub release Crowdin Join the chat at https://gitter.im/zotonic/zotonic

Zotonic

Zotonic is the open source, high speed, real-time web framework and content management system, built with Erlang.

It is flexible, extensible and designed from the ground up to support dynamic, interactive websites and mobile solutions.

Zotonic is incredibly fast and wonderfully stable – suited for anything from basic websites to complex distributed applications. It offers an elegant backend for managing content with the flexibility that developers need to build truly amazing applications.

Installation

Documentation

You can find out more about Zotonic on http://zotonic.com, including:

Contributing

Zotonic is an open source project, made possible by the community. If you’d like to contribute, please read the Contributing chapter in the documentation.

If you encounter any issues, please report them in our issue tracker. If you discover any security-related issues, please contact us at [email protected].

License

Zotonic is released under the Apache 2.0 License. Please refer to the included LICENSE file for more information.

Thanks

Thanks to the following services for supporting Open Source:

logstasher's People

Contributors

mworrell avatar rustkas avatar vkatsuba avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

rustkas

logstasher's Issues

Create UDP/TCP servers for common tests

logstasher version

1.0.0

OS version

All

Description

  • Motivation
    We should be sure that after some changes the structure of data is expected and can be sent by different transports.
  • Proposal
    Create test UDP/TCP servers with fake logstash data storing and add those logic into common tests.

Current behavior

UDP/TCP servers are missing in common tests.

Expected behavior

UDP/TCP servers are created and used in common tests.

iolist_to_binary is usualy not the best choice for list values

As discussed in the forum https://erlangforums.com/t/logstasher-is-erlang-logger-formatter-for-logstash/1026/2

Just applying term_to_binary to any list that happens to be a valid iolist is not always intuitive

The one trying to log smth like that:

Tags = ["foo", "bar", "baz"],
logger:info(#{label => something_happened, tags => Tags})

would rater expect it to be logged as

{"label": "something_happened", "tags": ["foo", "bar", "baz"]}

than

{"label": "something_happened", "tags": "foobarbaz"}

In our project we ended up with smth like

term_to_json([C | _] = List) when is_integer(C) ->
    case io_lib:char_list(S) of
      true ->
        unicode:characters_to_binary(List, utf8);  %% string() or specific form of unicode:chardata()
      false ->
        lists:map(fun term_to_json/1, List)  % JS array
    end;

Another issue is that calling iolist_to_binary is not guaranteed to succeed if it's guarded by io_lib:char_list:

> S = "привет", io_lib:char_list(S).       
true
> iolist_to_binary(S).
** exception error: bad argument
     in function  iolist_to_binary/1
        called as iolist_to_binary([1087,1088,1080,1074,1077,1090])
        *** argument 1: not an iodata term

unicode:characters_to_binary(S, utf8) might be a better choice.

Back-off on TCP connection problems

Add a back-off if there are TCP connection or data-send problems.

Proposal:

  • Retry 5 times
  • Backoff for configurable amount of time (default ca. 1 minute?)

And optionally:

  • Buffer last N messages

Overload protection

logstasher version

1.0.0

OS version

Any

Description

  • Motivation
    When running system is under stress load and it logs a lot, there is a risk that singletone logstasher process won't be able to process all the incoming log requests. In this scenario gen_server:call

-spec send(Data :: binary()) -> ok | {error, atom()}.
send(Data) when is_binary(Data) ->
case whereis(?MODULE) of
undefined -> {error, not_started};
Pid -> gen_server:call(Pid, {send, Data})
end.

would timeout which would cause OTP logger to disable this handler.

Also, for some latency-critical systems it might be unacceptable to hung for up to 5s on synchronous log calls.

This might be less of a problem for UDP connection, but since logstasher supports tcp, it may block for quite some time.

  • Proposal
    Handlers in standard OTP logger provide flexible overload protection mechanisms.
    Unfortunately, they are not yet available as a library, so, AFAIK, other logger handler libraries tend to implement their own overload protection:

https://github.com/seriyps/logger_journald/blob/34b5d9cc0c35b06abe05fe2b5b7d826bf69fd8bc/src/logger_journald_h.erl#L120

https://github.com/hauleth/erlang-systemd/blob/8637dadf493d1a520d56cdd74db9813c5b86d669/src/systemd_journal_h.erl#L383

So I think it might be a good idea to add some sort of overload protection to logstasher too.

Current behavior

With TCP connection and high amount of logs, calls to logger:log may take up to 5s and logger handler may crash with timeout and being automatically disabled.

Expected behavior

Some sort of configurable overload protection mechanism. Ideally, with configuration compatible with OTP standard logger overload protection settings https://www.erlang.org/doc/apps/kernel/logger_chapter.html#overload_protection

Config

none

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.