Skip to content

Commit 7f1c166

Browse files
committed
middle of writing chronos npm package readme
1 parent 4482b53 commit 7f1c166

27 files changed

+2531
-2069
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build
66
release-builds
77
coverage
88
__tests__/**/__snapshots__
9-
# .env
9+
.env
1010
users.json
1111
test_users.json
1212

__tests__/test_settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"setupRequired":false,"services":[["myPostgres","SQL","postgres://zwezmnqm:[email protected]:5432/zwezmnqm","Online bookstore with that keeps track of orders and customers","Jun 28, 2020 4:58 PM"],["ToddDB","MongoDB","mongodb+srv://tdwolf6:[email protected]/Chronos?retryWrites=true&w=majority","Web app deployed on AWS","Jul 3, 2020 7:12AM"],["orders","MongoDB","mongodb+srv://yangsong:[email protected]/orders?retryWrites=true&w=majority","orders","May 31, 2022 5:16 PM"]],"mode":"light mode","splash":true,"landingPage":"dashBoard"}
1+
{"setupRequired":false,"services":[["myPostgres","SQL","postgres://zwezmnqm:[email protected]:5432/zwezmnqm","Online bookstore with that keeps track of orders and customers","Jun 28, 2020 4:58 PM"],["ToddDB","MongoDB","mongodb+srv://tdwolf6:[email protected]/Chronos?retryWrites=true&w=majority","Web app deployed on AWS","Jul 3, 2020 7:12AM"],["orders","MongoDB","mongodb+srv://yangsong:[email protected]/orders?retryWrites=true&w=majority","orders","May 31, 2022 5:16 PM"],["JamesMongo","MongoDB","mongodb+srv://james:[email protected]/test?retryWrites=true&w=majority","","Jun 15, 2022 10:34 AM"],["JamesPostgres","SQL","postgres://dxdebork:[email protected]/dxdebork","","Jun 15, 2022 11:11 AM"]],"mode":"light mode","splash":true,"landingPage":"dashBoard"}

