Skip to content

Commit

Permalink
Merge branch 'release/2.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
chronosis committed Oct 29, 2019
2 parents 9480e9f + fd9d197 commit f783ce4
Show file tree
Hide file tree
Showing 38 changed files with 3,434 additions and 2,171 deletions.
17 changes: 14 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@ before_script:
script:
- gulp
- npm run coverage
branches:
only:
- master
- develop
cache:
directories:
- node_modules
env:
global:
- secure: qz+adZh+VJPpKpRSe8pr2dtfwfgbXPfA30jrBa9CW9aSm5aMjKU5zqU+u34G1Jk/A1euOuqZ7t6ORUW65KqTHZxvu5fboHpaVDfjR6usYgDjeYt0hR19sP/jCrR4uNyZbqOs8Pdg4FR7Yke7WsKkmFKh9Z561c6QcU5gIUIR3/9uRor/zyjp00h5aEv5YSFGWbd1CsddG5RL0tVw1XfMEAbuMFpa6BbmG45FSFI6k3BVa2X2tUUmi6VZieG6UaAz55YBn+nRv4LLXXR2EO3TZSn5Tid5UhaU955t2UKwdcRzeIo0oSZNM14tsOAxuDk51Nz7WucT2wVwV8qEXe9lhraTF2f4a2gx6KQSCSwi8dF6wPxDM7kJ5HiAUc4EDBRrGDKvcaNj2fCEZyM2AKJPXCoUysZyOxF5K5cjoTbMkwtDm7bR9M1yd5MTQ51jt3604JLvkSMjOjCZvEDWxFCSxAE4ktedCcU7JzxCHuklemJdnfZb1RGNUz796aNB8zRC1JCWcpwSO328xAXpYu4h3GMVqpZUI1Fg7xOZHZPVTZpT1mJJzI3z9HinGW8pwWsFHbuyawd0JiI7PteYFwEKYOKy+jeztOHaDHS+gBL0tyGNUia1C0QKEVNyKLMynGYMTwvqWxpnT0FTR9JSV+TPp0bVPngpEbh0O+rJxBa27n4=
- secure: F8buJtanB5DpkUqzP8rOK3Y9q5auPON795wkxZih1RyHSwT9cVOjpWcL1owWWXWVzY8hTya1jW7V1hKxP96ijefZSVExUrS5bktB+MW7F1icVw3hIc5KPU30Ry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T+KGfADccISeAnyApAYSOnylXXThADwybMW/8/EWGIg62Vhbtb+NkdpSQjBm5dCOxvp4ODfWaf79SNW2GedwCY=
email:
secure: X+d24R5uX+2jzEsg8yZ4Mk8F4bueJWgkRtV99Lz9uzg5nGWSDkD655cIZrCFBhOVlNcLM2khsWNQcNdaP5GbA8Csg1VsU+5Gi1NabxSvKv9JbLGVjxwpRNpAKTQzmWGwE7sv2R1kgjYuqCDTzrlEnY3ndR/t4a0ID4dk7es4xHSndbG0gwglxmOPL07k7YGKMc5W+oWrkiMmTqG2vZ1FHurJruj378NDmMAtdi2MqTo26jiJz4SYsCsNAICsLCq+6e51hcbdK3UnQBOrqDrVUgshbIPaI7r1uuKb3fdC2HAN4MunLAj/va5A7239P2v6St1/tbXGIn007pG86oBH4WyZ+WB1QooZggGrI8HJCeld6odseac0B+iA9/tgtUz/hqeumymq5TJsU6an5shC/9MVudj1hxkZdn7lIi8+VBsKN9tFKopdIhpku/5mUWYKjyXJwtjmbUiP4jFIxQGi4Yjm5WfymM32c8gWGx9a/k5CqHfAyt+ebViZdtlAzGCpUrFBEI40NRG9D1NXEyw0OWpm+0MdhNveIkAKxQ8fAih+WaIgCM/PLRm2P1JecDfOl1P7l5p+vRs9wy7uAac7glkX1j2scG74tqWh7CiDkbTZc9U4JzjaO1mjk+9crYPCGY/os0AjtrS3gdHWRvrbjlzrMW2jPulsEdUsgfkaPlw=
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2017 Jay Reardon
Copyright (c) 2017, 2018, 2019 Jay Reardon
Copyright (c) 2019 Out of Sync Studios LLC

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
49 changes: 34 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
[![NPM](https://nodei.co/npm/uriel.png?downloads=true)](https://nodei.co/npm/uriel/)

[![Actual version published on npm](http://img.shields.io/npm/v/uriel.svg)](https://www.npmjs.org/package/uriel)
[![Travis build status](https://travis-ci.org/MediaXPost/uriel.svg)](https://travis-ci.org/MediaXPost/uriel)
[![Travis build status](https://travis-ci.org/OutOfSyncStudios/uriel.svg)](https://travis-ci.org/OutOfSyncStudios/uriel)
[![Total npm module downloads](http://img.shields.io/npm/dt/uriel.svg)](https://www.npmjs.org/package/uriel)
[![Package Quality](http://npm.packagequality.com/shield/uriel.svg)](http://packagequality.com/#?package=uriel)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/d264ea63a69a4e3899ce06d6e81f18fb)](https://www.codacy.com/app/chronosis/uriel?utm_source=github.com&utm_medium=referral&utm_content=MediaXPost/uriel&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/d264ea63a69a4e3899ce06d6e81f18fb)](https://www.codacy.com/app/chronosis/uriel?utm_source=github.com&utm_medium=referral&utm_content=MediaXPost/uriel&utm_campaign=Badge_Coverage)
[![Dependencies badge](https://david-dm.org/MediaXPost/uriel/status.svg)](https://david-dm.org/MediaXPost/uriel?view=list)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ced17e413a2e48b0b27c3bc691a7c479)](https://www.codacy.com/manual/OutOfSyncStudios/uriel?utm_source=github.com&utm_medium=referral&utm_content=OutOfSyncStudios/uriel&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/ced17e413a2e48b0b27c3bc691a7c479)](https://www.codacy.com/app/OutOfSyncStudios/uriel?utm_source=github.com&utm_medium=referral&utm_content=OutOfSyncStudios/uriel&utm_campaign=Badge_Coverage)
[![Dependencies badge](https://david-dm.org/OutOfSyncStudios/uriel/status.svg)](https://david-dm.org/OutOfSyncStudios/uriel?view=list)

A simple service that pushes system information (e.g. system usage, memory, cpu, network, swap, diskio, and disk usage) to any compatible statsd service (e.g. StatsD, Telegraf, DogStatsD, etc.)

***Note:*** Version 2.0.0 contains breaking changes to how some statistics are delivered to the statsd server, and how the Uriel process is configured. Please consult the documentation for information on these breakages.

# Table of Contents

1. [Documentation](#documentation)
1. [Migrating from 1.x](#migrating)
2. [Documentation](#documentation)
1. [Modes of Operation](#uriel-modes)
1. [Stand-alone Service](#standalone)
1. [Installation](#standalone-installation)
Expand All @@ -31,13 +34,22 @@ A simple service that pushes system information (e.g. system usage, memory, cpu,
2. [Configuration Object](#uriel-configuration)
3. [Logging Object](#uriel-logging)
4. [Statsd Buckets](#statsd-buckets)
2. [Changelog](#changelog)
3. [License](#license)
3. [Changelog](#changelog)
4. [License](#license)

# Goals
**`Uriel`** is designed to be a lightweight NodeJS agent that gathers system information and delivers it to a compatible statsd service over UDP. It can be embedded within another service, or setup and configured as its own stand-alone service that runs on the system being monitored. At the time of creation, other NodeJS systeminfo agents were unsuitable due to their inflexibility or poor implementations. Uriel was created to (ideally) bridge those shortcomings. It uses UDP, because of the decreased network overhead that is required in comparison to TCP.

The name [Uriel](https://en.wikipedia.org/wiki/Uriel) is associated with Abrahamic religions for the Archangel which represents the light of the divine and as one who had dominion over another type of angel, the Gregori (i.e. The Watchers). The name was chosen both because of its association with illuminating dark places and watching things -- concepts related to system monitoring.
The name [Uriel](https://en.wikipedia.org/wiki/Uriel) is associated with Abrahamic religions for the Archangel which represents the light of the divine and as one who had dominion over another type of angel, the Gregori (a.k.a. ***The Watchers***). The name was chosen both because of its association with illuminating dark places and watching things which are two abstract concepts related to system monitoring.

<a name="migrating"></a>
# [Migrating from 1.x](#migrating)
So that grouped dashboards are possible, version 2.x moves CPU and Disk Usage reporting for individual cpu/disks and the aggregate totals into tagged metrics. Any dashboards which rely on this reporting will need to be updated as follows:
* If you are monitoring total CPU or Disk stats, then you will need to update your dashboards to look for the `cpu:total` or `disk:total` respectively.
* If you are monitoring individual CPU or Disks, then you will need to update your dashboards from `cpu.cpu0_usage_idle` / `disk.disk0_free` to `cpu.usage_idle` / `disk.free` with tags `cpu:0` / `disk:0`.

It is also now possible to configure global tags which are sent for all metrics in the server configuration. These are setup with the `statsd.tags` array of the server configuration. This allows for
systems being monitored in auto-scaling groups or under load-balancing to be grouped together by shared tags in dashboards. This is especially useful under architectures where the exact specification (size/number of systems/etc.) is mutable.

<a name="documentataion"></a>
# [Documentation](#documentation)
Expand All @@ -62,7 +74,7 @@ To install, clone the git repository:


```
$ git clone https://github.com/MediaXPost/uriel.git
$ git clone https://github.com/OutOfSyncStudios/uriel.git
$ cd uriel
```

Expand Down Expand Up @@ -113,7 +125,7 @@ $ pm2 start app.js -n "Uriel" -i 1 -- -c <fullpath to config file>
To install, clone the git repository:

```
$ git clone https://github.com/MediaXPost/uriel.git
$ git clone https://github.com/OutOfSyncStudios/uriel.git
$ cd uriel
```

Expand All @@ -124,7 +136,7 @@ To configure, run:
```shell
npm run config
```
This will ask a series of questions which provides the base configuration. Alternatively, it is possible to manually edit the `<uriel-base>/config/config.js` file to make adjustments. The configuration file is an exported version of the [Configuration Object](#relay-configuration).
This will ask a series of questions which provides the base configuration. Alternatively, it is possible to manually edit the `<uriel-base>/config/config.js` file to make adjustments. The configuration file is an exported version of the [Configuration Object](#uriel-configuration).

<a name="docker-running"></a>
#### [Running](#docker-running)
Expand Down Expand Up @@ -259,7 +271,6 @@ The following buckets are used to capture statistics:
|**`cpu.usage_idle`**|CPU|% of CPU idle|
|**`cpu.usage_irq`**|CPU|% of CPU usage from system IRQs|
|**`cpu.usage_total`**|CPU|% of non-idle CPU usage|
|**`cpu.cpu(#)_...`**|CPU|Same stats as above, but for the individually # cpu|
|**`cpu.num_cpus`**|CPU|Count of CPUs on the system|
|**`mem.free`**|Memory|Free Memory (in bytes)|
|**`mem.free_percent`**|Memory|% of Free Memory|
Expand All @@ -285,19 +296,26 @@ The following buckets are used to capture statistics:
|**`disk.total`**|Disk Usage|Total Disk (in bytes)|
|**`disk.used`**|Disk Usage|Used Disk (in bytes)|
|**`disk.used_percent`**|Disk Usage|% of Used Disk|
|**`disk.disk(#)_...`**|Disk Usage|Same stats as above but for the individually numbered disk|
|**`disk.num_disks`**|Disk Usage|Count of Disks in the system|
|**`swap.free`**|Swap Usage|Free Swap (in bytes)|
|**`swap.free_percent`**|Swap Usage|% of Free Swap|
|**`swap.total`**|Swap Usage|Total Swap (in bytes)|
|**`swap.used`**|Swap Usage|Used Swap (in bytes)|
|**`swap.used_percent`**|Swap Usage|% of Used Swap|

**Note:** CPU or Disk Usage reflect the combined usage across all CPUs or Disks.
**Note:** CPU or Disk Usage are delivered as tagged sets, with the 'cpu' and 'disk' tags respectively to mark the individual cpu or disk numbers or the 'total' for the aggregation of all cpus or disks.

<a name="changelog"></a>
# [Changelog](#changelog)

## 2.0.0
***Note***: This is a major version change that contains breaking changes to the old function & reporting. Please review the documentation for updates to how data is now reported.
* Improvements on delivery and handling of tagged metrics, an array of tags can now be configured to be delivered with each metric
* CPU and Disk Usage reporting are now delivered as tagged sets of data. The `cpu` and `disk` tags provide enumerate each of the individual cpus and disks; or have the tag value `total` to indicate the aggregation of all items.
* Refactored all monitors to be execute as Promises to reduce memory and cpu overhead
* Refactored statistics collection to use a factory pattern in an effort to further reduce memory overhead
* Migrated to Winston v3 logging

## 1.9.6
* Updating outdated dependencies again
* Additional improved logging
Expand Down Expand Up @@ -337,4 +355,5 @@ The following buckets are used to capture statistics:
<a name="license"></a>
# [License](#license)

Copyright (c) 2017, 2018 Jay Reardon -- Licensed under the MIT license.
Copyright (c) 2017, 2018, 2019 Jay Reardon
Copyright (c) 2019 Out of Sync Studios LLC -- Licensed under the MIT license.
26 changes: 11 additions & 15 deletions app/lib/logger.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// app/lib/logger.js

// Dependencies
const __ = require('@mediaxpost/lodashext');
const __ = require('@outofsync/lodash-ex');
const fs = require('fs');
const winston = require('winston');
const { format } = winston;

/**
* A utility class to wrap Winston logging
Expand All @@ -21,32 +22,23 @@ class Logger {
filename: `${this.logDir}/info.log`,
name: 'info-log',
level: 'info',
formatter: this.formatter
format: format.printf(this.formatter)
}),
new winston.transports.File({
filename: `${this.logDir}/error.log`,
name: 'error-log',
level: 'error',
formatter: this.formatter
format: format.printf(this.formatter)
})
];

// Optimization -- Add console logging if not in production
// if ((process.env.NODE_ENV !== 'production') && (process.env.NODE_ENV !== 'test')) {
transports.push(new winston.transports.Console({ level: 'debug', formatter: this.formatter }));

// transports.push(
// new (winston.transports.File) ({
// filename: this.logDir + '/debug.log',
// name: 'debug-log',
// level: 'debug',
// formatter: this.formatter
// })
// );
// }
this.options = {
exitOnError: false,
formatter: this.formatter,
format: winston.format.printf(this.formatter),
transports: transports
};

Expand All @@ -58,11 +50,15 @@ class Logger {

// Merge options from config into this object
this.options = __.assign(this.options, config.logging.options);
this.log = new winston.Logger(this.options);
this.log = winston.createLogger(this.options);
}

formatter(options) {
return `${new Date().toISOString()} [${options.level.toUpperCase()}]: ${options.message}`;
let message = options.message;
if (!message) {
message = JSON.parse(options[Symbol.for('message')])['@message'];
}
return `${new Date().toISOString()} [${options.level.toUpperCase()}]: ${message}`;
}

handleError(err) {
Expand Down
72 changes: 50 additions & 22 deletions app/lib/monitor.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,73 @@
// app/lib/monitor.js
const __ = require('@mediaxpost/lodashext');
const Statistic = require('./statistic');
const __ = require('@outofsync/lodash-ex');

class Monitor {
constructor(name, hostname, statsd, log, tags) {
constructor(name, statsFactory) {
this.name = name;
this.hostname = hostname;
this.statsd = statsd;
this.log = log;
this.statsFactory = statsFactory;
this.statistics = [];
this.tags = [];
if (Array.isArray(tags)) {
// Make a copy of the tags array (the original array should remain immutable)
this.tags = Object.assign([], tags);
}
this.log = this.statsFactory.log;
}

bundleStats(stats, tags) {
tags = tags || [];
return {
value: stats,
tags: tags
};
}

setStats(obj) {
setStats(objArr) {
this.log.silly(`[${this.name}] Setting statistics`);
this.statistics = __.toPairs(obj).map((pair) => {
let name = this.name + '.' + pair[0];
return new Statistic(name, pair[1], this.hostname, this.statsd, this.log, this.tags);
});
if (!Array.isArray(objArr)) {
objArr = [objArr];
}
this.statistics = [];
for (let itr = 0, itrTest = objArr.length; itr < itrTest; itr++) {
const obj = objArr[itr];
const tempStats = __.toPairs(obj.value).map((pair) => {
const name = this.name + '.' + pair[0];
const val = pair[1];
return this.statsFactory.create(name, val, obj.tags);
});
this.statistics = this.statistics.concat(tempStats);
}
}

send(isActive) {
// Only send if the server is still active and not shutting down
if (isActive) {
this.log.silly(`[${this.name}] Sending statistics`);

const statistics = this.statistics;
for (let itr = 0, jtr = statistics.length; itr < jtr; itr++) {
const stat = statistics[itr];
stat.send();
}
this.statsFactory.send(this.statistics);
}
}

sendPromise(isActive) {
return new Promise((resolve) => {
resolve(this.send(isActive));
});
}

clear() {
this.statistics = [];
}

clearPromise() {
return new Promise((resolve) => {
resolve(this.clear());
});
}

collect() {
// Do Nothing.. this is for override reasons
return;
}

collectPromise() {
return new Promise((resolve) => {
resolve(this.collect());
});
}
}

module.exports = Monitor;
Loading

0 comments on commit f783ce4

Please sign in to comment.