Skip to content

Commit 9d14027

Browse files
Merge pull request #29 from oslabs-beta/E-readme
E readme
2 parents cbdafd5 + bbac43b commit 9d14027

1 file changed

Lines changed: 73 additions & 72 deletions

File tree

chronos_npm_package/README.md

Lines changed: 73 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -20,84 +20,64 @@
2020
## Using Chronos
2121
The following steps should be performed in each microservice you want to track unless otherwise noted.
2222

23-
### Install Chronos Tracker
23+
### 1. Install Chronos Tracker
2424
Install the package as a dependency in each of the microservices you want to track:
2525

2626
```
2727
npm install @chronosmicro/tracker
2828
```
2929

3030

31-
### Configuring Chronos Tracker
32-
Create a `.js` Chronos configuration file (hereby referred to as `chronos-config.js`), which exports a JavaScript object with required Chronos configuration parameters. This object will be used as the sole Chronos class constructor argument. Feel free to use a `.env` file to hold sensitive parameters like the database URI, for example.
31+
### 2. Configuring Chronos Tracker
32+
Create a `chronos-config.js` file, which exports a JavaScript object with required Chronos configuration parameters. Use this configuration to customize Chronos for your specific microservice environment.
3333

3434
```js
3535
// A sample `chronos-config.js` file
36+
//replace the values with your specific configuration
3637

3738
module.exports = {
3839
// General Configuration
39-
microservice: 'my-service',
40-
interval: 10000,
40+
microservice: 'my-service', //Name of your microservice. For **Dockerized** microservices, this field **must** match the container_name of the corresponding Docker container.
41+
interval: 10000, //monitoring interval in milliseconds, if ommitted, Chronos will default to recording server health every 60000 ms.
4142

4243
// Database Information
4344
database: {
44-
connection: 'REST', // 'REST' or 'gRPC'
45-
type: 'MongoDB', // 'MongoDB' or 'PostgreSQL'
46-
URI: '<insert URI>', // <insert URI>
45+
connection: 'REST', // Choose 'REST' or 'gRPC' for your connection type
46+
type: 'MongoDB', // Choose 'MongoDB' or 'PostgreSQL'
47+
URI: '<insert 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
4748
},
4849

49-
/* USE ONE OF THE MODE-SPECIFIC CONFIGURATIONS BELOW */
50-
// (a) Microservices
50+
/* USE ONLY ONE OF THE CONFIGURATIONS BELOW: */
51+
// (a) Microservices Mode
5152
mode: 'microservices',
52-
dockerized: false, // false or true
53+
dockerized: false, // set to true if your service is Dockerized
5354

5455
// (b) Kubernetes
5556
mode: 'kubernetes',
56-
promService: 'prometheus-service',
57-
promPort: 8080,
58-
grafanaAPIKey: process.env.CHRONOS_GRAFANA_API_KEY,
57+
promService: 'prometheus-service', // Prometheus service name
58+
promPort: 8080, //Prometheus service port
59+
grafanaAPIKey: process.env.CHRONOS_GRAFANA_API_KEY,//API for Grafana
5960

6061
// (c) Apache Kafka
6162
mode: 'kafka',
62-
jmxuri: '<insert URI>',
63+
jmxuri: '<insert URI>', //URI for JMX to Prometheus Exporter
6364

6465
// (d) Docker
6566
mode: 'docker',
66-
promService: 'docker.for.mac.localhost',
67-
promPort: 9090,
68-
grafanaAPIKey: process.env.CHRONOS_GRAFANA_API_KEY,
67+
promService: 'docker.for.mac.localhost', //Prometheus service for Docker
68+
promPort: 9090, //Prometheus service port
69+
grafanaAPIKey: process.env.CHRONOS_GRAFANA_API_KEY, //API key for Grafana
70+
6971

70-
/* USE ONE OF THE MODE-SPECIFIC CONFIGURATIONS ABOVE */
7172

7273
// Notifications
74+
//Add notification configurations here
7375
notifications: [],
7476
}
7577
```
78+
Note: Consider using a `.env` file to securely store sensitive parameters like database URIs.
7679

