
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
fh-component-metrics
Advanced tools
This component is used to gather metrics such as CPU and memory usage. Using InfluxDB and Grafana you can easily visualise the metrics.
The following docker image was used to build the necessary infrastructure to investigate this: https://github.com/StackPointCloud/docker-influxdb
The 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.
Here are the steps to use this module in an existing RHMAP component:
add this module as a dependency:
npm install fh-component-metrics --save
Then you can capture CPU & memory usage in the component use this code:
var fhComponentMetrics = require('fh-component-metrics');
var metricsConf = {enabled: true, host: '1.2.3.4', port: 2003, baseTags: {appId: process.env.APPID}};
var metrics = fhComponentMetrics(metricsConf);
var TITLE = 'myTestComponent';
metrics.memory(TITLE, { interval: 2000 }, function(err) {
if (err) logger.warn(err);
});
metrics.cpu(TITLE, { interval: 1000 }, function(err) {
if (err) logger.warn(err);
});
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
:
var fhComponentMetrics = require('fh-component-metrics');
var metricsConf = {enabled: true, backends:[{type: 'influxdb', host: '1.2.3.4', port: 2003}, {type: 'statsd', host: '1.2.3.4', port: 2004}], baseTags: {appId: process.env.APPID}};
var metrics = fhComponentMetrics(metricsConf);
//the metrics data will be sent to both the influxdb and statsd backend
At 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.
To capture API time, you can add the timingMiddleware to an existing express app like this:
var fhComponentMetrics = require('fh-component-metrics');
var metricsConf = {enabled: true, host: '1.2.3.4', port: 2003, baseTags: {appId: process.env.APPID}};
var app = express();
app.use(fhComponentMetrics.timingMiddleware('myExpressApp', metricsConf));
It's better the add the metrics configuration into the component's configuation file. E.g.
{
...,
"component_metrics": {
"enabled": true,
"host": "1.2.3.4",
"port": 2003
},
...
}
NOTE: each metric will be formatted as described in this spec before sending to the server.
NOTE: 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:
CPU metrics are supported only on Linux based operating systems.
FAQs
influx db metrics wrapper
The npm package fh-component-metrics receives a total of 1 weekly downloads. As such, fh-component-metrics popularity was classified as not popular.
We found that fh-component-metrics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.