StatsD backend for Application Insights Node.js
Перейти к файлу
Matt McCleary 544ef3300e
Merge pull request #4 from DawgFan/patch-2
Move unsupported note to top of Readme
2020-07-21 17:24:56 -07:00
.vscode Initial commit. 2016-05-18 13:38:22 +09:00
lib Initial commit. 2016-05-18 13:38:22 +09:00
tests Initial commit. 2016-05-18 13:38:22 +09:00
.gitignore Initial commit. 2016-05-18 13:38:22 +09:00
.travis.yml Only suppot Node LTS + 2016-05-25 21:39:03 +09:00
CONTRIBUTING.md Initial commit. 2016-05-18 13:38:22 +09:00
LICENSE Initial commit. 2016-05-18 13:38:22 +09:00
README.md Update README.md 2019-08-12 13:15:00 -07:00
gulpfile.js Add missing gulpfile.js. 2016-05-25 21:22:57 +09:00
package.json Only suppot Node LTS + 2016-05-25 21:39:03 +09:00
tsconfig.json Initial commit. 2016-05-18 13:38:22 +09:00
tslint.json Initial commit. 2016-05-18 13:38:22 +09:00
typings.json Initial commit. 2016-05-18 13:38:22 +09:00

README.md

This SDK is NOT currently maintained or supported by Microsoft. Azure Monitor only provides support when using the supported SDKs. Were constantly assessing opportunities to expand our support for other languages, so follow our GitHub Announcements page to receive the latest SDK news.

Application Insights StatsD backend

NPM version Build Status

The ApplicationInsights StatsD backend enables easy pre-aggregation of lightweight StatsD metrics that can be then forwarded to Application Insights.

Installation and Configuration

You can add the appinsights backend into your existing StatsD project or into a new clone of the official StatsD repo.

New Project

Install node.js from nodejs.org

Clone the statsd project:

$ git clone https://github.com/etsy/statsd

Create a config file from exampleConfig.js:

$ cd /path/to/statsd
$ cp exampleConfig.js appinsights.js

Continue with the Existing Project instructions

Existing project

Install the appinsights-statsd backend npm module:

$ cd /path/to/statsd
$ npm install appinsights-statsd --save

Add the backend and configuration to your statsd config file (appinsights.js):

{
    backends: [ "appinsights-statsd" ],  // [Required] The Application Insighst StatsD backend
    aiInstrumentationKey: "<Application Insights Instrumentation Key from https://portal.azure.com>",  // [Required] Your instrumentation key
    aiPrefix: "myapp",  // [Optional] Send only metrics with this prefix
    aiRoleName: "MyFrontEnd",  // [Optional] Add this role name context tag to every metric
    aiRoleInstance: "VM5",  // [Optional] Add this role instance context tag to every metric
    aiTrackStatsDMetrics: true,  // [Optional] Send StatsD internal metrics to Application Insights
}

Start the Daemon:

$ node stats.js /path/to/config

Usage

The backend supports counters, timers and gauges with the standard statsd format.

In additional, custom properties can be attached to each metric using a double-underscore delimiter in this format:

"<name>__<base64-encoded JSON>"

E.g. to send a counter with a custom property you could use code like this:

const customProperties = { "title": "engineer" };
const customPropertiesEncoded = new Buffer(JSON.stringify(customProperties)).toString("base64");
const name = "jobs-open__" + customPropertiesEncoded;
statsDClient.increment(name);

Contributing

See CONTRIBUTING for details