Skip to content

πŸ“Š πŸ“Š πŸ“Š Monitors the health and web traffic of servers, microservices, and containers with real-time data monitoring and receive automated notifications over Slack or email.

License

Notifications You must be signed in to change notification settings

kurto8/Chronos

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Chronos

Build Passing PRs Welcome License: MIT Release: 5.1

Chronos

⭐ Star us on GitHub β€” it helps! ⭐

Chronos is a comprehensive developer tool that monitors the health and web traffic of servers, microservices, and containers. Use Chronos to see real-time data monitoring and receive automated notifications over Slack or email.

Table of Contents

Return to Top

New Features

  • New UI Features
    • Developed search bar functionality to filter displayed databases
    • Login system for user authentication
    • Any errored connections will now show on the bell icon
    • Notification bell will update in real time
  • Bug Fixes
    • Fixed database icons to show the correct icon

Features

  • Distributed tracing enabled across microservices applications
  • Compatible with GraphQL
  • Provides Docker container stats (e.g. ID, memory usage %, CPU usage %, running processes, etc.)
  • Supports PostgreSQL and MongoDB databases
  • Displays real-time temperature, speed, latency, and memory statistics

Return to Top

Demo

Chronos-Demo

Return to Top

Installation

This is for the latest Chronos version 5.1 release and later.

  • Stable release: 6.1.0
  • LTS release: 6.1.0

Pre-Installation

Make sure you're running version 14.16.1 of Node, which is the most recent LTS (long-term support) version.

If you need to roll back from Node 16.1.0, make sure to run npm rebuild in the root directory.

If you're installing Chronos into a microservices application, and you have different folders for each microservice, make sure you also run npm rebuild in each microservices folder after you roll back to version 14.16.1.

Install Dependencies

To use Chronos in your existing application, download and install the following in the root directory of each of your microservice applications:

npm install chronos-tracker

Configure Chronos Tracker

Similarly, in the root directory of each of your microservice applications, create a chronos-config.js file with properties listed below:

// A sample `chronos-config.js` file

const chronos = require('chronos-tracker');

chronos.use({
  microservice: 'payments',
  interval: 2000,
  dockerized: true,
  database: {
    connection: 'REST',
    type: 'MongoDB',
    URI: process.env.URI,
  },
  notifications: [],
});

The microservice property takes in a string. This should be the name of your server or microservice. For Docker containers, the name of the microservice should be the same as the name of the corresponding Docker container.

The interval property is optional and takes in an integer. This controls the Chronos monitoring frequency. If this is omitted, Chronos will defualt to recording server health every 2000 ms or 2 seconds.

The dockerized property is optional and should be specified as true if the server is running inside of a Docker container. Otherwise, this should be false. If omitted, Chronos will assume this server is not running in a container.

The database property is required and takes in the following:

  • connection which should be a string and only supports 'REST' and 'gRPC'
  • type which should be a string and only supports 'MongoDB' and 'PostgreSQL'.
  • URI which should be a connection string the database you intend Chronos to write and record data regarding health, HTTP route tracing, and container infomation to. A .env is recommended.

The notifications property is optional. Jump to the section below, Notifications to configure Slack or email Slack notifications.

Initialize Chronos Tracker

Initialize Chronos Tracker for REST

Wherever you create an instance of your server (see example below),

// Example for REST
const express = require('express');
const app = express());

you will also need to require in chronos-tracker and initialize Chronos, as well as the ./chronos-config file. You will then need to invoke chronos.propagate() to initiate the route tracing, in addition to implementing chronos.track() for all endpoints.

const chronos = require('chronos-tracker');
require('./chronos-config'); // Bring in config file

// ...

chronos.propagate();
app.use('/', chronos.track());

You should be good to go! The last step, Docker Configuration, is only applicable if you need to configure Docker for your application.


Initialize Chronos Tracker for gRPC

Wherever you create an instance of your server (see example below),

  // Example of gRPC server
  const server = new grpc.Server();

  server.bindAsync("127.0.0.1:30044", grpc.   ServerCredentials.createInsecure(), () => {
    server.start();
    console.log("Server running at http://127.0.0.1:30044");
});

you will also need to require Chronos-tracker, Chronos-config, and dotenv.config(if this is used). For health data simply use Chronos.track()

//track health data
const chronos = require('chronos-tracker');
require('./chronos-config');
require('dotenv').config(); // set up environment variables in .env
const BookModel = require('./BookModel');

chronos.track()

To trace requests, first wrap the gRPC client using Chronos

const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const chronos = require('chronos');

const PROTO_PATH = './order.proto';

const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
  keepCase: true,
  longs: String,
  enums: String,
  arrays: true,
});
const OrderToBookService = grpc.loadPackageDefinition(packageDefinition).OrderToBook;
const bookClient = new OrderToBookService('localhost:30044', grpc.credentials.createInsecure());

const ClientWrapper = chronos.ClientWrapper(bookClient, OrderToBookService);

Next wrap the gRPC server using Chronos

  const ServerWrapper = chronos.ServerWrapper(server,  Proto.protoname.service, {
    AddBook: (call, callback) => {
    // console.log(call.metadata)
    // get the properties from the gRPC client call
      const { title, author, numberOfPages, publisher, bookID } = call.request;
    // create a book in our book collection
      BookModel.create({
        title,
        author,
        numberOfPages,
        publisher,
        bookID,
      });
      callback(null, {});
    },
  });
})

