Giter Site home page Giter Site logo

logstash-tcp's Introduction

logstash-tcp 安装

yarn add logstash-tcp

使用方法

const logstash = require('logstash-tcp')

logstash.init({
  host: '192.168.40.167',
  port: '9600'
})


logstash.send({
  hostname: 'wdd2',
  id: i++,
  something: {
    name: 'abc'
  }
})

kibana查询结果

{
  "_index": "logstash-2019.03.07",
  "_type": "logs",
  "_id": "AWlWzhwpixOdAdKBNE2p",
  "_score": null,
  "_source": {
    "hostname": "wdd2",
    "@timestamp": "2019-03-07T06:19:02.050Z",
    "port": 55666,
    "@version": "1",
    "host": "192.168.2.184",
    "id": 7,
    "something": {
      "name": "abc"
    },
    "tags": [
      "_grokparsefailure"
    ]
  },
  "fields": {
    "@timestamp": [
      1551939542050
    ]
  },
  "highlight": {
    "hostname": [
      "@kibana-highlighted-field@wdd2@/kibana-highlighted-field@"
    ]
  },
  "sort": [
    1551939542050
  ]
}

logstash.init(options) 全部配置

字段 类型 默认值 说明
socketTimeout int 10000 socket超时毫秒数
port int logstash tcp端口号
host string
reconnectTimeout int 2000 发生异常时,多少毫秒后开始重连
maxReconnectTimes int 10 最多多少次重连
logBufferSize int 1000 当发生异常时,最多缓存多少个待发送的日志。当下次重连成功后,这些日志会再次尝试发送。

logstash.send(msg)

msg是一个可以被序列化的对象。

logstash.send({
  key: 'what u want'
})

logstash-tcp's People

Contributors

wangduanduan avatar

Watchers

 avatar  avatar

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.