Awesome Open Source
Awesome Open Source
Chronos

Build Passing PRs Welcome License: MIT Release: 5.2

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

What's New?

  • New Feature
    • Chronos now comes in any OS .exe!
  • Overhauled Features
    • Authentication Enabling with Bcrypt
    • Stand-up times decreased
    • Side-by-side Server Comparisons
    • Color-hashing generates unique colors for each server connection
    • Improved navigation bar and buttons
    • Increased overall speed and responsiveness
  • Updated Features
    • Added React Testing Library
    • Removed Spectron and Enzyme
    • Added testing suites for unit, integration, and end-to-end testing
    • Refactored components for dependency injection
  • Bug Fixes
    • Authentication now functioning properly

Features

  • Distributed tracing enabled across microservices applications
  • Compatible with GraphQL
  • Supports PostgreSQL and MongoDB databases
  • Displays real-time temperature, speed, latency, and memory statistics
  • Display and compare multiple microservice metrics in a single graph

Return to Top

Demo

Chronos-Demo

Return to Top

Installation

This is for the latest Chronos version 5.2 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.

If you wish to launch the Electron Application in an WSL2 envirronment(Ubuntu) you may need the following commands for an Electron window to appear

  • Install VcXsrv

  • Run the following command in the terminal

sudo apt install libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev
  • After running your VcXsrv instance, run the following command in the terminal
export DISPLAY="`sed -n 's/nameserver //p' /etc/resolv.conf`:0"

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: 5000,
  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 default to recording server health every 60000 ms or 60 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 should be a string and only supports 'REST' and 'gRPC'
  • type should be a string and only supports 'MongoDB' and 'PostgreSQL'.
  • URI should be a connection string to the database where you intend Chronos to write and record data regarding health, HTTP route tracing, and container infomation.

NOTE: 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 in as arguments for microservice names.

Important In order to have container statistics 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 automatically record 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.

Getting the Chronos Executable

At the current moment, to get a copy of the executable that works on all OS, the steps are 1) clone the master branch, 2) run npm i, 3) run npm run prepareDist, 4) run npm run package-any, 5) navigate in your Chronos folder ./release-builds/resources and click on chronos.exe. 6) optionally right click to create a shortcut.

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.

chronosWebsite

This is the branch that holds the code base for the splash page. Edit the website by first running git clone -b chronosWebsite https://github.com/open-source-labs/Chronos.git . and then updating the aws S3 bucket with the changes.

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 bug fixes 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


Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Typescript (239,722
Reactjs (160,989
Docker (97,011
Email (21,340
Graphql (15,617
Slack (13,013
Microservices (11,958
Monitoring (11,776
Health (6,945
Docker Container (6,118
Grpc (5,038
Monitoring Tool (455
Microservice Toolkit (15