For any request you wish to trace, require uuidv4 and write the following code where the initial gRPC request begins,

const require { v4: uuidv4} = require('uuid')
const createMeta = () => {
  const meta = new grpc.Metadata();
  meta.add('id', uuidvd());
  return meta
}

and then invoke createMeta as a third argument to any client method that is the beginning of the request path.

orderClient.AddOrder(
    order,
    (err, data) => {
      if (err !== null) {
        console.log(err);
        // could not add order because bookID does not exist
        return res.sendStatus(404);
      }
      console.log('addOrder response: ', data);
      return res.sendStatus(200);
    },
    createMeta()
  );

Finally, on all servers that will be involved in the request path, invoke chronos.link with parameters of client and ServerWrapper in the server wrapper.

chronos.link(client, ServerWrapper);

Docker Configuration

Again, this step is only applicable if you are currently using Docker containers for your microservices.

Important Give your containers the same names you pass as arguments for microservice names.

Important In order to have container stats saved to your database, along with other health info, bind volumes to this path when starting up the containers:

/var/run/docker.sock

For example, you can type the following when starting up a container:

docker run -v /var/run/docker.sock:/var/run/docker.sock [your-image-tag]

If you're using docker-compose to start up multiple containers, you can add a volumes key for each of your services in the docker-compose.yml file:

volumes:
  - "/var/run/docker.sock:/var/run/docker.sock"

Start Chronos

Once you have configured and intialized Chronos Tracker, it will be automatically recording monitoring data when your servers are running. Finally, start the Chronos desktop app to view that data! After cloning our GitHub repo, run npm install and npm run both to start Chronos. Alternatively, you can download an executable for Mac. Add your application in the Chronos app dashboard with the same URI you used in your Chronos Tracker configuration. Click on it and start monitoring!

Return to Top

Notifications

The notifications property is optional and allows developers to be alerted when the server responds to requests with status codes >= 400. To set up notifications, set the value of the notifications property to an array of objects, each with a type and settings property.

Chronos only supports Slack and email notifications.

Slack

Chronos uses the Slack API to send messages to a Slack channel and only requires the webhook url. Learn how to set up Slack webhooks for your team.

An example of configured slack settings:

// ...
notifications: [
  {
    type: 'email',
    settings: {
      slackurl: process.env.WEBHOOK
    }
  }
]
// ...

Email

Chronos provides the option to send Slack emails. The properties that should be provided are the following

  • emails - The recipient list (string) can be a single email address or multiple as comma seprated values.
  • emailHost - The smtp host (string) of your email server
  • emailPort - The email port (integer) is either 465 or 587 depending on the sender email security settings. Learn more about email ports by reading the nodemailer docs
  • user - The email address (string) of the sender
  • password - The password (string) of the sender email

NOTE: Email notification settings may require alternative security settings to work

An example of configured email settings:

// ...
notifications: [
  {
    type: 'email',
    settings: {
      emails: '[email protected], [email protected]',
      emailHost: '[email protected]',
      emailPort: 465,
      user: process.env.SENDER_EMAIL,
      password: process.env.SENDER_PASSWORD
    }
  }
]
// ...

Return to Top

Branches

Master Branch

The 'master' branch of this repository is where the Electron application for Chronos is deployed. The Chronos monitoring tool includes two database examples, one PostgresQL and one MongoDB, with sample data sets.

NOTE: To replace or delete these two databases, simply change the database URIs stored in the following path:

root directory -> electron -> user -> settings.json

Examples

We provide two working example microservice applications in the master branch for you to test out Chronos: microservices and docker.

Microservices

In the microservices folder, we provide a sample microservice application that successfully utilizes Chronos to apply all the powerful, built-in features of our monitoring tool. You can then visualize the data with the Electron app.

Refer to the README in the microservices folder for more details.

Docker

In the Docker folder within the master branch, we provide a sample dockerized microservices application to test out Chronos and to apply distributed tracing across different containers for your testing convenience.

The docker folder includes individual Docker files in their respective directories. A docker-compose.yml is in the root directory in case you'd like to deploy all services together.

Refer to the README in the docker folder for more details.


gRPC Branch

The 'gRPC' branch is the current codebase for the NPM package, which is what you will install in your own application in order to use Chronos. Download the NPM package here.


Return to Top

Technologies

  • Electron
  • React
  • JavaScript
  • TypeScript
  • PostgreSQL
  • MongoDB
  • Node
  • Express
  • HTTP
  • gRPC
  • GraphQL
  • Docker
  • AWS
  • Jest
  • Enzyme
  • Spectron
  • Webpack
  • Material-UI
  • Vis.js
  • Plotly.js

Return to Top

Contributing

Development of Chronos is open source on GitHub through the tech accelerator umbrella OS Labs, and we are grateful to the community for contributing bugfixes and improvements. Read below to learn how you can take part in improving Chronos.

Return to Top

License

Chronos is MIT licensed.

Return to Top

About

πŸ“Š πŸ“Š πŸ“Š Monitors the health and web traffic of servers, microservices, and containers with real-time data monitoring and receive automated notifications over Slack or email.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 56.0%
  • JavaScript 23.6%
  • SCSS 20.1%
  • HTML 0.3%