Socket
Book a DemoInstallSign in
Socket

log2splunk

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

log2splunk

Log to Splunk

latest
Source
npmnpm
Version
0.0.5
Version published
Maintainers
1
Created
Source

log2splunk

Log to Splunk

Build Status codecov npm version

Usage

const Log2Splunk = require('log2splunk');

const logger = new Log2Splunk({
  token: "your-token",
  host: "splunk-hec.example.com"
});

// Send string
logger.send("Hello World");

// Send json
logger.send({
  message: "Hello World";
});

// Send with metadata
logger.send("Hello World", {
  source: 'my-app',
  sourcetype: '_raw'
})


// Send Raw
logger.sendRaw("Hello World");

Options

NameDescriptionTypeDefault
tokenThe Splunk HEC token, requiredStringnull
protocolThe Splunk HEC protocolhttp || httpshttps
hostThe Splunk HEC hostStringlocalhost
portThe Splunk HEC portNumber8088
pathThe Splunk HEC pathString/services/collector
sourceThen event sourceStringlog2splunk
indexThe event indexStringExtend your HEC token info
httpsThe https config, more info in https optionsObjectnull

Metadata

NameDescriptionTypeDefault
timeThe event time in epoch time, in the format \<sec\>.\<ms\>. For example, 1433188255.500 indicates 1433188255 seconds and 500 milliseconds after epoch, or Monday, June 1, 2015, at 7:50:55 PM GMT.Numbernow
hostThe host value to assign to the event data. This is typically the hostname of the client from which you're sending data.String
sourceThe source value to assign to the event data. For example, if you're sending data from an app you're developing, you could set this key to the name of the app.String
sourcetypeThe sourcetype value to assign to the event data.Stringhttpevent
indexThe name of the index by which the event data is to be indexed. The index you specify here must be within the list of allowed indexes if the token has the indexes parameter set.String
fields(Not applicable to raw data.) Specifies a JSON object that contains explicit custom fields to be defined at index time. Requests containing the "fields" property must be sent to the /collector/event endpoint, or they will not be indexed. For more information, see Indexed field extractions.String or Object<String, String | Array<String>>

Async/Await

(async () => {
  await logger.send('Hello async/await');
})();

Reference

HTTP Event Collector Examples

Keywords

logger

FAQs

Package last updated on 13 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts