Git Product home page Git Product logo

Comments (4)

okkez avatar okkez commented on July 22, 2024

Could you show me your full configuration for Fluentd and your JavaScript code to emit log?
I could not reproduce your situation.

from fluent-logger-node.

jurgenhaas avatar jurgenhaas commented on July 22, 2024

Sure, what I'm doing is to enhance an existing monitoring tool and the file I'm editing is this: https://gitlab.paragon-es.de/tools/uptime/blob/master/models/ping.js

In the header I've added this:

var logger = require('fluent-logger');
logger.configure('app.uptime', {
  host: 'localhost',
  port: 24224,
  timeout: 3.0,
  reconnectInterval: 60000
});

Then, the class builds a Ping object which will be written to a MongoDB in line 72.

In my first approach I have added the following code right before ping.save():

logger.emit('test', ping);

That throws the error and as ping contains some other class objects, I thought I should simplify that and tried this:

var LoggerFields = ['timestamp', 'isUp', 'isResponsive', 'time', 'tags', 'monitorName', 'downtime', 'error'];
var log_output = {};
for (var i = 0, len = LoggerFields.length; i < len; i++) {
  var name = LoggerFields[i],
      value = ping.get(name);
  if (value != undefined) {
    log_output[name] = value;
  }
}
logger.emit('test', log_output);

That throws the same error. Then I casted String(value) which is then working OK.

Hope that helps you to reproduce this?

from fluent-logger-node.

okkez avatar okkez commented on July 22, 2024

I got error error_class=MessagePack::UnknownExtTypeError error="unexpected extension type with following code:

var logger = require('fluent-logger');
var mongoose = require('mongoose');
var Schema   = mongoose.Schema;
logger.configure('tag_prefix', {
   host: 'localhost',
   port: 24224,
   timeout: 3.0,
   reconnectInterval: 600000 // 10 minutes
});

var PingSchema = new Schema({
  timestamp    : { type: Date, default: Date.now },
  isUp         : Boolean,  // false if ping returned a non-OK status code or timed out
  isResponsive : Boolean,  // true if the ping time is less than the check max time
  time         : Number,
  check        : { type: Schema.ObjectId, ref: 'Check' },
  tags         : [String],
  monitorName  : String,
  // for pings in error, more details need to be persisted
  downtime     : Number,   // time since last ping if the ping is down
  error        : String,
  details      : Schema.Types.Mixed
});

var Ping = mongoose.model('Ping', PingSchema);

var ping = new Ping();
// console.log(JSON.stringify(ping));
//console.log(typeof ping.timestamp);
logger.emit('ping', ping);

Maybe ping.timestamp is not plain JavaScript object so Fluentd cannot decode from msgpack.
You can send plain JavaScript object with fields what you want (your code is almost good).

Or logger.emit('ping', JSON.parse(JSON.stringify(ping)));

from fluent-logger-node.

jurgenhaas avatar jurgenhaas commented on July 22, 2024

Thanks, that should do.

from fluent-logger-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.