winston-loki
winston-loki copied to clipboard
document header options
It is possible to pass headers as options to the request. This should be documented in the Options part.
Oh man, this would have saved me several hours today. I request from the transport wasn't returning an HTTP error, even though it wasn't getting a successful HTTP response, and I couldn't tell because the transport isn't handling this as a failure. This is a separate issue here: https://github.com/JaniAnttonen/winston-loki/issues/98
The failed HTTP error I was getting was a 401 "no org id". The reason for the failed HTTP response was because in a multi-tenant configuration, Loki requires the "X-Scope-OrgID" header to be set to the tenant ID. Using the undocumented "headers" option, one can set this like so:
new LokiTransport({
headers: {
"X-Scope-OrgID": "tenant1",
},
...
});
Hopefully this helps others avoid the same confusion I ran into.