@splunkdlt/hec-client
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

@splunkdlt/hec-client

Integration Tests

Flexible client library for Splunk HTTP Event Collector (HEC) with support for sending metrics and events, batching, compression, keep-alives and retries.

Install and Use

npm i @splunkdlt/hec-client

# or

yarn add @splunkdlt/hec-client

Example: sending some metrics to HEC:

const hec = new HecClient({
    url: 'https://http-inputs-acme.splunkcloud.com',
    token: '12345678-9999-4711-0815-C0FF33C0FFEE',
});

const mem = process.memoryUsage();
const cpu = process.cpuUsage();

hec.pushMetrics({
    time: Date.now(),
    measurements: {
        'myapp.cpu.user': cpu.user,
        'myapp.cpu.system': cpu.system,
        'myapp.mem.heapUsed': mem.heapUsed,
        'myapp.mem.heapTotal': mem.heapTotal,
    },
    fields: {
        hostname: os.hostname(),
    },
    metadata: {
        index: 'mymetrics',
        sourcetype: 'myapp:system',
        source: 'myapp',
    },
});

await hec.flush();

Readme

Keywords

none

Package Sidebar

Install

npm i @splunkdlt/hec-client

Weekly Downloads

6

Version

1.2.1

License

Apache-2.0

Unpacked Size

300 kB

Total Files

29

Last publish

Collaborators

  • spuchbauer-splunk
  • tmio