mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
39 lines
7.9 KiB
JSON
39 lines
7.9 KiB
JSON
{
|
|
"name": "pmx",
|
|
"version": "0.3.23",
|
|
"description": "Keymetrics++ and PM2 adapter",
|
|
"main": "index.js",
|
|
"dependencies": {
|
|
"debug": "*",
|
|
"json-stringify-safe": "*"
|
|
},
|
|
"devDependencies": {
|
|
"express": "*",
|
|
"request": "*",
|
|
"should": "*",
|
|
"mocha": "*",
|
|
"shelljs": "*"
|
|
},
|
|
"scripts": {
|
|
"test": "DEBUG='axm:*' mocha test/*.mocha.js"
|
|
},
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/keymetrics/pmx.git"
|
|
},
|
|
"author": {
|
|
"name": "Keymetrics I/O"
|
|
},
|
|
"license": "MIT",
|
|
"readme": "\n# Driver for Keymetrics\n\n\n\nPMX is a module that allows you to create advanced interactions with Keymetrics.\n\nWith it you can:\n- Trigger remote actions / functions\n- Analyze custom metrics / variables (with utilities like Histogram/Counter/Metric/Meters)\n- Report errors (uncaught exceptions and custom errors)\n- Emit events\n- Analyze HTTP latency\n\n# Installation\n\n\n\nInstall PMX and add it to your package.json via:\n\n```bash\n$ npm install pmx --save\n```\n\nThen init the module to monitor HTTP, Errors and diverse metrics.\n```javascript\nvar pmx = require('pmx').init(); // By default everything is enabled and ignore_routes is empty\n```\nOr choose what to monitor.\n```javascript\nvar pmx = require('pmx').init({\n http : true, // HTTP routes logging (default: true)\n ignore_routes : [/socket\\.io/, /notFound/], // Ignore http routes with this pattern (Default: [])\n errors : true, // Exceptions loggin (default: true)\n custom_probes : true, // Custom probes (default: true)\n network : true, // Traffic usage monitoring (default: false)\n ports : true // Shows which ports your app is listening on (default: false)\n});\n```\n\n# Custom monitoring\n\n## Emit Events\n\nEmit events and get historical and statistics:\n\n```javascript\nvar pmx = require('pmx');\n\npmx.emit('user:register', {\n user : 'Alex registered',\n email : 'thorustor@gmail.com'\n});\n```\n\n## Custom Action\n\nTrigger function from Keymetrics\n\n### Long running\n\n```javascript\nvar pmx = require('pmx');\n\npmx.action('db:clean', { comment : 'Description for this action' }, function(reply) {\n clean.db(function() {\n /**\n * reply() must be called at the end of the action\n */\n reply({success : true});\n });\n});\n```\n\n## Errors\n\nCatch uncaught exceptions:\n```javascript\nvar pmx = require('pmx').init();\n```\n\nAttach more data from errors that happens in Express:\n```javascript\nvar pmx = require('pmx');\n\napp.get('/' ...);\napp.post(...);\n\napp.use(pmx.expressErrorHandler());\n```\n\nTrigger custom errors:\n```javascript\nvar pmx = require('pmx');\n\npmx.notify({ success : false });\n\npmx.notify('This is an error');\n\npmx.notify(new Error('This is an error'));\n```\n\n## TCP network usage monitoring\n\nIf you enable the flag `network: true` when you init pmx it will show network usage datas (download and upload) in realtime.\n\nIf you enable the flag `ports: true` when you init pmx it will show which ports your app is listenting on.\n\n\n## HTTP latency analysis\n\nMonitor routes, latency and codes. REST compliant.\n\n```javascript\npmx.http(); // You must do this BEFORE any require('http')\n```\nIgnore some routes by passing a list of regular expressions.\n```javascript\npmx.http({\n http : true, // (Default: true)\n ignore_routes : [/socket\\.io/, /notFound/] // Ignore http routes with this pattern (Default: [])\n});\n```\nThis can also be done via pmx.init()\n```javascript\npmx.init({\n http : true, // (Default: true)\n ignore_routes : [/socket\\.io/, /notFound/] // Ignore http routes with this pattern (Default: [])\n});\n```\n\n**This module is enabled by default if you called pmx with the init() function.**\n\n## Measure\n\nMeasure critical segments of you code thanks to 4 kind of probes:\n\n- Simple metrics: Values that can be read instantly\n - Monitor variable value\n- Counter: Things that increment or decrement\n - Downloads being processed, user connected\n- Meter: Things that are measured as events / interval\n - Request per minute for a http server\n- Histogram: Keeps a resevoir of statistically relevant values biased towards the last 5 minutes to explore their distribution\n - Monitor the mean of execution of a query into database\n\n#### Common options\n\n- `name` : The probe name as is will be displayed on the **Keymetrics** dashboard\n- `agg_type` : This param is optional, it can be `sum`, `max`, `min`, `avg` (default) or `none`. It will impact the way the probe data are aggregated within the **Keymetrics** backend. Use `none` if this is irrelevant (eg: constant or string value).\n\n\n### Metric\n\nValues that can be read instantly.\n\n```javascript\nvar probe = pmx.probe();\n\nvar metric = probe.metric({\n name : 'Realtime user',\n agg_type: 'max',\n value : function() {\n return Object.keys(users).length;\n }\n});\n```\n\n### Counter\n\nThings that increment or decrement.\n\n```javascript\nvar probe = pmx.probe();\n\nvar counter = probe.counter({\n name : 'Downloads',\n agg_type: 'sum'\n});\n\nhttp.createServer(function(req, res) {\n counter.inc();\n req.on('end', function() {\n counter.dec();\n });\n});\n```\n\n### Meter\n\nThings that are measured as events / interval.\n\n```javascript\nvar probe = pmx.probe();\n\nvar meter = probe.meter({\n name : 'req/sec',\n samples : 1,\n timeframe : 60\n});\n\nhttp.createServer(function(req, res) {\n meter.mark();\n res.end({success:true});\n});\n```\n#### Options\n\n**samples** option is the rate unit. Defaults to **1** sec.\n\n**timeframe** option is the timeframe over which events will be analyzed. Defaults to **60** sec.\n\n### Histogram\n\nKeeps a resevoir of statistically relevant values biased towards the last 5 minutes to explore their distribution.\n\n```javascript\nvar probe = pmx.probe();\n\nvar histogram = probe.histogram({\n name : 'latency',\n measurement : 'mean'\n});\n\nvar latency = 0;\n\nsetInterval(function() {\n latency = Math.round(Math.random() * 100);\n histogram.update(latency);\n}, 100);\n```\n\n#### Options\n\n**measurement** option can be:\n\n- min: The lowest observed value.\n- max: The highest observed value.\n- sum: The sum of all observed values.\n- variance: The variance of all observed values.\n- mean: The average of all observed values.\n- stddev: The stddev of all observed values.\n- count: The number of observed values.\n- median: 50% of all values in the resevoir are at or below this value.\n- p75: See median, 75% percentile.\n- p95: See median, 95% percentile.\n- p99: See median, 99% percentile.\n- p999: See median, 99.9% percentile.\n\n## Expose data (JSON object)\n\n```javascript\npmx.transpose('variable name', function() { return my_data });\n\n// or\n\npmx.tranpose({\n name : 'variable name',\n value : function() { return my_data; }\n});\n```\n\n## Modules\n\n### Simple app\n\n```\nprocess.env.MODULE_DEBUG = true;\n\nvar pmx = require('pmx');\n\nvar conf = pmx.initModule();\n```\n\n# Beta\n\n### Long running with data emitter (scoped action)\n\nA scoped action is an action that can emit logs related to this action.\n\n```javascript\nvar pmx = require('pmx');\n\npmx.scopedAction('scoped:action', function(options, res) {\n var i = setInterval(function() {\n // Emit progress data\n if (error)\n res.error('oops');\n else\n res.send('this is a chunk of data');\n }, 1000);\n\n setTimeout(function() {\n clearInterval(i);\n return res.end();\n }, 8000);\n});\n```\n\n\n# License\n\nMIT\n",
|
|
"readmeFilename": "README.md",
|
|
"gitHead": "8f487ccb89d25d5bc1d23a0fc75a50ae7d9aab5a",
|
|
"bugs": {
|
|
"url": "https://github.com/keymetrics/pmx/issues"
|
|
},
|
|
"homepage": "https://github.com/keymetrics/pmx#readme",
|
|
"_id": "pmx@0.3.23",
|
|
"_shasum": "fbb9c118f63109aedeb4309903898c70f978396b",
|
|
"_from": "pmx@*"
|
|
}
|