Skip to content

harvve/tslog-influxdb-transport-demo

Repository files navigation

tslog-influxdb-transport-demo

Demonstrates sending logs to InfluxDB2 via telegraph

Prerequisites

Make sure you have installed Docker and docker-compose locally.

I refer to these articles (choose right system version!):

Getting started

Via Docker

The simplest and fastest solution is to run the demo in a docker environment to do this do the following:

docker-compose up -d

Go to page http://localhost:8086/signin and login to InfluxDB2:

Login: influxadminuser
Password: influxadminuserpassword

Vizualize logs

After logging in, you should see the main view.

Click on Build a Dashboard

InfluxDB home view

Then choose Create Dashboard

InfluxDB dashboards view

Change dashboard name to Logs

Click on Add cell

InfluxDB logs view

On this view:

InfluxDB add cell

  1. Change cell name - click on Name this cell and type exampleService1
  2. Click on Script Editor button and paste flux formula:
from(bucket: "harvve_demo_bucket")
  |> range(start: -2h)
  |> filter(fn: (r) => r["_measurement"] == "exampleService1Logs" and r._field == "logLevelId")
  |> window(every: 10s)
  1. Select Histogram from view type selector
  2. Click Customize button and change Data section
    • X Column - select _time
    • Group by - mark only logLevel
  3. Click on Submit button
  4. Save cell by clicking on check mark.

Then you shoud have one cell on your dashboard.

  1. Click on cell settings and select Clone
  2. Click on cloned cell settings and select Configure
  3. On edit view change measurement container in Script Editor to exampleService2Logs:
from(bucket: "harvve_demo_bucket")
  |> range(start: -2h)
  |> filter(fn: (r) => r["_measurement"] == "exampleService2Logs" and r._field == "logLevelId")
  |> window(every: 10s)
  1. Change name of cell to exampleService2 and save

Then on the log dashboard you should have 2 cells.

InfluxDB cell on dashboard

To set autorefresh click on Enable Auto Refresh and select:

InfluxDB autorefresh dashboard cells

Confirm dialog.

Now, you should see logs from two services on your Logs dashboard.

Important! The demo environment creates new logs all the time, remember to turn it off at the end of testing.

Clean up

docker-compose down -v
docker rmi harvve/tslog-influxdb-transport-demo

Locally

If you want to start program via ts-node-dev first of all you need to create copy of .env.default:

cp .env.default .env

Make sure you have configured and running instance of telegraf and influxdb2

Change ADDRESS and PORT in a copy of your .env file to direct to the running Telegraph instance.

then you can run:

npm run debug

License

Under the MIT License. See LICENSE for more information.

Acknowledgments

About

Demonstrates sending logs to InfluxDB2 via telegraph

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published