The `splunk-bunyan-logger` package provides a Bunyan stream specifically designed to send structured log data to Splunk Enterprise or Splunk Cloud via the HTTP Event Collector (HEC). It acts as a bridge, allowing applications using the Bunyan JSON logging library to seamlessly integrate with Splunk's data ingestion capabilities. The current stable version is 0.11.0. While no explicit release cadence is provided, the recent update (0.11.0) indicates active maintenance, with the last update fixing deprecated internal dependencies. Key differentiators include its tight integration with Bunyan's streaming architecture, batching capabilities for efficient data transfer, and support for custom event formatting. It requires Node.js v4 or later (tested with v10 and v14) and Splunk Enterprise 6.3.0 or later, or Splunk Cloud.
npm install splunk-bunyan-loggerVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to configure a Bunyan logger with the `splunk-bunyan-logger` stream to send structured logs to Splunk HTTP Event Collector. It includes basic error handling and uses environment variables for sensitive configuration.
Set `splunkStream.logger.requestOptions.strictSSL = true;` after creating the stream instance if your Splunk HEC endpoint uses a valid SSL certificate.
Carefully test any custom `requestOptions` after upgrading to 0.11.0. Consult `needle` library documentation for equivalent options.
Stick to `require()` for importing `splunk-bunyan-logger` in your Node.js applications or ensure your build setup correctly handles CommonJS module imports within an ESM context.
Ensure `config.token` and `config.url` are correct. Verify network connectivity to the Splunk HEC endpoint and attach an `error` listener to your `splunkStream` instance to catch and log any transmission failures.
Use `const splunkBunyan = require('splunk-bunyan-logger');` and then access `splunkBunyan.createStream(config);`. Do not use `const { createStream } = require('splunk-bunyan-logger');` or ESM `import { createStream } from 'splunk-bunyan-logger';`Either disable `strictSSL` (not recommended for production) by `splunkStream.logger.requestOptions.strictSSL = false;` or, preferably, configure Node.js to trust your self-signed certificate by setting the `NODE_EXTRA_CA_CERTS` environment variable to the path of your CA certificate file.
Verify the `config.url` is correct (including port). Check network connectivity from your application server to the Splunk HEC host, and ensure Splunk HEC is enabled and listening on the specified port.