# sr-monitor

> 上报数据到秒级监控上

Latest version **1.0.8** (published 2020-07-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install sr-monitor
pnpm add sr-monitor
yarn add sr-monitor
bun add sr-monitor
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2020-07-03 |
| First published | 2019-12-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | michaelcaot@icloud.com |
| Maintainers | michaelcao |

## Links

- npm: https://www.npmjs.com/package/sr-monitor
- npm.io page: https://npm.io/package/sr-monitor

## Dependencies (5)

- [qs](https://npm.io/package/qs.md) ^6.9.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [moment](https://npm.io/package/moment.md) ^2.24.0
- [request](https://npm.io/package/request.md) ^2.88.0
- [node-schedule](https://npm.io/package/node-schedule.md) ^1.3.2

## Recent versions

- 1.0.8 (latest) — 2020-07-03
- 1.0.7 — 2020-05-18
- 1.0.6 — 2020-05-15
- 1.0.4 — 2020-04-03
- 1.0.3 — 2020-03-12
- 1.0.1 — 2019-12-30
- 1.0.0 — 2019-12-30

## README

# sr-monitor
上报数据到秒级监控上

### Installation
```
npm install sr-monitor --save
```

### Usage
```js
  /**
   *
   * @param {*} url 上报的url，默认值：https://lingshou.tencent.com/monitor/notify
   * @param {*} srId 上报的鉴权的应用标识，默认值：process.env.SR_ID
   * @param {*} srSecret 上报的鉴权的密钥，默认值：process.env.SR_SECRET
   * @param {*} intfId 秒级监控的intfId
   * @param {*} sysId 秒级监控的sysId
   * @param {*} logging 日志回调函数，传入n个需要打印的参数
   */
const monitor = new Monitor({
  url: 'https://lingshou.tencent.com/monitor/notify',
  srId: process.env.SR_ID,
  srSecret: process.env.SR_SECRET,
  intfId: '3',
  sysId: '9900627',
  logging: (...args) => {
    console.log(...args);
  },
});

// 秒级监控的维度参数和指标维度：recordCount，requestCount, tableName
// 这三个参数需要在秒级监控中查询
monitor.report({
  recordCount: 1,
  requestCount: 3,
  tableName: 'aaa',
}).then((data, err) => {
  // 上报失败
  if (err) {
    console.log(err);
  }
  // 上报成功
  console.log(data);
});
```

---
_Source: https://npm.io/package/sr-monitor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
