
Research
/Security News
Coruna Respawned: Compromised art-template npm Package Leads to iOS Browser Exploit Kit
Compromised npm package art-template delivered a Coruna-like iOS Safari exploit framework through a watering-hole attack.
搜集&汇报node应用metrics的二方库,目前暂时只提供一种一种在应用内将指标计算好的收集方式。
npm install n-metrics 或
yarn add n-metrics
const { registry, registryReporter, MeasurementKey, InfluxdbReporter } = require('n-metrics');
// 或者
import { registry, registryReporter, MeasurementKey, InfluxdbReporter } from 'n-metrics';
在应用中搜集metrics数据(QPS,RT,COUNT)等数据,然后汇报给influxdb,最后可以通过grafana进行展示
注意: 每个应用建议单独用一个库. 避免互相影响
所有的metrics的集中营
根据MeasurementKey取出表Measurement,相同MeasurementKey会取出相同的Measurement
name,[,key, value]+ 相同的measurementKey会进行累加,比如
`measurementKey("api.memcached", "host", "192.168.1.1")`
就可以理解为
应用
api,机器名为192.168.1.1的memcached指标
MeasurementKey支持多个tag,比如
key = new MeasurementKey("name", "host", "localhost", "cluster", "cluster-basic")
host用于举例,实际使用讲默认带此tag,不需要添加 在influxdb中一条记录的唯一性是通过表名+Tags确定的
对应influxdb中的一张表
counter、timer、v8gauge都是具体的指标
counter、timer和v8gauge都是实现了IMetrics,后续如果有更多类型的指标,可以继续扩张此类.
三者第一个参数对应influxdb中的field,如counter('tps')表示操作表的tps字段,其中v8gauge有第二个参数,指的是获取快照的时间间隔,单位,默认为5s,v8gauge只需要调用一次,内部就会定时收集内存快照,具体操作:
field字段的值为n,默认为1field)获取到timer开始就开始计时,调用stop后停止计时,期间如果多次调用timer(field),stop时将会获取平均值单例,所有报告注册中心,目前只提供一种报告方式,未来扩展可以往此添加即可
应用要上报数据,必须调用registryReporter.init进行初始化,可选项如下:
报告实例,实现IReporter接口 用于将metrics数据报告给influxdb config配置参见node-influx 另外提供了一个参数
数据库database、表measurement不存在时会自动创建
FAQs
搜集&汇报node应用metrics的二方库
The npm package n-metrics receives a total of 12 weekly downloads. As such, n-metrics popularity was classified as not popular.
We found that n-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.

Research
/Security News
Compromised npm package art-template delivered a Coruna-like iOS Safari exploit framework through a watering-hole attack.

Company News
As AI accelerates how code is written and shipped, Socket is scaling to protect the software supply chain from the growing wave of attacks targeting open source dependencies.

Company News
Socket is scaling to defend open source against supply chain attacks as AI accelerates software development.