Giter VIP home page Giter VIP logo

http-event-collector's Introduction

Synopsis

The purpose of this project is to allow node-red to publish a node-red payload to Splunk's HTTP Event Collector.

Motivation

Wanted to make an easy avenue to publish data into Splunk through Node-Red.

Installation

The easiest way to install is through the Node-Red Palette Manager that can be found in the menu on the top right hand corner of the Node-Red ui.

Manual install with npm

npm install -g node-red-contrib-http-event-collector

Install from source

From github: Navigate to the your home directory on linux is is ~/.node-red/node-modules

git clone https://github.com/gdziuba/http-event-collector.git
cd http-event-collector
npm install

Setup

To configure Splunk's HTTP Event Collector, follow these instructions.

Example Node-RED configuration

Examples:

Node-RED Functions for converting msg to correct structure for Metric Event Collector.

Single value MQTT payload message to Metric structure:

var o = msg.payload;
var v = msg.topic;
msg.payload = {};
msg.payload.fields = {};
msg.payload.fields._value = o;
msg.payload.fields.metric_name= v;
return msg;

Single value with dimensions enabled :

var o = msg.payload;
var v = msg.topic;
msg.payload = {};
msg.payload.splunkdims = true;
msg.payload.fields = {};
msg.payload.fields._value = o;
msg.payload.fields.metric_name= v;
msg.payload.fields.dimension1= "value1";
return msg;

http-event-collector's People

Contributors

gdziuba avatar msenebald avatar

Stargazers

Douglas Oliveira avatar

Watchers

 avatar  avatar

http-event-collector's Issues

Logging

Hi there, I have adjusted the logging to warn for Nodered, but this module keeps logging the payload it send to Splunk, with teh result code

My Settings.js
/** Configure the logging output /
logging: {
/
* Only console logging is currently supported /
console: {
/
* Level of logging to be recorded. Options are:
* fatal - only those errors which make the application unusable should be recorded
* error - record errors which are deemed fatal for a particular request + fatal errors
* warn - record problems which are non fatal + errors + fatal errors
* info - record information about the general running of the application + warn + error + fatal errors
* debug - record information which is more verbose than info + info + warn + error + fatal errors
* trace - record very detailed logging + debug + info + warn + error + fatal errors
* off - turn off all logging (doesn't affect metrics or audit)
/
level: "error",
/
* Whether or not to include metric events in the log output /
metrics: false,
/
* Whether or not to include audit events in the log output */
audit: false
}
},

Displays in the docker log.

Sending payload {

message: { _msgid: 'f995fa1dcb5742b7', payload: 'Hello 2' },

metadata: {

source: 'nodered',

sourcetype: 'nodered:event',

index: 'stm_dev_nodered',

host: 'xxxx'

},

severity: 'info'

}

Regards
Willem

Events are not accepted by Splunk HEC for metric store: payload isn't json or has already converted

I am trying to use your module to send data from "Homematic" (Smart home solution) via NodeRed to Splunk's HEC.
So long everything worked like a charm and I have the full JSON events in Splunk and can work with them. Now I tried to switch to sending it to the metric store but can't seem to get it to work.

The index is setup and I've added another branch in my flow to send to the HEC and use the metric variant in parallel so in order not to loose any events while testing.

image

However in the console I now get those errors:

Feb  5 13:40:54 homematic-raspi daemon.err node-red: {"text":"Success","code":0}
Feb  5 13:40:54 homematic-raspi daemon.err node-red: hostname: 192.168.0.1
Feb  5 13:40:54 homematic-raspi daemon.err node-red: payload isn't json or has already converted
Feb  5 13:40:54 homematic-raspi daemon.err node-red: {"text":"Success","code":0}
Feb  5 13:41:00 homematic-raspi daemon.err node-red: hostname: 192.168.0.1
Feb  5 13:41:00 homematic-raspi daemon.err node-red: payload isn't json or has already converted

In the convert event I used your example from: https://flows.nodered.org/node/node-red-contrib-http-event-collector and adapted it a little bit (it didn't work with your version either though)

// First try
//var mname = "metric_name:" + msg.topic.replace(':','.');
//var v = msg.payload.val;

//if (v == null || v == false) v=0;
//if (v == true) v=1;

//msg = {};
//msg[mname] = v;

var v = msg.payload.val;
var t = msg.topic;

if (v == null || v == false) v=0;
if (v == true) v=1;

msg.payload = {};
msg.payload.fields = {};

msg.payload.fields.metric_name= t;
msg.payload.fields._value = v;

return msg;

Any idea what could be wrong?

running= npm i node-red-contrib-http-event-collector

I am getting this error when running the following
npm i node-red-contrib-http-event-collector
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno ENOENT
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t https://github.com/splunk/splunk-javascript-logging.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: Logfile

I get the same error when trying from the Node red palette. Any help appreciated.

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.