chore: Basic logging met loki

This commit is contained in:
Tibo De Peuter 2025-02-23 13:56:40 +01:00
parent c07bb959cf
commit 0f8bd3df6a
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
5 changed files with 133 additions and 23 deletions

View file

@ -19,4 +19,31 @@ async function startServer() {
});
}
startServer();
import { LokiClient, LogError, LokiLabels, LogInfo } from 'loki-logger-ts';
const HostData = {
url: "http://localhost:3100/loki/api/v1/push",
};
const labels: LokiLabels = {
source: "Test",
job: "TestJob",
host: "localhost",
};
async function main() {
const client = new LokiClient(HostData.url);
const msg = 'Hello World';
await LogError(client, msg, labels);
await LogInfo(client, 'Dit is een goed bericht', labels);
console.log(client.showMetrics());
console.log(client.getMetrics());
}
main();
// startServer();