Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@akeating-redhat/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};
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}];
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};
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:
FAQs
influx db metrics wrapper
We found that @akeating-redhat/fh-component-metrics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.