https://github.com/davidedantonio/pino-fluentd
:evergreen_tree: send pino logs to Fluentd
https://github.com/davidedantonio/pino-fluentd
fluentd fluentd-plugin nodejs pino
Last synced: 3 months ago
JSON representation
:evergreen_tree: send pino logs to Fluentd
- Host: GitHub
- URL: https://github.com/davidedantonio/pino-fluentd
- Owner: davidedantonio
- License: mit
- Created: 2019-01-15T12:30:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-02T10:19:09.000Z (5 months ago)
- Last Synced: 2024-10-30T17:47:52.772Z (4 months ago)
- Topics: fluentd, fluentd-plugin, nodejs, pino
- Language: JavaScript
- Homepage:
- Size: 467 KB
- Stars: 17
- Watchers: 3
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# pino-fluentd
[](https://travis-ci.com/davidedantonio/pino-fluentd) [](http://standardjs.com/) [](https://greenkeeper.io/) 
Send [pino](https://github.com/pinojs/pino) logs to [Fluentd](https://www.fluentd.org/). This plugin is fully inspired to [pino-elasticsearch](https://github.com/pinojs/pino-elasticsearch)
Under the hood the official [fluent-logger-node](https://github.com/fluent/fluent-logger-node) module is used.
## What is Fluentd?
[Fluentd](https://www.fluentd.org/) is an open source data collector for unified logging layer. Fluentd allows you to unify data collection and consumption for a better use and understanding of data.
## Install
If you want to use `pino-fluentd` you must first install globally on your machine
```
npm install pino-fluentd -g
```## Usage
```
pino-fluentdTo send pino logs to fluentd:
cat log | pino-fluentd --tag debug --trace-level info
Flags
-h | --help Display Help
-v | --version Display Version
-H | --host the IP address of fluentd; default: 127.0.0.1
-p | --port the port of fluentd; default: 24224
-t | --tag the name of the tag to use; default: pino
-k | --key the name of the type to use; default: log
-T | --timeout set the socket to timetout after timeout milliseconds of inactivity
-ri | --reconnect-interval The reconnect interval in milliseconds
-fi | --flush-interval The flush interval in milliseconds
-l | --trace-level trace level for the fluentd client, default 'error' (trace, debug, info, warn, error, fatal)
```You can then use [Elasticsearch](https://www.elastic.co/products/elasticsearch) and [Kibana](https://www.elastic.co/products/kibana) to browse and visualize your logs, or whatever you want. A full list of Data Output is [here](https://www.fluentd.org/dataoutputs).
## Setup and testing
Setting up `pino-fluentd` is easy and you can use the bundled `docker-compose-*.yml` file to bring up a Fluentd with or without Elasictsearch and Kibana containers.
You will need [docker](https://www.docker.com/) and [docker-compose](https://docs.docker.com/compose/), then in this project folder, launch `docker-compose -f docker-compose-*.yml up`.
You can test it by launching `node example | pino-fluentd`, in this project folder. You will need to have pino-fluentd installed globally.
## Forward to Elasticsearch
Fluentd can be configured to forward your logs to ElasticSearch (and search them with Kibana maybe?).
In order to use fluentd with ElasticSearch you need to install the fluent-plugin-elasticsearch plugin on your fluentd instance:```
gem install fluent-plugin-elasticsearch
```In your Fluentd configuration file, use `@type elasticsearch`. Additional configuration is optional, default values would look like this:
```
# File fluent.conf@type forward
port 24224
bind 0.0.0.0@type copy
@type elasticsearch
host elasticsearch
port 9200
flush_interval 10s
@type stdout
```
When Fluentd receives some logs from `pino-fluentd` and has flushed them to Elasticsearch after a certain interval (in this example 10 seconds), you can view, search and visualize, the log data using Kibana.
## License
Licensed under [MIT](./LICENSE)