Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including logs-to-sumologic with all npm packages installed. Try it out:

var logsToSumologic = require("logs-to-sumologic")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

logs-to-sumologic v1.1.0

A simple sumologic log client tool

logs-to-sumologic

A client implementation for Sumologic in node.js.

Usage

Very simple to use. First of all, set up an account with Sumologic

Create an HTTP Collector endpoint

eg.

alt tag

Now write a few lines of code to call logs-to-sumologic:


const Sumologic = require('logs-to-sumologic');

var collectorCode = 'YOUR_COLLECTOR CODE'

var endpoint = 'YOUR_ENDPOINT'
// 'https://endpoint1.collection.us2.sumologic.com/receiver/v1/http/'

var url = endpoint + collectorCode;

const sumologic = Sumologic.createClient({
  url: url,
  name: "SumoHttpCollector",   // Custom Source Name -  optional
  host: "webapp.com",      // Custom Source Host - optional
  category: "env/host/service" // Custom Source Category - optional
});

/**
 * More info about name,host and category options are in section 
 *  "Other Supported HTTP Headers"
 *  at https://help.sumologic.com/Send_Data/Sources/02Sources_for_Hosted_Collectors/HTTP_Source/Upload_Data_to_an_HTTP_Source
*/

var cb = function (err, res) {
  if (err) {
    // handle error
  }
  // handle success
};


// contrived examples:

// single log message
var log = {test: "test only"};
sumologic.log(JSON.stringify(log), cb);
// or
sumologic.log(log, cb);

// bulk
var logs = [{test1: "test only"}, {test2: "test only"}];
sumologic.log(JSON.stringify(logs), cb);
// or
sumologic.log(logs, cb);

Optionally, setup a live tail to your HTTP Collector endpoint

You should see your logs appearing, eg.

alt tag

Done.

Further information

Please see here for further information on uploading data to an HTTP Source using Sumologic.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free