kandi background
Explore Kits

fluent-logger-node | A structured logger for Fluentd

 by   fluent JavaScript Version: Current License: Apache-2.0

 by   fluent JavaScript Version: Current License: Apache-2.0

Download this library from

kandi X-RAY | fluent-logger-node Summary

fluent-logger-node is a JavaScript library typically used in Logging, Nodejs applications. fluent-logger-node has no bugs, it has no vulnerabilities, it has a Permissive License and it has low support. You can install using 'npm i @jigsaw/fluent-logger' or download it from GitHub, npm.
This package is compatible with NodeJS versions >= 6.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • fluent-logger-node has a low active ecosystem.
  • It has 233 star(s) with 83 fork(s). There are 17 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 17 open issues and 67 have been closed. On average issues are closed in 79 days. There are 2 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of fluent-logger-node is current.
fluent-logger-node Support
Best in #JavaScript
Average in #JavaScript
fluent-logger-node Support
Best in #JavaScript
Average in #JavaScript

quality kandi Quality

  • fluent-logger-node has 0 bugs and 0 code smells.
fluent-logger-node Quality
Best in #JavaScript
Average in #JavaScript
fluent-logger-node Quality
Best in #JavaScript
Average in #JavaScript

securitySecurity

  • fluent-logger-node has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • fluent-logger-node code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
fluent-logger-node Security
Best in #JavaScript
Average in #JavaScript
fluent-logger-node Security
Best in #JavaScript
Average in #JavaScript

license License

  • fluent-logger-node is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
fluent-logger-node License
Best in #JavaScript
Average in #JavaScript
fluent-logger-node License
Best in #JavaScript
Average in #JavaScript

buildReuse

  • fluent-logger-node releases are not available. You will need to build from source code and install.
  • Deployable package is available in npm.
  • Installation instructions are not available. Examples and code snippets are available.
fluent-logger-node Reuse
Best in #JavaScript
Average in #JavaScript
fluent-logger-node Reuse
Best in #JavaScript
Average in #JavaScript
Top functions reviewed by kandi - BETA

kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here

Get all kandi verified functions for this library.

Get all kandi verified functions for this library.

fluent-logger-node Key Features

A structured logger for Fluentd (Node.js)

Install

copy iconCopydownload iconDownload
$ npm install fluent-logger

Prerequistes

copy iconCopydownload iconDownload
<source>
  @type forward
  port 24224
</source>

<match **.*>
  @type stdout
</match>

Send an event record to Fluentd

copy iconCopydownload iconDownload
var logger = require('fluent-logger')
// The 2nd argument can be omitted. Here is a default value for options.
logger.configure('tag_prefix', {
   host: 'localhost',
   port: 24224,
   timeout: 3.0,
   reconnectInterval: 600000 // 10 minutes
});

// send an event record with 'tag.label'
logger.emit('label', {record: 'this is a log'});

Disable automatic reconnect

copy iconCopydownload iconDownload
logger.configure('tag_prefix', {
   host: 'localhost',
   port: 24224,
   timeout: 3.0,
   enableReconnect: false // defaults to true
});

Shared key authentication

copy iconCopydownload iconDownload
var logger = require('fluent-logger').createFluentSender('dummy', {
  host: 'localhost',
  port: 24224,
  timeout: 3.0,
  reconnectInterval: 600000, // 10 minutes
  security: {
    clientHostname: "client.localdomain",
    sharedKey: "secure_communication_is_awesome"
  }
});
logger.emit('debug', { message: 'This is a message' });

TLS/SSL encryption

copy iconCopydownload iconDownload
var logger = require('fluent-logger').createFluentSender('dummy', {
  host: 'localhost',
  port: 24224,
  timeout: 3.0,
  reconnectInterval: 600000, // 10 minutes
  security: {
    clientHostname: "client.localdomain",
    sharedKey: "secure_communication_is_awesome"
  },
  tls: true,
  tlsOptions: {
    ca: fs.readFileSync('/path/to/ca_cert.pem')
  }
});
logger.emit('debug', { message: 'This is a message' });

Mutual TLS Authentication

copy iconCopydownload iconDownload
var logger = require('fluent-logger').createFluentSender('dummy', {
  host: 'localhost',
  port: 24224,
  timeout: 3.0,
  reconnectInterval: 600000, // 10 minutes
  security: {
    clientHostname: "client.localdomain",
    sharedKey: "secure_communication_is_awesome"
  },
  tls: true,
  tlsOptions: {
    ca: fs.readFileSync('/path/to/ca_cert.pem'),
    cert: fs.readFileSync('/path/to/client-cert.pem'),
    key: fs.readFileSync('/path/to/client-key.pem'),
    passphrase: 'very-secret'
  }
});
logger.emit('debug', { message: 'This is a message' });

EventTime support

