{"_id":"@akeating-redhat/fh-component-metrics","_rev":"3-023b6a4b421cf776d08fe4ffbfc6490e","name":"@akeating-redhat/fh-component-metrics","description":"influx db metrics wrapper","dist-tags":{"latest":"2.7.0"},"versions":{"2.3.0":{"name":"@akeating-redhat/fh-component-metrics","version":"2.3.0","description":"influx db metrics wrapper","main":"index.js","scripts":{"test":"grunt eslint fh-test","version":"sed -i.bak \"s/sonar.projectVersion=.*/sonar.projectVersion=${npm_package_version}/\" sonar-project.properties && rm sonar-project.properties.bak && git add sonar-project.properties"},"author":{"name":"FeedHenry"},"license":"Apache-2.0","repository":{"type":"git","url":"git+ssh://git@github.com/feedhenry/fh-component-metrics.git"},"bugs":{"url":"https://github.com/feedhenry/fh-component-metrics/issues"},"dependencies":{"async":"2.0.1","lodash":"4.3.0"},"devDependencies":{"eslint":"^2.7.0","grunt":"^1.0.1","grunt-fh-build":"^1.0.1","istanbul":"^0.4.3","mocha":"^2.2.5","proxyquire":"^1.7.4","sinon":"^1.17.5"},"gitHead":"68e2bf82d44ee8f8ad23ff31fc115958dc4a2a40","homepage":"https://github.com/feedhenry/fh-component-metrics#readme","_id":"@akeating-redhat/fh-component-metrics@2.3.0","_shasum":"69fc2d018d14d09f2a82f2c6fa9bfe3620d2ab4b","_from":".","_npmVersion":"2.15.8","_nodeVersion":"4.4.7","_npmUser":{"name":"akeating-redhat","email":"akeating@redhat.com"},"dist":{"shasum":"69fc2d018d14d09f2a82f2c6fa9bfe3620d2ab4b","tarball":"https://registry.npmjs.org/@akeating-redhat/fh-component-metrics/-/fh-component-metrics-2.3.0.tgz","integrity":"sha512-oRmIqa97bDMv78DfLFsDmH+CvpRV1I3XY+twq7APlwJ1TKnCPVR/qdKIDjypB6jMQ2GnbvnNxRzaVa+92FeU6A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHCncT9UwcWgw4OmP9EqLYl3Kod+FovqVlH2vuv+WdSRAiA0UzRU+JpXvw3g321S+jFVmXRwPLY5Kt7xJyYic1zdAA=="}]},"maintainers":[{"name":"akeating-redhat","email":"akeating@redhat.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/fh-component-metrics-2.3.0.tgz_1485428516176_0.4462030620779842"}},"2.7.0":{"name":"@akeating-redhat/fh-component-metrics","version":"2.7.0","description":"influx db metrics wrapper","main":"index.js","scripts":{"test":"grunt eslint fh-test","version":"sed -i.bak \"s/sonar.projectVersion=.*/sonar.projectVersion=${npm_package_version}/\" sonar-project.properties && rm sonar-project.properties.bak && git add sonar-project.properties"},"author":{"name":"FeedHenry"},"license":"Apache-2.0","repository":{"type":"git","url":"git+ssh://git@github.com/feedhenry/fh-component-metrics.git"},"bugs":{"url":"https://github.com/feedhenry/fh-component-metrics/issues"},"dependencies":{"async":"2.1.5","debug":"^2.6.4","lodash":"4.17.4"},"devDependencies":{"eslint":"^2.7.0","grunt":"^1.0.1","grunt-fh-build":"^1.0.1","istanbul":"^0.4.3","mocha":"^2.2.5","proxyquire":"^1.7.4","sinon":"^1.17.5"},"gitHead":"34bf893cbb45e7a9426d622c9ca1c026384df900","homepage":"https://github.com/feedhenry/fh-component-metrics#readme","_id":"@akeating-redhat/fh-component-metrics@2.7.0","_shasum":"8a118670e2736e23e6bd8e6e758b2a9f016bf14b","_from":".","_npmVersion":"2.15.1","_nodeVersion":"4.4.3","_npmUser":{"name":"akeating-redhat","email":"akeating@redhat.com"},"dist":{"shasum":"8a118670e2736e23e6bd8e6e758b2a9f016bf14b","tarball":"https://registry.npmjs.org/@akeating-redhat/fh-component-metrics/-/fh-component-metrics-2.7.0.tgz","integrity":"sha512-oNliIMWr0LX6bjaVBgJOsZQRgEk1pnGjf+R/gc4qA6NZNYXr0rgiHNpoo8UiamAKkWhp1qNAW8/ou//sUctLCw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwlXXQyjRXINGco9BFhqv49lXP6ir7fhcRofP6Ssl4mQIhAPoTzQ3uZSAlCL3eUuyKeCcUz3v1QGgSxfKXBtfaUPqJ"}]},"maintainers":[{"name":"akeating-redhat","email":"akeating@redhat.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/fh-component-metrics-2.7.0.tgz_1493203556484_0.25690280413255095"}}},"readme":"# fh-component-metrics \n\nThis component is used to gather metrics such as CPU and memory usage. Using InfluxDB and \nGrafana you can easily visualise the metrics.\n\nThe following docker image was used to build the necessary infrastructure\nto investigate this:\nhttps://github.com/StackPointCloud/docker-influxdb\n\n# Influxdb Version\n\nThe 2.x version of this component is compatible with 0.10 release of Influxdb. It is using the line protocol to send metrics data over UDP port. Please make sure UDP is enabled in the Influxdb configurations.\n\n# Usage Guide\n\nHere are the steps to use this module in an existing RHMAP component:\n\n1. add this module as a dependency:\n\n    ```\n    npm install fh-component-metrics --save\n    ```\n\n2. Then you can capture CPU & memory usage in the component use this code:\n\n    ```\n    var fhComponentMetrics = require('fh-component-metrics');\n    var metricsConf = {enabled: true, host: '1.2.3.4', port: 2003};\n    var metrics = fhComponentMetrics(metricsConf);\n    var TITLE = 'myTestComponent';\n    metrics.memory(TITLE, { interval: 2000 }, function(err) {\n      if (err) logger.warn(err);\n    });\n\n    metrics.cpu(TITLE, { interval: 1000 }, function(err) {\n      if (err) logger.warn(err);\n    });\n    ```\n\n3. Send metrics data to multiple backends. By default, if you only need to send metrics data to an Influxdb backend, you can specify the configuration as the example above. But it also supports some other backends like Statsd and it can send the metrics data to multiple backends at the same time. To do that, you just need to change the configuration and replace the `host` and `port` value with an array called `backends`:\n\n   ```\n   var fhComponentMetrics = require('fh-component-metrics');\n   var metricsConf = {enabled: true, backends:[{type: 'influxdb', host: '1.2.3.4', port: 2003}, {type: 'statsd', host: '1.2.3.4', port: 2004}];\n   var metrics = fhComponentMetrics(metricsConf);\n   //the metrics data will be sent to both the influxdb and statsd backend\n   ```\n\nAt the moment, it supports Influxdb, Statsd and redis, so the valid options for the `type` field are `influxdb`, `statsd` and `redis`. See the next section for more details about the available options for each type.\n\n4. To capture API time, you can add the timingMiddleware to an existing express app like this:\n\n    ```\n    var fhComponentMetrics = require('fh-component-metrics');\n    var metricsConf = {enabled: true, host: '1.2.3.4', port: 2003};\n    var app = express();\n    app.use(fhComponentMetrics.timingMiddleware('myExpressApp', metricsConf));\n    ```\n\n5. It's better the add the metrics configuration into the component's configuation file. E.g.\n\n    ```\n    {\n      ...,\n      \"component_metrics\": {\n        \"enabled\": true,\n        \"host\": \"1.2.3.4\",\n        \"port\": 2003\n      },\n      ...\n    }\n    ```\n\n# Configuration Options for Each Backend Type\n\n## Influxdb\n\n* host: the host of the influxdb\n* port: the port of the influxdb. It has to be a UDP port.\n\n## Statsd\n\n* host: the host of the statsd server\n* port: the port of the statsd server. It has to be a UDP port.\n* keyBuilder: a function that will allow override how the metric key is being built. If not provided, a default function will be provided. See [statsd.js](./lib/clients/statsd.js) for more details.\n\nNOTE: each metric will be formatted as described in this [spec](https://github.com/b/statsd_spec) before sending to the server.\n\n## Redis\n\n* redisClient: an instance of https://github.com/NodeRedis/node_redis#rediscreateclient. \n* recordsToKeep: how many records to keep in redis\n* namespace: a prefix that will be added to each metric key\n\nNOTE: each record will be added to a list in Redis. The key for the list is the metric name. Each record will is a stringified JSON object, with the follow fields:\n\n* tags\n* fields\n* ts","maintainers":[{"name":"akeating-redhat","email":"akeating@redhat.com"}],"time":{"modified":"2022-06-12T14:26:56.372Z","created":"2017-01-26T11:01:56.818Z","2.3.0":"2017-01-26T11:01:56.818Z","2.7.0":"2017-04-26T10:45:57.507Z"},"homepage":"https://github.com/feedhenry/fh-component-metrics#readme","repository":{"type":"git","url":"git+ssh://git@github.com/feedhenry/fh-component-metrics.git"},"author":{"name":"FeedHenry"},"bugs":{"url":"https://github.com/feedhenry/fh-component-metrics/issues"},"license":"Apache-2.0","readmeFilename":"README.md"}