2.2.10 • Published 3 years ago

azure-log-analytics-data-collector-client v2.2.10

Weekly downloads
239
License
MIT
Repository
github
Last release
3 years ago

Azure Log Analytics Data Collector Client

Test status

Node.JS wrapper for Azure Monitor HTTP Data Collector API.

Installation

npm install azure-log-analytics-data-collector-client

Or with yarn:

yarn add azure-log-analytics-data-collector-client

Usage

Javascript:

const {
  DataCollectorClient,
} = require("azure-log-analytics-data-collector-client");

const client = new DataCollectorClient(
  "WORKSPACE_ID",
  "PRIMARY_KEY_OR_SECONDARY_KEY",
  "OPTIONAL_HOST"
);

client
  .send("MyLogs", [
    {
      level: "info",
      message: "server starts",
    },
  ])
  .then(console.log);

Typescript:

import { DataCollectorClient } from "azure-log-analytics-data-collector-client";

const client = new DataCollectorClient(
  "WORKSPACE_ID",
  "PRIMARY_KEY_OR_SECONDARY_KEY",
  "OPTIONAL_HOST"
);

client
  .send("MyLogs", [
    {
      level: "info",
      message: "server starts",
    },
  ])
  .then(console.log);

To get your WORKSPACE_ID and PRIMARY_KEY_OR_SECONDARY_KEY, in your workspace go to Agents management -> Log Analytics agent instructions.

The OPTIONAL_HOST is available for the ODS endpoint for your workspace cloud.

  • Azure Public Cloud's ods.opinsights.azure.com is the default used if none is provided
  • Azure US Government's host has to be set to ods.opinsights.azure.us

To query your logs, go to the Logs tab of your workspace and use MyLogs_CL as query table name. Sample query:

MyLogs_CL
| where TimeGenerated > ago(24h)
| limit 10

Please note that only alphanumeric and underscore can be used as table name. the - in the table name will be replaced with _.

Response Object

PropertyOptionalDescription
codenoHTTP response code
statusnoHTTP response status
errorCodeyesError code from server
errorMsgyesError message from server

Local Development

To run the integration test locally, grab the workspace id and the agent key and then run:

LOG_ANALYTICS_WORKSPACE_ID=<your_workspace_id> LOG_ANALYTICS_AGENT_KEY=<your_agent_key> LOG_ANALYTICS_HOST=<your_private_host> yarn test

License

MIT

2.2.9

3 years ago

2.2.10

3 years ago

2.2.8

3 years ago

2.2.7

4 years ago

2.2.6

4 years ago

2.2.5

4 years ago

2.2.4

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago