UNPKG

2.03 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:
15
16>`host`
17
18The URL of the Grafana Loki server.
19It should contain everything from the protocol to the port.
20
21>`interval`
22
23*optional*
24
25The interval at which the transport sends batched logs to Loki. **In seconds.**
26
27>`json`
28
29*optional*
30
31Switch to JSON transport instead of Protobuf.
32
33### Example
34```js
35const { createLogger, transports } = require("winston");
36const LokiTransport = require("winston-loki");
37const options = {
38 ...,
39 transports: [
40 new LokiTransport({
41 host: "http://localhost:3100"
42 })
43 ]
44 ...
45};
46const logger = createLogger(options);
47```
48
49## Developing
50```sh
51npm install
52npm link
53cd ~/your_project
54npm link winston-loki
55npm install
56```
57And you should have a working, requirable winston-loki package under your project's node_modules.
58
59Refer to https://github.com/grafana/loki/blob/master/docs/api.md for documentation about the available endpoints, data formats etc.
60
61Grafana 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.
62
63### Run tests
64```sh
65npm test
66```
67
68Write new ones under `/test`
69
70TODO: Remove *got* dependency