/charm-fluentbit

Juju Charmed Operator for Fluentbit

Primary LanguagePythonMIT LicenseMIT

Fluentbit Charmed Operator

Charmed Operator for Fluentbit. This subordinate charm allows to forward logs to a centralized service.

Quickstart

To deploy Fluentbit and forward logs from your Juju Application:

$ juju deploy fluentbit
$ juju relate fluentbit my-application

Forwarding logs

This charm provides a library to facilitate forwarding logs from your charm to a centralized place. To use it, pull the library (with charmcraft fetch-lib charmms.fluentbit.v0.fluentbit) and instantiate a FluentbitClient class in your charm:

class MyCharm(CharmBase):
    def __init__(self, *args):
        super().__init__(*args)

        self._fluentbit = FluentbitClient(self, "fluentbit")

        self.framework.observe(self.on.fluentbit.relation_created,
                               self._fluentbit_relation_created)

    def _fluentbit_relation_created(self, event):
        cfg = [{"input": [("name",     "tail"),
                          ("path",     "/var/log/foo/bar.log"),
                          ("path_key", "filename"),
                          ("tag",      "foo"),
                          ("parser",   "bar")]},
               {"parser": [("name",        "bar"),
                           ("format",      "regex"),
                           ("regex",       "^\[(?<time>[^\]]*)\] (?<log>.*)$"),
                           ("time_key",    "time"),
                           ("time_format", "%Y-%m-%dT%H,%M,%S.%L")]}]
        self._fluentbit.configure(cfg)

Please see the library documentation for more details.

Developing

The code follows PEP8 and PEP257. The supplied Makefile allows one to easily lint and build the charm:

$ make lint
$ make charm

To deploy the locally built charm:

$ juju deploy ./fluentbit.charm

When finishing a pull request, update the CHANGELOG with a brief description of the changes.

Contact

We want to hear from you!

Email us @ info@omnivector.solutions

Bugs

In the case things aren't working as expected, please file a bug.

License

The charm is maintained under the MIT license. See LICENSE file in this directory for full preamble.

Copyright © Omnivector Solutions 2021