Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is this repo still working? #90

Closed
nort3x opened this issue Dec 24, 2021 · 8 comments
Closed

is this repo still working? #90

nort3x opened this issue Dec 24, 2021 · 8 comments

Comments

@nort3x
Copy link

nort3x commented Dec 24, 2021

as grafana stated in their official website their api can undergo breaking changes,
and they didn't even listed this project even as an unofficial related library to their project

i hoped i could use this lib (which is currently most popular node lib related to loki) to use it's functionality but i struggled for +8 hours and couldn't make it work,

it's not failing fast i can't even tell if it's facing any issue or not, tried different configurations then used the provided example and tests and yet i can't get what i need

Screenshot from 2021-12-24 22-22-45

@olearycrew
Copy link
Contributor

I'm currently in the same boat, having the same kind of results. Hard to tell if the logs are even hitting the API. I've downloaded and run directly from the latest code to try and figure it out.

@olearycrew
Copy link
Contributor

Okay I think I sorted my problem - it was TLS related but there was no way to easily figure that out.

@nort3x
Copy link
Author

nort3x commented Dec 28, 2021

the docker provided in example also is pulling latest loki and the example doesn't work with that , at least for a temporary solution we need to know which version it has been tested with

it's good piece of work and need more attention towards it <3

@jonim8or
Copy link

Could you maybe try with a fixed version of loki (instead of latest)? That would help clarify what is working and what not.
I ran the examples with latest and 2.4.1, and they both work for me.
image

@crundberg
Copy link

The problem is that Winston returns the timestamp as a string and this transport expects a date. As a workaround I set the option replaceTimestamp to true.

winston-loki/index.js

Lines 55 to 84 in 8af9b48

const { label, labels, timestamp, level, message, ...rest } = info
// build custom labels if provided
let lokiLabels = { level: level }
lokiLabels = Object.assign(lokiLabels, labels)
if (this.labels) {
lokiLabels = Object.assign(lokiLabels, this.labels)
} else {
lokiLabels['job'] = label
}
// follow the format provided
const line = this.useCustomFormat ? info[MESSAGE] : `${message} ${
rest && Object.keys(rest).length > 0 ? JSON.stringify(rest) : ''
}`
// Make sure all label values are strings
lokiLabels = Object.fromEntries(Object.entries(lokiLabels).map(([key, value]) => [key, value ? value.toString() : value]))
// Construct the log to fit Grafana Loki's accepted format
const logEntry = {
labels: lokiLabels,
entries: [
{
ts: timestamp || Date.now().valueOf(),
line
}
]
}

@andestaerfan
Copy link

I use the latest for Loki, Grafana, and Promtail and it's working fine. Please consider that URL for Loki on Grafana must be http://loki:3100 and for winston-loki must be http://localhost:3100

@nort3x
Copy link
Author

nort3x commented Jan 26, 2022

i see some contradictory comments here, let me test it with current main head at
b825d3b

and i will report the results

@briosheje
Copy link

The problem is that Winston returns the timestamp as a string and this transport expects a date. As a workaround I set the option replaceTimestamp to true.

winston-loki/index.js

Lines 55 to 84 in 8af9b48

const { label, labels, timestamp, level, message, ...rest } = info
// build custom labels if provided
let lokiLabels = { level: level }
lokiLabels = Object.assign(lokiLabels, labels)
if (this.labels) {
lokiLabels = Object.assign(lokiLabels, this.labels)
} else {
lokiLabels['job'] = label
}
// follow the format provided
const line = this.useCustomFormat ? info[MESSAGE] : `${message} ${
rest && Object.keys(rest).length > 0 ? JSON.stringify(rest) : ''
}`
// Make sure all label values are strings
lokiLabels = Object.fromEntries(Object.entries(lokiLabels).map(([key, value]) => [key, value ? value.toString() : value]))
// Construct the log to fit Grafana Loki's accepted format
const logEntry = {
labels: lokiLabels,
entries: [
{
ts: timestamp || Date.now().valueOf(),
line
}
]
}

That was my issue, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants