<commit_before>## 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

```sh
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
```sh
git clone https://github.com/gdziuba/http-event-collector.git
```
```sh
cd http-event-collector
npm install
```

## Setup
[To configure Splunk's HTTP Event Collector, follow these instructions.](http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/Data/UsetheHTTPEventCollector#Configure_HTTP_Event_Collector_on_Splunk_Enterprise)

[Example Node-RED configuration](https://i.imgur.com/9noXzGI.png)
<commit_msg>Example code for conveting MQTT data to Metric<commit_after>## 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

```sh
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
```sh
git clone https://github.com/gdziuba/http-event-collector.git
```
```sh
cd http-event-collector
npm install
```

## Setup
[To configure Splunk's HTTP Event Collector, follow these instructions.](http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/Data/UsetheHTTPEventCollector#Configure_HTTP_Event_Collector_on_Splunk_Enterprise)

[Example Node-RED configuration](https://i.imgur.com/9noXzGI.png)

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

#### Single value MQTT payload message to Metric structure:
```sh
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;
```

{'fraction_non_alphanumeric': 0.1012448132780083, 'fraction_numerical': 0.0033195020746887966, 'mean_word_length': 4.686320754716981, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7598863', 'n_tokens_mistral': 774, 'n_tokens_neox': 722, 'n_words': 265}