Demonstrates sending logs to InfluxDB2 via telegraph
Make sure you have installed Docker and docker-compose locally.
I refer to these articles (choose right system version!):
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
After logging in, you should see the main view.
Click on Build a Dashboard
Then choose Create Dashboard
Change dashboard name to Logs
Click on Add cell
On this view:
- Change cell name - click on
Name this cell
and typeexampleService1
- 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)
- Select Histogram from view type selector
- Click Customize button and change
Data
section- X Column - select
_time
- Group by - mark only
logLevel
- X Column - select
- Click on Submit button
- Save cell by clicking on check mark.
Then you shoud have one cell on your dashboard.
- Click on cell settings and select Clone
- Click on cloned cell settings and select Configure
- 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)
- Change name of cell to
exampleService2
and save
Then on the log dashboard you should have 2 cells.
To set autorefresh click on Enable Auto Refresh
and select:
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.
docker-compose down -v
docker rmi harvve/tslog-influxdb-transport-demo
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
andinfluxdb2
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
Under the MIT License. See LICENSE
for more information.