wizcorp / node-graylog2 Goto Github PK
View Code? Open in Web Editor NEWThis project forked from stelcheck/node-graylog2
Graylog2 client library for Node.js
License: Other
This project forked from stelcheck/node-graylog2
Graylog2 client library for Node.js
License: Other
In looking at https://github.com/Wizcorp/node-graylog2/blob/master/graylog.js, I don't think this is implemented, but I wanted to confirm for sure that there isn't a built-in way to pass a configuration property to set the minimal level to log. The idea is that you can code all of the various logging events, and their respective levels, in your application, and then set what level(s) get sent off to Graylog in your configuration.
It took us a while to figure out why our messages were not being logged.
Our GrayLog2 GELF port was firewalled, but we didn't receive any feedback at all. It would be great to have more reliable error messages.
Thanks!
Attempting to send a large message causes a problem in graylog2.js (167):
if (chunkCount > 128) {
return that.emit('error', new Error('Cannot log messages bigger than ' + (dataSize * 128) + ' bytes'));
}
This is causing my application to crash. Is it possible to log a warning, and continue the application? I don't want to have to wrap all my logging calls with exception handling.
Hello!
After installing this module, graylog2 ran into a problem.
After npm i graylog2 was building nodejs 16.13.0 and getting Module not found: Error: Can't resolve 'dgram'
Then found a solution by adding to webpack.mix.js
mix.webpackConfig ({
node: {
fs: 'empty',
dgram: 'empty',
}
});
The build error did not appear anymore. but when using the graylog2 module itself in my project another error occurred: "dgram.createSocket is not a function"
How can you solve these problems in order to use this module by means of the front?
"vuex": "3.5.1",
"webpack": "4.44.2",
"vue": "2.6.10"
nodejs: 16.13.0
hello, i was assuming that if the graylog server was down , the on error would be called.
if the server is up, my messages are being sent correctly and can be seen on graylog
i am using version 0.1.3
this is my code snippet:
thanks for any help
var gl2 = new graylog2.graylog({
servers: config.loggingService.graylog2.servers,
bufferSize: config.loggingService.graylog2.bufferSize
});
gl2.on('error', function (error) {
console.error('Error while trying to write to graylog2:', error);
});
Add support for typescript and @type file.
Hi, I just recently tried your package with the following code snippet:
const graylog2 = require("graylog2");
const logger = new graylog2.graylog({
servers: [
{ "host": "52.136.248.240", port: 8514 }
],
// hostname: "test.name", // the name of this host
// (optional, default: os.hostname())
facility: "Banana.js", // the facility for these log messages
// (optional, default: "Node.js")
// bufferSize: 1350 // max UDP packet size, should never exceed the
// MTU of your system (optional, default: 1400)
});
logger.on("error", function (error) {
console.error("Error while trying to write to graylog2:", error);
});
logger.log("InvalidChecksum", JSON.stringify({ name: "Error", message: "The packet is corrupted. CRC-16-IBM not matching.", info: 1 }));
logger.close(function(){
console.log('All done - cookie now?');
process.exit();
});
So, as you can see, there are several things I ought to expect when check the graylog logs, like for example, the facility being "Banana.js".
This however, is not the case. graylog2 seems to be unable to understand my log, and parses everything as a single string. I have attached a screenshot that exemplifies this:
From the image, you can see that a few things are not quite right:
I assume this is either a config issue, or the module is not communication correctly with graylog2.
TypeError: Cannot read property 'split' of undefined
at graylog.log [as _log] (/Users/.....node_modules/graylog2/graylog.js:146:34)
at graylog.error (/Users/.....node_modules/graylog2/graylog.js:93:17)
Graylog code:
} else if (short_message.stack && short_message.message) {
// Short message is an Error message, we process accordingly
message.short_message = short_message.message;
message.full_message = short_message.stack;
// extract error file and line
fileinfo = message.stack.split('\n')[0];
Looking at this, the last line message.stack
should be short_message.stack
.
Message is a newly build object within the library which does not contain a stack trace by default.
GELF documentation specifies that we can log additional fields by adding underscore before them. How can we do that in this library?
graylog not log!
i am using graylog2 in several projects. nodeJS and meteorJS
but seems that some logs are missed!!
after a lot of headache we figured out exactly what was the problem.
in json object that we sent as detailes, we used with keywords from graylog for field names.
graylog don't log them! and not raised any error or warning!!!
it's crazy! how the developer can found this problem? and how he can know from which keywords he need to avoid??
for example: 'error', 'host' are keyword .
so if you write:
catch(ex){
logger.error("error in registration", "an exception raised through registration process", {error: ex})
}
nothing log!!!
but if :
logger.error("error in registration", "an exception raised through registration process", {err: ex})
all it's ok!!!!
line 112 - 121
var payload,
fileinfo,
that = this,
field = '',
message = {
version : '1.0',
118 -->> timestamp : (timestamp || new Date()).getTime() / 1000, <<--
host : this.hostname,
facility : this.facility,
level : level
};
There have been some committed bug fixes in master which make for potential candidate release of 0.2.2.
Example https://github.com/Wizcorp/node-graylog2/blob/v0.2.1/graylog.js#L146 where error logging uses the incorrect object at tag 0.2.1.
@0.2.1
fileinfo = message.stack.split('\n')[0];
fileinfo = short_message.stack.split('\n')[0];
Suggest a new version push to npmjs, or are there other issues holding back?
Would be great if you could also console log messages during development so if you don't have access to graylog you can instantly get feedback without duplicating logging messages.
I know we can log additional fields, using a parameter in the functions:
function (short_message, full_message, additionalFields, timestamp)
But I'd like to set an additional field at the initial configuration:
var logger = new graylog2.graylog({
servers: [
{ 'host': '127.0.0.1', port: 12201 },
{ 'host': '127.0.0.2', port: 12201 }
],
hostname: 'server.name', // the name of this host
// (optional, default: os.hostname())
facility: 'Node.js', // the facility for these log messages
// (optional, default: "Node.js")
bufferSize: 1350 // max UDP packet size, should never exceed the
// MTU of your system (optional, default: 1400)
///////////////additional field
"_additionalField": "content"
});
Is it possible?
How can I log stream to TCP, checked the code and there is not a single option to input TCP credentials in it.
i am not getting any error if gray log failure . this event listener is not working
logger.on('error', function (error) {
console.error('Error while trying to write to graylog2:', error);
});
The .close
method does not actually close the connection and call a possible callback if no unsent messages/chunks are left.
when i put wrong ip or port i dont get connection error, even graylog server gets down then also i dont get any error.. my requirement is to switch other logger server if graylog server is down or unable to connect but i dont get any error for it so i am unable to switch to other logger server. Please look into these issue
I am running this code:
var graylog2 = require("graylog2");
var logger = new graylog2.graylog({
servers: [{ host: 'localhost', port: 9999 }]
});
logger.on('error', function (error) {
console.log('Error:', error);
});
logger.emergency("App crashed");
logger.close(function(){
console.log('All good, exiting');
process.exit();
});
And I can set any random ip/port combination (even unreachable host) and it doesn't trigger errors at all, just 'All good, exiting'. Maybe I am doing something wrong or my expectations are wrong?
P.S. It would be good to indicate somewhere on front page that this library can be used only with UDP graylog inputs.
Hi,
I am using below Code, but I am not getting logs in my server also I am not getting any Error in Node Console.
`logMsg = "Some Random String";
let logger = new graylog2.graylog({
servers: [
{ 'host': 'XXX.XXX.XXX.XXX', port: 12201 }
],
// hostname: 'server.name', // the name of this host
// (optional, default: os.hostname())
facility: 'MyAPP', // the facility for these log messages
// (optional, default: "Node.js")
bufferSize: 1350 // max UDP packet size, should never exceed the
// MTU of your system (optional, default: 1400)
});
logger.log("info", logMsg);`
Can someone please help me?
Probably not a huge priority, but while investigating a memory leak somewhere in winston, I noticed the getServer code using a clever way of load balancing between configured servers.
CallCount is never reset though, so once the count reaches 9007199254740992, callCount++ will stop incrementing, thus breaking load balancing.
https://github.com/Wizcorp/node-graylog2/blob/master/graylog.js#L49
Hi
I have a small problem with random crashes wit a EADDRINUSE error. The environment consists of multiple services run with pm2 and scripts started from cron. In both cases i see errors once or twice per day. The error is as below.
bind EADDRINUSE 0.0.0.0
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at dgram.js:221:18
at _combinedTickCallback (internal/process/next_tick.js:77:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
I haven't been able to confirm it but from the dgram docs I think it might be solve by setting reuseAddr
to true
Hi,
I am unable to send messages in chunks. In the source code I see, when the payload size exceeds a certain buffer limit, the message is sent in chunks. However, I do not see those messages in my graylog.
Is there some way we can debug this? There are no messages in error logs.
Hi,
When my script executes, few last messages are not pushed to graylog. i.e. last message "All done" is never delivered.
What can I do to fix this?
I get this error. I use this library in vuejs.
// Main.js
const graylog2 = require("graylog2");
const logger = new graylog2.graylog({
servers: [
{ 'host': {myHost}', port: {myPort} }
],
hostname: 'myProjectName', // the name of this host
// (optional, default: os.hostname())
facility: 'Node.js', // the facility for these log messages
// (optional, default: "Node.js")
bufferSize: 1400 // max UDP packet size, should never exceed the
// MTU of your system (optional, default: 1400)
});
logger.on('error', function (error) {
console.error('Error while trying to write to graylog2:', error);
});
logger.log("Graylog test");
Can you help me solve the problem?
This is a node issue, but your library uses zlib, and it causes a memory leak that has been crashing our docker containers on EC2. Unfortunately that means we can no longer use your library, and have to opt for another lib that doesn't use zlib.
It's really easy to recreate the issue:
let zlib = require('zlib');
let message = {
some:"data"
};
let payload = new Buffer(JSON.stringify(message));
for(var i =0; i < 30000; ++i){
zlib.deflate(payload, function (err, buffer) {
});
}
setTimeout(()=>{}, 2000000);
Here's the related node issue:
nodejs/node#8871
Because I see several merge requests. and also no updates to the repository in time.
Thanks..
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.