UNPKG

1.89 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*NOTE: Use with caution, very alpha very logging wow*
11
12## Usage
13This 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
16LokiTransport() takes a Javascript object as an input. These are the options that are available:
17
18>`host`
19
20The URL of the Grafana Loki server.
21It should contain everything from the protocol to the port.
22
23>`interval`
24
25*optional*
26
27The interval at which the transport sends batched logs to Loki. **In seconds.**
28
29### Example
30```js
31const { createLogger, transports } = require("winston");
32const LokiTransport = require("winston-loki");
33const options = {
34 ...,
35 transports: [
36 new LokiTransport({
37 host: "http://localhost:3100"
38 })
39 ]
40 ...
41};
42const logger = createLogger(options);
43```
44
45## Developing
46```sh
47npm install
48npm link
49cd ~/your_project
50npm link winston-loki
51npm install
52```
53And you should have a working, requirable winston-loki package under your project's node_modules.
54
55Refer 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
59npm test
60```
61
62Write new ones under `/test`
63
64TODO: Add protobuf as default mode, remove *got* dependency