axiom-node 0.8.0
Install from the command line:
Learn more about npm packages
$ npm install @axiomhq/axiom-node@0.8.0
Install via package.json:
"@axiomhq/axiom-node": "0.8.0"
About this version
The Node SDK for Axiom.
Install the package:
npm install @axiomhq/axiom-node
Then use it like this:
import Client from '@axiomhq/axiom-node';
// Construct a client from environment variables
// Export an API token in `AXIOM_TOKEN` for this to work
const client = new Client();
// Ingest two events
await client.datasets.ingestEvents('my-application', [
{ 'method': 'GET', path: '/' },
{ 'method': 'POST', path: '/login' }
]);
// Query the dataset
const res = await client.datasets.aplQuery(`['my-application'] | summarize count() by bin_auto(_time)`);
const count = res.buckets.totals![0].aggregations![0].value;
console.log(`We have a count of ${count}`);
For more sample code snippets, head over to the examples directory.
The quickstart example above creates a client by environment variables, here's all that are supported.
Environment variable | Description |
---|---|
AXIOM_TOKEN |
An Axiom API or personal token. If it's a personal token you'll also need AXIOM_ORG_ID
|
AXIOM_ORG_ID |
Your Axiom org id, necessary for personal tokens |
AXIOM_URL |
If you self-host Axiom, set this to your deployment url |
You can programmatically override these by passing an options object to the
Client
constructor, here's an example with all values set:
const client = new Client({
token: "xaat-xxxx",
orgId: "my-org",
url: "http://my-axiom.example.org"
});
This library exports a transport for winston, which you can use like this:
import { WinstonTransport as AxiomTransport } from '@axiomhq/axiom-node';
const logger = winston.createLogger({
// ...
transports: [
new AxiomTransport(),
],
});
The main aim of this repository is to continue developing and advancing axiom-node, making it faster and simpler to use. Kindly check our contributing guide on how to propose bugfixes and improvements, and submitting pull requests to the project
© Axiom, Inc., 2021
Distributed under MIT License (The MIT License
).
See LICENSE for more information.