npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

log2splunk

v0.0.5

Published

Log to Splunk

Downloads

60

Readme

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

| Name | Description | Type | Default | | ---------- | ------------------------------------------------------------------------------------------------------ | ------------------- | -------------------------- | | token | The Splunk HEC token, required | String | null | | protocol | The Splunk HEC protocol | http || https | https | | host | The Splunk HEC host | String | localhost | | port | The Splunk HEC port | Number | 8088 | | path | The Splunk HEC path | String | /services/collector | | source | Then event source | String | log2splunk | | index | The event index | String | Extend your HEC token info | | https | The https config, more info in https options | Object | null |

Metadata

| Name | Description | Type | Default | | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- | ----------- | | time | The 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. | Number | now | | host | The host value to assign to the event data. This is typically the hostname of the client from which you're sending data. | String | | | source | The 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 | | | sourcetype | The sourcetype value to assign to the event data. | String | httpevent | | index | The 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