77-
Then utilize the `chronos-config.js` file into your application by importing it and using it as the Chronos class constructor argument:
78-
```js
79-
const chronosConfig = require('./chronos-config.js');
80-
const Chronos = require('@chronosmicro/tracker');
81-
const chronos = new Chronos(chronosConfig);
82-
```
83-
84-
85-
#### Chronos Configuration Parameters
86-
_See mode-specific configuration descriptions in the "Chronos Tracker for Microservices" section_
87-
88-
The `microservice` property takes in a string. This should be a descriptive name for your microservice.
89-
90-
- <img src="../assets/important.png" alt="Important" title="Important" align="center" height="20" /> For **Dockerized** microservices, this field **must** match the _container_name_ of the corresponding Docker container.
91-
92-
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.
93-
94-
The `database` property is required and takes in the following:
95-
- `connection` is a string that should should be either 'REST' or 'gRPC'
96-
- `type` should be a string and only supports 'MongoDB' and 'PostgreSQL' at this time
97-
- `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
98-
99-
The `mode` property accepts a string that can either be 'microservices', 'kubernetes', 'kafka', or 'docker'. There are other settings that depend on the mode choice, so these are broken down in the "Chronos Tracker for Microservices" section.
100-
80+
### 3. Configuring notifications
10181
The `notifications` property is an array that can be optionally left empty. It 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.
10282

10383
Chronos only supports **Slack** and **email** notifications at this time.
@@ -124,32 +104,48 @@ notifications: [
124104
{
125105
type: 'email',
126106
settings: {
127-
emails: 'foobar@email.com, bizbaz@email.edu',
128-
emailHost: 'smpt@gmail.com',
129-
emailPort: 465,
130-
user: process.env.SENDER_EMAIL,
131-
password: process.env.SENDER_PASSWORD
107+
emails: 'foobar@email.com, bizbaz@email.edu', //can be single or multiple, separated by a comma
108+
emailHost: 'smpt@gmail.com',// the smtp host of your email server
109+
emailPort: 465, // the email port is either **465** or **587** depending on the sender email security settings. Learn more about email ports by reading the [nodemailer docs](https://nodemailer.com/smtp/)
110+
user: process.env.SENDER_EMAIL, //email address of the sender
111+
password: process.env.SENDER_PASSWORD //password of the sender's email
132112
}
133113
}
134114
]
135-
// ...
136115
```
137116

138-
Chronos provides the option to send emails. The properties that should be provided are the following
139-
- `emails` - The recipient list (string) can be a single email address or multiple as comma seprated values.
140-
- `emailHost` - The smtp host (string) of your email server
141-
- `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](https://nodemailer.com/smtp/)
142-
- `user` - The email address (string) of the sender
143-
- `password` - The password (string) of the sender email
144117

145118

146-
**NOTE: Email notification settings may require alternative security settings to work**
119+
### 4. Utilize `chronos-config.js` in your application
120+
To integrate the `chronos-config.js` file into your application, follow these steps:
121+
1. importing the `chronos-config.js` file
122+
```js
123+
const chronosConfig = require('./chronos-config.js');
124+
```
125+
2. importing the Chronos class
126+
```js
127+
const Chronos = require('@chronosmicro/tracker');
128+
```
129+
3. creating a new instance of the Chronos class
130+
```js
131+
const chronos = new Chronos(chronosConfig);
132+
```
133+
147134
#
135+
### Mode Specific Configurations
136+
137+
138+
139+
### A. Chronos Tracker for "Microservices" Mode
140+
In the `microservices` mode, Chronos employs the `dockerized` setting to determine the operational environment of the microservice.
141+
142+
* `dockerized`: This setting is crucial for specifying the nature of the service deployment.
143+
* Default Setting: If `dockerized` is not explicitly set to true, Chronos defaults to assuming that the service is not operating in a Docker container environment. Hence, the default value of `dockerized` is false.
144+
* When `dockerized` is `false`: This configuration tells Chronos to collect metrics directly from the host system. It's applicable for services running outside of Docker containers.
145+
* When `dockerized` is `true`: This configuration directs Chronos to retrieve metrics from the Docker daemon, aligning with services deployed within Docker containers for accurate monitoring.
146+
148147

149-
### Chronos Tracker for "Microservices" Mode
150-
The mode `microservices` uses the additional setting `dockerized`, which indicates whether or not the microservice has been containerized with Docker. If omitted, Chronos will assume this server is not running in a container, i.e. `dockerized` will default to _false_.
151148

152-
Setting the flag to `false` will collect metrics from the host computer directly, while `true` indicates for Chronos to pull metrics from the Docker daemon.
153149

154150
```js
155151
// Excerpt from a chronos-config.js
@@ -173,7 +169,7 @@ const chronos = new Chronos(chronosConfig);
173169
chronos.track()
174170
```
175171

176-
If you are using an Express.js REST API, calling `Chronos.track()` returns middleware that allows users to track incoming network requests and outgoing their corresponding outgoing responses by marking them with unique IDs using `Chronos.propagate`.
172+
If you are using an Express.js REST API, calling `Chronos.track()` returns middleware that allows users to track incoming network requests and their corresponding outgoing responses by marking them with unique IDs using `Chronos.propagate`.
177173

178174
If you want to utilize this feature, setup a catchall route that will serve as a pass through for tracking and chain in the middleware from `Chronos.track`.
179175

@@ -212,8 +208,11 @@ volumes:
212208
- "/var/run/docker.sock:/var/run/docker.sock"
213209
```
214210

