diff --git a/doc/admin.md b/doc/admin.md index 11e518e69..9b763aea6 100644 --- a/doc/admin.md +++ b/doc/admin.md @@ -164,16 +164,32 @@ support nulls or multi-attribute requests if they are encountered. It configures the periodic collection of statistics. Use `interval` in milliseconds to set the time between stats writings. -By default, stats are logged to the standard log at level `INFO`. If the `persistence` flag is defined and set to -`true`, stats are also stored in a collection named `kpis` in the mongo backend. +```javascript +stats: { + interval: 100; +} +``` + +By default, stats are logged to the standard log at level `INFO`. You can also have your stats written +to a collection named `kpis` in the mongo backend, if you do these two things: + +- Set the `stats.persistence` flag to `true`. ```javascript stats: { interval: 100; - persistence: false; + persistence: true; } ``` +- Schedule periodic collection of stats to mongo by calling `statsRegistry.addTimerAction`. + +```js +statsRegistry.addTimerAction(statsRegistry.mongodbPersistence, function callback() { + // ... called after timer is enabled ... +}); +``` + Each document in the `kpis` collection will have a `timestamp` attribute with the stat collection time, and an additional attribute for each of the stats created by calling the `statsRegistry.add` function, e.g.: @@ -181,7 +197,8 @@ additional attribute for each of the stats created by calling the `statsRegistry { "timeinstant": new ISODate("2024-07-29T00:00:00.000Z"), "deviceCreationRequests": 1334, - "deviceRemovalRequests": 454 + "deviceRemovalRequests": 454, + "measureRequests": 4432 } ```