1 | # winston-loki
|
2 | [![npm version](https://badge.fury.io/js/winston-loki.svg)](https://badge.fury.io/js/winston-loki)
|
3 | [![Build Status](https://travis-ci.com/JaniAnttonen/winston-loki.svg?branch=master)](https://travis-ci.com/JaniAnttonen/winston-loki)
|
4 | [![Coverage Status](https://coveralls.io/repos/github/JaniAnttonen/winston-loki/badge.svg?branch=master)](https://coveralls.io/github/JaniAnttonen/winston-loki?branch=master)
|
5 | [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
|
6 |
|
7 |
|
8 | A Grafana Loki transport for the nodejs logging library Winston.
|
9 |
|
10 | *NOTE: Use with caution, very alpha very logging wow*
|
11 |
|
12 | ## Usage
|
13 | This Winston transport is used similarly to other Winston transports. Require winston and define a new LokiTransport() inside its options when creating it.
|
14 |
|
15 | ### Options
|
16 | LokiTransport() takes a Javascript object as an input. These are the options that are available:
|
17 |
|
18 | >`host`
|
19 |
|
20 | The URL of the Grafana Loki server.
|
21 | It should contain everything from the protocol to the port.
|
22 |
|
23 | >`interval`
|
24 |
|
25 | *optional*
|
26 |
|
27 | The interval at which the transport sends batched logs to Loki. **In seconds.**
|
28 |
|
29 | ### Example
|
30 | ```js
|
31 | const { createLogger, transports } = require("winston");
|
32 | const LokiTransport = require("winston-loki");
|
33 | const options = {
|
34 | ...,
|
35 | transports: [
|
36 | new LokiTransport({
|
37 | host: "http://localhost:3100"
|
38 | })
|
39 | ]
|
40 | ...
|
41 | };
|
42 | const logger = createLogger(options);
|
43 | ```
|
44 |
|
45 | ## Developing
|
46 | ```sh
|
47 | npm install
|
48 | npm link
|
49 | cd ~/your_project
|
50 | npm link winston-loki
|
51 | npm install
|
52 | ```
|
53 | And you should have a working, requirable winston-loki package under your project's node_modules.
|
54 |
|
55 | Refer to https://github.com/grafana/loki/blob/master/docs/api.md for documentation about the available endpoints, data formats etc.
|
56 |
|
57 | ### Run tests
|
58 | ```sh
|
59 | npm test
|
60 | ```
|
61 |
|
62 | Write new ones under `/test`
|
63 |
|
64 | TODO: Add protobuf as default mode, remove *got* dependency
|