# @ceramicnetwork/node-metrics

> Typescript library for publishing metrics from Ceramic nodes, as ceramic model instance documents

Latest version **1.0.5** (published 2024-07-15) · (Apache-2.0 OR MIT) license · 0 weekly downloads

## Install

```sh
npm install @ceramicnetwork/node-metrics
pnpm add @ceramicnetwork/node-metrics
yarn add @ceramicnetwork/node-metrics
bun add @ceramicnetwork/node-metrics
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2024-07-15 |
| First published | 2024-06-18 |
| Weekly downloads | 0 |
| License | (Apache-2.0 OR MIT) |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 29.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Golda Velez |
| Maintainers | dav1do, ceramic-velvetshark, cb3box, jpham2023, npm.3box, smrz2001, oed, paul_lecam, stbrody, ukstv |
| Keywords | Metrics, Ceramic Network |

## Links

- npm: https://www.npmjs.com/package/@ceramicnetwork/node-metrics
- Repository: https://github.com/ceramicnetwork/observability
- Homepage: https://github.com/ceramicnetwork/observability#readme
- Issues: https://github.com/ceramicnetwork/observability/issues
- npm.io page: https://npm.io/package/@ceramicnetwork/node-metrics

## Dependencies (7)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [dids](https://npm.io/package/dids.md) ^5.0.2
- [uint8arrays](https://npm.io/package/uint8arrays.md) ^5.0.1
- [key-did-resolver](https://npm.io/package/key-did-resolver.md) ^4.0.0
- [@ceramicnetwork/streamid](https://npm.io/package/@ceramicnetwork/streamid.md) ^3.3.0
- [key-did-provider-ed25519](https://npm.io/package/key-did-provider-ed25519.md) ^3.0.2
- [@ceramicnetwork/stream-model-instance](https://npm.io/package/@ceramicnetwork/stream-model-instance.md) ^2.3.0

## Recent versions

- 1.0.5 (latest) — 2024-07-15
- 1.0.3 — 2024-06-22
- 1.0.2 — 2024-06-18
- 1.0.1 — 2024-06-18

## README

# Node Metrics

Publishes metrics about Ceramic Nodes, on the Ceramic Network

 ## Purpose

Uses the decentralized CeramicNetwork to publish metrics and data about Ceramic Nodes

## Enable Configuration

In your `daemon.config.json` file (often found in ~/.ceramic directory), add the following setting:

```
"metrics": {
    "metrics-publisher-enabled": true
  }
```
and restart your ceramic daemon.  

Since the code to record metrics will already be incorporated into the daemon, no further action is necessary.

---

## Installation

Note, this class will be included as a dependency in ceramic daemon, so installation is not necessary.

However, if using in your own project, the package can be installed normally.

```sh
npm install @ceramicnetwork/node-metrics
```


## Usage

Import the class, start the metrics publishing service and record metrics.

```ts
import { NodeMetrics, Counter, Observable } from '@ceramicnetwork/node-metrics'

NodeMetrics.start({ceramic: ceramic, network: 'dev-unstable', intervalMS: 30000})

NodeMetrics.observe(Observable.TOTAL_PINNED_STREAMS, 100)
NodeMetrics.count(Counter.RECENT_COMPLETED_REQUESTS, 20)
ModelMetris.recordError('oops')

NodeMetrics.stopPublishing()

```


## Future Updates

If wishing to modify the metrics model, start by updating the model definition in the `./composites` directory, then
```ts
composedb composite:create your-schema.graphql --output=../__generated__/definition.json --did-private-key=your-private-key
cd ../__generated__
composedb composite:deploy definition.json --ceramic-url=http://localhost:7007 --did-private-key=...

composedb composite:compile definition.json definition.js
```
Depending on the changes made, code changes may need to be made as well, in particular start with the list of models defined in `src/publishMetrics.ts`

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