chronos_npm_package/README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Chronos 7
2+
3+
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.
4+
5+
## <div height=22 > What's New? </div>
6+
- New Features
7+
- The ability to monitor an Apache Kafka cluster via the JMX Prometheus Exporter
8+
- Added 19 new system-level metrics for monitoring!
9+
- Overhauled Features
10+
- Users can use the new query tool to select the specific metrics that they would
11+
like to monitor
12+
## Features
13+
- Distributed tracing enabled across microservices applications
14+
- Compatible with <img src="./app/assets/graphql-logo-color.png" alt="GraphQL" title="GraphQL" align="center" height="20" /></a>
15+
- Supports <a href="#"><img src="./app/assets/postgres-logo-color.png" alt="PostgreSQL" title="PostgreSQL" align="center" height="20" /></a> and <img src="./app/assets/mongo-logo-color.png" alt="MongoDB" title="MongoDB" align="center" height="20" /></a> databases
16+
- Displays real-time temperature, speed, latency, and memory statistics
17+
- Display and compare multiple microservice metrics at once
18+
- Monitor an Apache Kafka cluster via the JMX Prometheus Exporter
19+
#
20+
## Installation
21+
22+
To use Chronos in your existing application, download and install the following in the **root directory** of _each of your microservice applications_:
23+
```
24+
npm install chronos-tracker-7
25+
```
26+
27+
### Pre-Installation
28+
Make sure you're running version 14.16.1 of, which is the most recent LTS (long-term support) version.
29+
30+
If you need to roll back from <a href="#"><img src="./app/assets/node-logo-color.png" alt="Node" title="Node" align="center" height="20" /></a> 16.1.0, make sure to run
31+
```npm rebuild```
32+
in the root directory.
33+
34+
35+
<br>
36+
37+
### Configuring Chronos Tracker
38+
39+
Similarly, in the **root directory** of _each of your microservice applications_, create a `chronos-config.js` file with properties listed below:
40+
41+
```js
42+
// A sample `chronos-config.js` file
43+
44+
const chronos = require('chronos-tracker-7');
45+
46+
chronos.use({
47+
microservice: 'payments',
48+
interval: 5000,
49+
dockerized: true,
50+
database: {
51+
connection: 'REST',
52+
type: 'MongoDB',
53+
URI: process.env.URI,
54+
},
55+
notifications: [],
56+
});
57+
```
58+
59+
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.
60+
61+
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.
62+
63+
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.
64+
65+
The `database` property is required and takes in the following:
66+
- `connection` should be a string and only supports 'REST' and 'gRPC'
67+
- `type` should be a string and only supports 'MongoDB' and 'PostgreSQL'.
68+
- `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.
69+
We reccommend using dotenv
70+
71+
Wherever you create an instance of your server (see example below),
72+
73+
```js
74+
// Example for REST
75+
const express = require('express');
76+
const app = express();
77+
78+
```
79+
80+
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.
81+
82+
```js
83+
const chronos = require('chronos-tracker');
84+
require('./chronos-config'); // Bring in config file
85+
86+
// ...
87+
88+
app.use('/', chronos.track());
89+
```
90+
91+
You should be good to go! The last step, **Docker Configuration**, is **only applicable** if you need to configure <a href="#"><img src="./app/assets/docker-logo-color.png" alt="Docker" title="Docker" align="center" height="20" /></a> for your application.
92+
93+
<br>

chronos_npm_package/chronos-config.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// A sample `chronos-config.js` file
2+
3+
const chronos = require('./chronos.js');
4+
5+
chronos.use({
6+
microservice: 'PostGresTest',
7+
interval: 1000,
8+
dockerized: false,
9+
jmxuri: 'http://localhost:12345/metrics',
10+
database: {
11+
connection: 'REST',
12+
type: 'PostgreSQL',
13+
URI:
14+
'postgres://dxdebork:[email protected]/dxdebork',
15+
// type: 'MongoDB',
16+
// URI: 'mongodb+srv://james:[email protected]/test?retryWrites=true&w=majority',
17+
},
18+
notifications: [],
19+
});

chronos_npm_package/controllers/mongo.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ chronos.health = ({ microservice, interval }) => {
110110
setInterval(() => {
111111
collectHealthData()
112112
.then(healthMetrics => {
113-
console.log('HEALTH METRICS: ', healthMetrics);
113+
// console.log('HEALTH METRICS: ', healthMetrics);
114114
const HealthModel = HealthModelFunc(`${microservice}`);
115115
return HealthModel.insertMany(healthMetrics);
116116
})
@@ -219,7 +219,10 @@ KafkaModel.js, and inserts them into the db at the provided uri with insertMany(
219219
*/
220220
chronos.kafka = function (userConfig) {
221221
// ensure that kafkametrics exists in the services table
222-
const service = new ServicesModel({ service: 'kafkametrics', interval: userConfig.interval });
222+
const service = new ServicesModel({
223+
microservice: 'kafkametrics',
224+
interval: userConfig.interval,
225+
});
223226

224227
service
225228
.save()

chronos_npm_package/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "chronos",
2+
"name": "chronos7test",
33
"version": "1.1.0",
44
"description": "",
55
"main": "chronos.js",

examples/microservices/books/.env

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
BOOK_URI = mongodb+srv://alexkolb1:QKiNQxyxsQqBHLpi@cluster0.zmgge.mongodb.net/books?retryWrites=true&w=majority
2-
CHRONOS_URI = mongodb+srv://alexkolb1:QKiNQxyxsQqBHLpi@cluster0.zmgge.mongodb.net/chronos?retryWrites=true&w=majority
1+
BOOK_URI = mongodb+srv://james:james@cluster0.kb3y4.mongodb.net/Books?retryWrites=true&w=majority
2+
CHRONOS_URI = mongodb+srv://james:james@cluster0.kb3y4.mongodb.net/test?retryWrites=true&w=majority

examples/microservices/books/bookserver.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
const cmd = require('chronos-microservice-debugger3');
2-
cmd.propagate();
31
require('dotenv').config();
42

53
// const chronos = require('chronos-tracker');
6-
const chronos = require('../../../chronos_npm_package/chronos');
4+
const myURI = process.env.BOOK_URI;
5+
const chronos = require('chronos7test');
76
require('./chronos-config'); // Bring in config file
87

98
chronos.propagate();
@@ -12,12 +11,15 @@ const PORT = 4545;
1211
const express = require('express');
1312
const path = require('path');
1413
const cors = require('cors');
14+
1515
const app = express();
1616
const bodyParser = require('body-parser');
1717
const controller = require('./BookController.js');
1818

19+
chronos.kafka();
20+
1921
// UNCOMMENT THE LINE BELOW AND PASS IN YOUR CHOSEN ARGUMENTS
20-
app.use('/', cmd.microCom('books', 'mongo', process.env.BOOK_URI, 'yes'));
22+
// app.use('/', cmd.microCom('books', 'mongo', process.env.BOOK_URI, 'yes'));
2123
app.use('/', chronos.track());
2224

2325
app.use(bodyParser.json());
@@ -55,8 +57,6 @@ function errorHandler(error, req, res, next) {
5557
res.status(errorObj.status).json(errorObj.message);
5658
}
5759

58-
59-
6060
// Open and listen to server on specified port
6161
app.listen(PORT, () => {
6262
console.log(`Book server running on port ${PORT} ...`);
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
require('dotenv').config();
22
// const chronos = require('chronos-tracker');
3-
const chronos = require('../../../chronos_npm_package/chronos');
3+
const chronos = require('chronos7test');
44

55
chronos.use({
66
microservice: 'books',
77
interval: 2000,
8+
jmxuri: 'http://localhost:12345/metrics',
89
// dockerized: true,
910
database: {
1011
connection: 'REST',
1112
type: 'MongoDB',
1213
URI: process.env.CHRONOS_URI,
1314
},
1415
notifications: [],
15-
});
16+
});

0 commit comments

Comments
 (0)