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

Bulk log sending is broken in v4.0.1 #71

Open
Klem3n opened this issue Sep 1, 2023 · 0 comments
Open

Bulk log sending is broken in v4.0.1 #71

Klem3n opened this issue Sep 1, 2023 · 0 comments

Comments

@Klem3n
Copy link

Klem3n commented Sep 1, 2023

Sending logs in bulk is currently broken in version 4.0.1 of the library, because only one of the logs is sent to Loggly while others are disarded. The http request options contain the wrong data.

Reproduction script:

import loggly from "node-loggly-bulk";

const subdomain = "REPLACE_ME";
const token = "REPLACE_ME"

const client = loggly.createClient({
  subdomain,
  json: true,
  token,
  tags: ["test"],
  isBulk: true,
  useTagHeader: false,
  bufferOptions: {
    size: 2
  },
});

client.log({
  message: "test",
  id: 10091
});
client.log({
  message: "test",
  id: 10091
});

//Wait for request to finish before exiting
console.log("Press any key to exit");

process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.on("data", process.exit.bind(process, 0));

Sent axios request options

{
  uri: 'https://logs-01.loggly.com/bulk/xxx/tag/test/',
  method: 'POST',
  headers: {},
  proxy: null,
  data: '{"message":"test","id":10091}',
  body: '{"message":"test","id":10091}\n{"message":"test","id":10091}'
}

Expected axios request options

{
  uri: 'https://logs-01.loggly.com/bulk/xxx/tag/test/',
  method: 'POST',
  headers: {},
  proxy: null,
  data: '{"message":"test","id":10091}\n{"message":"test","id":10091}'
}

I think the issue is related to migration from request library to axios library. The data in requestOptions is set to body.

Fix

This issue can be fixed by changing .body to .data in common.js#236. But I'm not sure if this is the correct solution.

https://github.com/loggly/node-loggly-bulk/blob/39163147f9bc028850935a08faa76bbe09cd01f8/lib/loggly/common.js#L236C21-L236C21

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

1 participant