Skip to content

A simple playground for sending logs easily into Loki from Node.js without the need for Promtail.

Notifications You must be signed in to change notification settings

leventebalogh/playground-nodejs-loki-grafana

Repository files navigation

Node.js + Loki + Grafana

This is a simple playground for sending random logs from a Node.js service to Loki and then querying them using Grafana.

 Node.JS      (:8080)        Loki         (:3100)       Grafana        (:3000)
+-------------------+       +-------------------+      +---------------------+
|                   |       |                   |      |                     |
|   Sends logs      |       |                   |      |  Query with         |
|   using Winston   |------->                   <------|  LogQL              |
|                   |       |                   |      |                     |
|                   |       |                   |      |                     |
+-------------------+       +-------------------+      +---------------------+

Screenshot


How are the logs sent?

The logs are sent using winston-loki which exposes a transform that pushes them directy to the /loki/api/v1/push API endpoint of Loki.


Start

# Starts the following services:
# - Node.js - http://localhost:8080 
# - Loki - http://localhost:3100 
# - Grafana - http://localhost:3000 
$ docker-compose up

Visit http://localhost:3000/explore for playing around with the metrics. (The service is scraped for random metrics every 1s for more frequent data)


Development

# Starts the Node.js service and restarts it on changes
$ yarn dev

# Starts Loki and Grafana
$ docker-compose up loki grafana

About

A simple playground for sending logs easily into Loki from Node.js without the need for Promtail.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published