copy iconCopydownload iconDownload
var FluentLogger = require('fluent-logger');
var EventTime = FluentLogger.EventTime;
var logger = FluentLogger.createFluentSender('tag_prefix', {
var eventTime = new EventTime(1489547207, 745003500); // 2017-03-15 12:06:47 +0900
logger.emit('tag', { message: 'This is a message' }, eventTime);

Events

copy iconCopydownload iconDownload
var logger = require('fluent-logger').createFluentSender('tag_prefix', {
   host: 'localhost',
   port: 24224,
   timeout: 3.0,
   reconnectInterval: 600000 // 10 minutes
});
logger.on('error', (error) => {
  console.log(error);
});
logger.on('connect', () => {
  console.log('connected!');
});

winston

copy iconCopydownload iconDownload
var winston = require('winston');
var config = {
  host: 'localhost',
  port: 24224,
  timeout: 3.0,
  requireAckResponse: true // Add this option to wait response from Fluentd certainly
};
var fluentTransport = require('fluent-logger').support.winstonTransport();
var fluent = new fluentTransport('mytag', config);
var logger = winston.createLogger({
  transports: [fluent, new (winston.transports.Console)()]
});

logger.on('flush', () => {
  console.log("flush");
})

logger.on('finish', () => {
  console.log("finish");
  fluent.sender.end("end", {}, () => {})
});

logger.log('info', 'this log record is sent to fluent daemon');
logger.info('this log record is sent to fluent daemon');
logger.info('end of log message');
logger.end();

stream

copy iconCopydownload iconDownload
'use strict';
const Console = require('console').Console;
var sender = require('fluent-logger').createFluentSender('tag_prefix', {
   host: 'localhost',
   port: 24224,
   timeout: 3.0,
   reconnectInterval: 600000 // 10 minutes
});
var logger = new Console(sender.toStream('stdout'), sender.toStream('stderr'));
logger.log('this log record is sent to fluent daemon');
setTimeout(()=> sender.end(), 5000);

Fluentd Kubernetes Nodejs : Error: connect ECONNREFUSED 127.0.0.1:24224

copy iconCopydownload iconDownload
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: default # <- the same as the pod communicating with the service
spec:
  type: ExternalName
  externalName: nginx.nginx-namespace.svc.cluster.local

Community Discussions

Trending Discussions on fluent-logger-node
  • Fluentd Kubernetes Nodejs : Error: connect ECONNREFUSED 127.0.0.1:24224
Trending Discussions on fluent-logger-node

QUESTION

Fluentd Kubernetes Nodejs : Error: connect ECONNREFUSED 127.0.0.1:24224

Asked 2020-Sep-21 at 06:13

EDIT : I harcoded the fluentd service IP directly in my express app and its working.. how to get it work without harcoding ip?

I have a couple of pods (nodejs + express server) running on a Kubernetes cluster.

I'd like send logs from my nodejs pods to a Fluentd DeamonSet.

But I'm getting this error :

Fluentd error Error: connect ECONNREFUSED 127.0.0.1:24224

I'm using https://github.com/fluent/fluent-logger-node and my configuration is pretty simple:

const logger = require('fluent-logger')

logger.configure('pptr', {
   host: 'localhost',
   port: 24224,
   timeout: 3.0,
   reconnectInterval: 600000
});

My fluentd conf file:

<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>

# Ignore fluent logs
<label @FLUENT_LOG>
  <match fluent.*>
    @type null
  </match>
</label>

<match pptr.**>
  @type elasticsearch
  host "#{ENV['FLUENT_ELASTICSEARCH_HOST']}"
  port "#{ENV['FLUENT_ELASTICSEARCH_PORT']}"
  scheme "#{ENV['FLUENT_ELASTICSEARCH_SCHEME'] || 'http'}"
  ssl_verify "#{ENV['FLUENT_ELASTICSEARCH_SSL_VERIFY'] || 'true'}"
  user "#{ENV['FLUENT_ELASTICSEARCH_USER']}"
  password "#{ENV['FLUENT_ELASTICSEARCH_PASSWORD']}"
  reload_connections "#{ENV['FLUENT_ELASTICSEARCH_RELOAD_CONNECTIONS'] || 'true'}"
  type_name fluentd
  logstash_format true
</match>

Here's the Fluentd DeamonSet config file:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd
  namespace: kube-system
  labels:
    k8s-app: fluentd-logging
    version: v1
spec:
  selector:
    matchLabels:
      k8s-app: fluentd-logging
      version: v1
  template:
    metadata:
      labels:
        k8s-app: fluentd-logging
        version: v1
    spec:
      serviceAccount: fluentd
      serviceAccountName: fluentd
      tolerations:
        - key: node-role.kubernetes.io/master
          effect: NoSchedule
      containers:
        - name: fluentd
          image: fluent/fluentd-kubernetes-daemonset:v1-debian-elasticsearch
          ports:
            - containerPort: 24224
          env:
            - name:  FLUENT_ELASTICSEARCH_HOST
              value: "xxx"
            - name:  FLUENT_ELASTICSEARCH_PORT
              value: "xxx"
            - name: FLUENT_ELASTICSEARCH_SCHEME
              value: "https"
            # Option to configure elasticsearch plugin with self signed certs
            # ================================================================
            - name: FLUENT_ELASTICSEARCH_SSL_VERIFY
              value: "true"
            # Option to configure elasticsearch plugin with tls
            # ================================================================
            - name: FLUENT_ELASTICSEARCH_SSL_VERSION
              value: "TLSv1_2"
            # X-Pack Authentication
            # =====================
            - name: FLUENT_ELASTICSEARCH_USER
              value: "xxx"
            - name: FLUENT_ELASTICSEARCH_PASSWORD
              value: "xxx"
          resources:
            limits:
              memory: 200Mi
            requests:
              cpu: 100m
              memory: 200Mi
          volumeMounts:
            - name: config-volume
              mountPath: /fluentd/etc/kubernetes.conf
              subPath: kubernetes.conf
            - name: varlog
              mountPath: /var/log
            - name: varlibdockercontainers
              mountPath: /var/lib/docker/containers
              readOnly: true
      terminationGracePeriodSeconds: 30
      volumes:
        - name: config-volume
          configMap:
            name: fluentd-conf
        - name: varlog
          hostPath:
            path: /var/log
        - name: varlibdockercontainers
          hostPath:
            path: /var/lib/docker/containers

I also tried to deploy a service and expose the 24224 port :

apiVersion: v1
kind: Service
metadata:
  name: fluentd
  namespace: kube-system
  labels:
    app: fluentd
spec:
  ports:
    - name: "24224"
      port: 24224
      targetPort: 24224
  selector:
    k8s-app: fluentd-logging
status:
  loadBalancer: {}

Finally my express app (deployment) is here:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: puppet
  labels:
    app: puppet
spec:
  replicas: 5
  selector:
    matchLabels:
      app: puppet
  template:
    metadata:
      labels:
        app: puppet
    spec:
      containers:
        - name: puppet
          image: myrepo/my-image
          ports:
            - containerPort: 8080

EDIT : I harcoded the fluentd service IP directly in my express app and its working.. how to get it work without harcoding ip?

ANSWER

Answered 2020-Sep-21 at 06:13

Focusing on below parts of the question:

I'd like send logs from my nodejs pods to a Fluentd DeamonSet.

EDIT : I harcoded the fluentd service IP directly in my express app and its working.. how to get it work without harcoding ip?

It looks like the communication between pods and the fluentd service is correct (hardcoding the IP works). The issue here is the way they can communicate with each other.

You can communicate with service fluentd by its name. For example (from the inside of a pod):

  • curl fluentd:24224

You can communicate with services by its name (like fluentd) only in the same namespace. If a service is in another namespace you would need to use it's full DNS name. It's template and example is following:

  • template: service-name.namespace.svc.cluster.local
  • example: fluentd.kube-system.svc.cluster.local

You can also use service of type ExternalName to map the full DNS name of your service to a shorter version like below:


Assuming that (example):

  • You have created a nginx-namespace namespace:
    • $ kubectl create namespace nginx-namespace
  • You have an nginx Deployment inside the nginx-namespace and a service associated with it:
    • $ kubectl create deployment nginx --image=nginx --namespace=nginx-namespace
    • $ kubectl expose deployment nginx --port=80 --type=ClusterIP --namespace=nginx-namespace
  • You want to communicate with nginx Deployment from another namespace (i.e. default)

You have an option to communicate with above pod:

  • By the IP address of a Pod
    • 10.98.132.201
  • By a (full) DNS service name
    • nginx.nginx-namespace.svc.cluster.local
  • By an ExternalName type of service that points to a a (full) DNS service name
    • nginx-service

The example of ExternalName type of service:

apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  namespace: default # <- the same as the pod communicating with the service
spec:
  type: ExternalName
  externalName: nginx.nginx-namespace.svc.cluster.local

You can pass this information to the pod by either:


Additional resources:

Source https://stackoverflow.com/questions/63937370

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install fluent-logger-node

You can install using 'npm i @jigsaw/fluent-logger' or download it from GitHub, npm.

Support

We can also specify EventTime as timestamp.

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Reuse Pre-built Kits with fluent-logger-node
Consider Popular JavaScript Libraries
Try Top Libraries by fluent
Compare JavaScript Libraries with Highest Support
Compare JavaScript Libraries with Highest Quality
Compare JavaScript Libraries with Highest Security
Compare JavaScript Libraries with Permissive License
Compare JavaScript Libraries with Highest Reuse
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases
Explore Kits

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.