Skip to content

Added new config option with readme documentation #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Splunk logging for JavaScript

#### Version 0.10.1
#### Version 0.10.2

This project provides a simple JavaScript interface for logging to HTTP Event Collector in Splunk Enterprise and Splunk Cloud.

Expand Down Expand Up @@ -49,6 +49,25 @@ var Logger = new SplunkLogger(config);
Logger.requestOptions.strictSSL = true;
```

### Configure Http Keep-Alive Agent

Note: No default agent configuration is configured by default.
To enable it, set `config.agent` to a valid http Agent (i.e. https://nodejs.org/api/http.html#http_new_agent_options)

```javascript
var SplunkLogger = require("splunk-logging").Logger;
var Agent = require('http').Agent
var agent = new Agent({ keepAlive: true })

var config = {
token: "your-token-here",
url: "https://splunk.local:8088",
agent: agent,
};

var Logger = new SplunkLogger(config);
```

### Basic example

```javascript
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "splunk-logging",
"version": "0.10.1",
"version": "0.10.2",
"description": "Splunk HTTP Event Collector logging interface",
"homepage": "http://dev.splunk.com",
"main": "index.js",
Expand Down
4 changes: 4 additions & 0 deletions splunklogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@ SplunkLogger.prototype._sendEvents = function(context, callback) {
// since json is set to true.
requestOptions.headers["Content-Type"] = "application/x-www-form-urlencoded";
requestOptions.url = this.config.protocol + "://" + this.config.host + ":" + this.config.port + this.config.path;

if (this.config.agent) {
requestOptions.agent = this.config.agent;
}

// Initialize the context again, right before using it
context = this._initializeContext(context);
Expand Down