You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chronos_npm_package/README.md
+73-72Lines changed: 73 additions & 72 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,84 +20,64 @@
20
20
## Using Chronos
21
21
The following steps should be performed in each microservice you want to track unless otherwise noted.
22
22
23
-
### Install Chronos Tracker
23
+
### 1. Install Chronos Tracker
24
24
Install the package as a dependency in each of the microservices you want to track:
25
25
26
26
```
27
27
npm install @chronosmicro/tracker
28
28
```
29
29
30
30
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.
33
33
34
34
```js
35
35
// A sample `chronos-config.js` file
36
+
//replace the values with your specific configuration
36
37
37
38
module.exports= {
38
39
// 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.
41
42
42
43
// Database Information
43
44
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
47
48
},
48
49
49
-
/* USE ONE OF THE MODE-SPECIFIC CONFIGURATIONS BELOW */
50
-
// (a) Microservices
50
+
/* USE ONLY ONE OF THE CONFIGURATIONS BELOW:*/
51
+
// (a) Microservices Mode
51
52
mode:'microservices',
52
-
dockerized:false, //false or true
53
+
dockerized:false, //set to true if your service is Dockerized
_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
-
- <imgsrc="../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
101
81
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.
102
82
103
83
Chronos only supports **Slack** and **email** notifications at this time.
@@ -124,32 +104,48 @@ notifications: [
124
104
{
125
105
type:'email',
126
106
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
132
112
}
133
113
}
134
114
]
135
-
// ...
136
115
```
137
116
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
144
117
145
118
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:
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
+
148
147
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_.
151
148
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.
153
149
154
150
```js
155
151
// Excerpt from a chronos-config.js
@@ -173,7 +169,7 @@ const chronos = new Chronos(chronosConfig);
173
169
chronos.track()
174
170
```
175
171
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`.
177
173
178
174
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`.
179
175
@@ -212,8 +208,11 @@ volumes:
212
208
- "/var/run/docker.sock:/var/run/docker.sock"
213
209
```
214
210
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.
217
216
218
217
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.
219
218
@@ -245,9 +244,10 @@ const chronos = new Chronos(chronosConfig);
245
244
246
245
chronos.kubernetes();
247
246
```
247
+
Check out the [**Kubernetes Readme**](../examples/kubernetes/README.md).
248
+
#
248
249
249
-
250
-
### Chronos Tracker for "Kafka" Mode
250
+
### C. Chronos Tracker for "Kafka" Mode
251
251
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
252
252
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.
253
253
@@ -280,7 +280,7 @@ When viewing your information in the Chronos Electron application the data will
280
280
**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.
281
281
282
282
#
283
-
### Chronos Tracker for "Docker" Mode
283
+
### D. Chronos Tracker for "Docker" Mode
284
284
Chronos monitors Docker containers by storing metric data through instant Prometheus queries within your Docker container environment.
285
285
286
286
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);
313
313
314
314
chronos.docker();
315
315
```
316
-
317
-
316
+
Check out the [**Docker Readme**](../examples/docker/README.md).
317
+
#
318
318
### Chronos Tracker for gRPC
319
319
320
320
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
432
432
```js
433
433
chronos.link(client, ServerWrapper);
434
434
```
435
+
Check out the [**gRPC README**](../examples/gRPC/README.md).
435
436
436
437
#
437
438
438
439
### Viewing Chronos Data
439
440
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.
440
441
441
-
442
+
#
442
443
## Examples
443
444
444
445
We provide working example microservice applications in Chronos desktop app repo in the [**examples**](../chronos_npm_package/README.md) folder.
445
-
446
+
#
446
447
## Technologies
447
448
- Electron
448
449
- JavaScript
@@ -458,16 +459,16 @@ We provide working example microservice applications in Chronos desktop app repo
458
459
- Docker
459
460
- Kubernetes
460
461
461
-
462
+
#
462
463
## Contributing
463
464
464
465
Chronos hopes to inspire an active community of both users and developers. For questions, comments, or contributions, please submit a pull request.
465
466
466
467
Read our [contributing README](../../CONTRIBUTING.md) to further learn how you can take part in improving Chronos.
0 commit comments