215-
### Chronos Tracker for "Kubernetes" Mode
216-
Chronos can monitor an Kubernetes clusters by saving metric data from instant queries to a Prometheus server in your Kubernetes cluster, and then display all metrics data through Grafana dashboards.
211+
Check out the [**Microservices Readme**](../examples_new/README.md).
212+
#
213+
214+
### B. Chronos Tracker for "Kubernetes" Mode
215+
Chronos monitors Kubernetes clusters in two steps. First, it saves metric data from instant queries to a Prometheus server in your Kubernetes cluster. Then, it displays all metrics data through Grafana dashboards.
217216

218217
In `chronos-config.js`, set the `mode` to `kubernetes` and pass it both the name of the port the Prometheus server is listening on INSIDE the cluster, and the name of the Prometheus service so that its IP address can be resolved using KubeDNS.
219218

@@ -245,9 +244,10 @@ const chronos = new Chronos(chronosConfig);
245244

246245
chronos.kubernetes();
247246
```
247+
Check out the [**Kubernetes Readme**](../examples/kubernetes/README.md).
248+
#
248249

249-
250-
### Chronos Tracker for "Kafka" Mode
250+
### C. Chronos Tracker for "Kafka" Mode
251251
Chronos can monitor an Apache Kafka cluster via JMX to Prometheus Exporter. In order for this feature to work you must be running [JMX to Prometheus
252252
Exporter](https://github.com/prometheus/jmx_exporter) either as a Java Agent with your cluster or as a standalone HTTP server. Then, use `chronos-config.js` to specifiy where to retrieve the metrics.
253253

@@ -280,7 +280,7 @@ When viewing your information in the Chronos Electron application the data will
280280
**NOTE:** We provide a jmx_config.yaml file in the Chronos root folder for use with JMX prometheus that provides some useful baseline metrics to monitor.
281281

282282
#
283-
### Chronos Tracker for "Docker" Mode
283+
### D. Chronos Tracker for "Docker" Mode
284284
Chronos monitors Docker containers by storing metric data through instant Prometheus queries within your Docker container environment.
285285

286286
In `chronos-config.js`, configure the `mode` parameter to `docker`. Additionally, provide the name of the port where the Prometheus server is actively listening inside the container, and specify the name of the Prometheus service to enable DNS-based resolution of its IP address.
@@ -313,8 +313,8 @@ const chronos = new Chronos(chronosConfig);
313313

314314
chronos.docker();
315315
```
316-
317-
316+
Check out the [**Docker Readme**](../examples/docker/README.md).
317+
#
318318
### Chronos Tracker for gRPC
319319

320320
To monitor your gRPC server, setup `chronos-config.js` as if it was a standard microservices example, but be sure to set the `connection` type to `gRPC`.
@@ -432,17 +432,18 @@ Finally, on all servers that will be involved in the request path, invoke `chron
432432
```js
433433
chronos.link(client, ServerWrapper);
434434
```
435+
Check out the [**gRPC README**](../examples/gRPC/README.md).
435436

436437
#
437438

438439
### Viewing Chronos Data
439440
Once you have configured and intialized Chronos Tracker, it will automatically record monitoring data when your servers are running. The data will be saved into your database of choice, and then start the Chronos desktop app to view by cloning our [GitHub repo](https://github.com/open-source-labs/Chronos). Folow the ReadMe in that repo to setup the Chronos desktop app.
440441

441-
442+
#
442443
## Examples
443444

444445
We provide working example microservice applications in Chronos desktop app repo in the [**examples**](../chronos_npm_package/README.md) folder.
445-
446+
#
446447
## Technologies
447448
- Electron
448449
- JavaScript
@@ -458,16 +459,16 @@ We provide working example microservice applications in Chronos desktop app repo
458459
- Docker
459460
- Kubernetes
460461

461-
462+
#
462463
## Contributing
463464

464465
Chronos hopes to inspire an active community of both users and developers. For questions, comments, or contributions, please submit a pull request.
465466

466467
Read our [contributing README](../../CONTRIBUTING.md) to further learn how you can take part in improving Chronos.
467468

468-
469+
#
469470
## License
470471

471472
[MIT](https://github.com/oslabs-beta/Chronos/blob/master/LICENSE.md)
472473
#
473-
###### Return to [Top](#chronos)
474+
###### Return to [Top](#whats-new)

0 commit comments

Comments
 (0)