@axiomhq/axiom-node

中文文档
0.12.0发布于 2023/05/04MITTypeScriptCommonJS近 30 天下载 4万

The official NodeJS bindings for the Axiom API

此软件包已被标记为弃用

Please use @axiomhq/js instead

原始使用文档
文档目录3 节
  1. Quickstart
  2. Using Axiom transport for Winston
  3. License

axiom-node: The official NodeJS bindings for the Axiom API axiom-node: The official NodeJS bindings for the Axiom API

Workflow Latest Release License

Axiom unlocks observability at any scale.

  • Ingest with ease, store without limits: Axiom’s next-generation datastore enables ingesting petabytes of data with ultimate efficiency. Ship logs from Kubernetes, AWS, Azure, Google Cloud, DigitalOcean, Nomad, and others.
  • Query everything, all the time: Whether DevOps, SecOps, or EverythingOps, query all your data no matter its age. No provisioning, no moving data from cold/archive to “hot”, and no worrying about slow queries. All your data, all. the. time.
  • Powerful dashboards, for continuous observability: Build dashboards to collect related queries and present information that’s quick and easy to digest for you and your team. Dashboards can be kept private or shared with others, and are the perfect way to bring together data from different sources

For more information check out the official documentation and our community Discord.

Quickstart

Install using npm install:

npm install @axiomhq/axiom-node

If you use the Axiom CLI, run eval $(axiom config export -f) to configure your environment variables.

Otherwise create a personal token in the Axiom settings and export it as AXIOM_TOKEN. Set AXIOM_ORG_ID to the organization ID from the settings page of the organization you want to access.

You can also configure the client using options passed to the constructor of the Client:

const client = new Client({
    token: process.env.AXIOM_TOKEN,
    orgId: process.env.AXIOM_ORG_ID,
});

Create and use a client like this:

import { Client } from '@axiomhq/axiom-node';

async function main() {
  const client = new Client();

  await client.ingestEvents('my-dataset', [
    { 'foo': 'bar'},
  ]);

  const res = await client.query(`['my-dataset'] | where foo == 'bar' | limit 100`);
}

Using Axiom transport for Winston

You can use Winston logger to send logs to Axiom. First, install the winston and @axiomhq/axiom-node packages, then create an instance of the logger with the AxiomTransport.

import winston from 'winston';
import { WinstonTransport as AxiomTransport } from '@axiomhq/axiom-node';

const logger = winston.createLogger({
    level: 'info',
    format: winston.format.json(),
    defaultMeta: { service: 'user-service' },
    transports: [
        new AxiomTransport({
            dataset: 'my-dataset', // defaults to process.env.AXIOM_DATASET
            token: 'my-token', // defaults to process.env.AXIOM_TOKEN
            orgId: 'my-org-id', // defaults to process.env.AXIOM_ORG_ID
        }),
    ],
});

For further examples, see the examples directory.

License

Distributed under the MIT License.

版本与发布记录

@axiomhq/axiom-node 共发布 13 个版本,首次发布于 2021/08/26;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.12.0latest2023/05/043 年前
0.11.02023/01/263 年前
0.10.02022/11/153 年前
0.9.02022/10/244 年前
0.8.02022/09/224 年前
0.7.02022/09/194 年前

关于 @axiomhq/axiom-node 的常见问题

@axiomhq/axiom-node 是什么?

The official NodeJS bindings for the Axiom API注意:该包已被作者标记为弃用——Please use @axiomhq/js instead

如何安装 @axiomhq/axiom-node?

在项目目录运行 npm install @axiomhq/axiom-node,或使用 pnpm add / yarn add / bun add。

@axiomhq/axiom-node 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@axiomhq/axiom-node 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@axiomhq/axiom-node 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=14。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@axiomhq/axiom-node 可以商用吗?

@axiomhq/axiom-node 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@axiomhq/axiom-node 的下载量有多少?

根据 npm 官方下载统计,@axiomhq/axiom-node 在 2026/10/08 – 2026/11/06 这 30 天内被下载 39,825 次,日均约 1,328 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@axiomhq/axiom-node 还在维护吗?

最新版本 0.12.0 发布于 2023/05/04(3 年前);至今共发布 13 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/08/26。作者已将其标记为弃用,新项目建议寻找替代方案。