Our Story
First prototyped in Feldkirch, Austria, then built out in full at the Umma Hüsla Hackathon "Reboot", October 2021
Want a dashboard, data persistence, logs, support, and more? Try moniter Enterprise at moniter.org - built upon this very package!
😄
Otherwise, follow the remaining documenation to see how you can use moniter
at your own organization.
Get Started
- Install the
moniter
package in your project:
npm install --save moniter
- Setup configuration files:
-
Copy the entire contents of the folder
example/src/config/moniter
to your project and modify all the configuration files: -
url-config.ts
: the list of URLs and the intervals at each that you want to monitor them. -
alert-config.ts
: the list of alert methods you wish to be notified by -
email-config.ts
: the email settings if you wish to be notified by email -
slack-config.ts
: the Slack webhook if you wish to be notified by slack
*** More contact methods are coming soon! ***
Once these files have been created, do not check them into git! They potentially contain secrets!
- Create a new
.ts
file (in this example namedmoniter-config.ts
) and import these configuration files and create a variable that corresponds to theIConfigConfig
interface:
// src/config/moniter/moniter-config.ts
import { IConfigConfig } from 'moniter';
import urlConfig from './url-config.js';
import alertConfig from './alert-config.js';
import emailConfig from './email-config.js';
import slackConfig from './slack-config.js';
const config: IConfigConfig = {
urlConfig,
alertConfig,
// TODO: add once properly configured for your organization:
// emailConfig,
// slackConfig,
};
export default config;
Note that according to IConfigConfig, at least a urlConfig and an alertConfig is required. This example follows the example/ folder and uses only the AlertMethod.CONSOLE alert type.
- Import
moniter
, and your newly created config and callmonitor(config)
to start monitoring! Or callrunImmediately(config)
to ignore the cron values and check all URLs immediately.
// index.js
import moniter, { runImmediately } from 'moniter'
import config from './src/config/moniter/monitor-config.js'
moniter(config);
// alternatively, run immediately for all URLs!
// runImmediately(config);
Question: Why the use of the .js
file extension everywhere when these are TypeScript files?
Answer: moniter
is trying to be very cool and uses esm
to package itself. This requires that write our imports filepaths with their compiled file paths(s), i.e., .js
.
TypeScript unfortunately does not consider it a responsibility for their library. See more here
Don't want to do all these steps yourself? Try moniter Enterprise at moniter.org - built on this very package!
😄
Example: Run With Forever
To have an on premise site uptime checker you can use anywhere, you can run moniter
by using the tool forever
:
forever start index.js
This will restart your index.js
process if moniter
crashes at any time.
See forever's repository for more information.
(We're not sponsored by forever
in any way, we just think it's a cool tool!
Example
See a working example in the example/ folder.