winston-loki icon indicating copy to clipboard operation
winston-loki copied to clipboard

document header options

Open jburghardt opened this issue 2 years ago • 1 comments

It is possible to pass headers as options to the request. This should be documented in the Options part.

jburghardt avatar Mar 03 '22 13:03 jburghardt

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.

jantoine1 avatar May 02 '23 00:05 jantoine1