alligator-metrics
alligator-metrics is a Ganglia metrics reporter.
Quick Start
vi config/metrics.js
npm start
Configuration
Config files for metrics in config/metrics
General
- Edit config/metrics.js
- Add Ganglia masters to array
return hosts: host:'localhost' port:8649 // gmond port ;
Redis Metrics
- Edit config/metrics/redis.js
return redis: enabled:true // enable/disable host:'localhost' port: 6379 database:0 ;
Elasticsearch Metrics
- Edit config/metrics/elasticsearch.js
return elasticsearch: enabled:true // enable/disable host:"http://localhost:9200" log:'error' ;
Creating a Metric
You can create you own Metric by placing them in a ./metrics/ folder create a yourMetric.js file. Here's an example of a simple metric which will report to ganglia the number of cpus:
var os = ;exportscpus= title:'NodeJS CPUs Count' name: 'node_cpu_num' group: 'cpu' units: 'CPUs' slope: 'zero' type: 'uint16' description:'Number of CPUs' interval:1200 tmax:10 dmax:60 { metricvalue=oslength; ; };
Metric Options
title:'NodeJS CPUs Count'name: 'node_cpu_num'group: 'cpu'units: 'CPUs' // unit of your metricslope: 'zero' // zero | positive | negative | both | unspecifiedtype: 'uint16' // string | uint | uint8 | uint16 | uint32 | int8 | int16 | int32 | float | doubledescription:'Number of CPUs'interval:1200 // Periodic reporting interval in millisecondstmax:10dmax:60
Plugins
Creating a Plugin
- Create a project with the following structure:
/ initializers/ metrics/ scripts/ config/ package.json
-
Write an metric file in metrics/ folder for example:
- Write an config file for the metric to config/ folder for example config/metrics/cpu.js:
exportsdefault = { return 'node_cpu_num': enabled:true ; }
- Write an config install script to scripts/postinstall.js file for example:
#!/usr/bin/env node var fs = ;var path = ; var localConfig = path;var configPath = path;var config = path; if!fs console try fs; catche fs;
- Add to package.json the install script:
"scripts": "postinstall": "scripts/postinstall.js"
Including a Plugin
- Add to package.json your plugin:
"dependencies": { "am-your-plugin":"1.0.0" }
- Add to config/api.js your plugin:
metrics: // this is a list of metric plugin names 'am-your-plugin'