UNPKG

2.59 kBMarkdownView Raw
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
8A Grafana Loki transport for the nodejs logging library Winston.
9
10## Usage
11This Winston transport is used similarly to other Winston transports. Require winston and define a new LokiTransport() inside its options when creating it.
12
13### Options
14LokiTransport() takes a Javascript object as an input. These are the options that are available, __required in bold__:
15
16| **Parameter** | **Description** | **Example** |
17| ---------------- | --------------------------------------------------------- | -------------------------------- |
18| __`host`__ | URL for Grafana Loki | http://localhost:3100 |
19| `interval` | The interval at which batched logs are sent in seconds | 30 |
20| `json` | Use JSON instead of Protobuf for transport | true |
21| `batching` | If batching is not used, the logs are sent as they come | true |
22| `clearOnError` | Discard any logs that result in an error during transport | true |
23
24### Example
25```js
26const { createLogger, transports } = require("winston");
27const LokiTransport = require("winston-loki");
28const options = {
29 ...,
30 transports: [
31 new LokiTransport({
32 host: "http://localhost:3100"
33 })
34 ]
35 ...
36};
37const logger = createLogger(options);
38```
39
40## Developing
41```sh
42npm install
43npm link
44cd ~/your_project
45npm link winston-loki
46npm install
47```
48And you should have a working, requirable winston-loki package under your project's node_modules.
49
50Refer to https://github.com/grafana/loki/blob/master/docs/api.md for documentation about the available endpoints, data formats etc.
51
52Grafana Loki *doesn't have any official releases or version numbers* as of now, so if the API is changed, it's going to be fun, but it's working as of now.
53
54### Run tests
55```sh
56npm test
57```
58
59Write new ones under `/test`
60
61TODO: Remove *got* dependency