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
+221-3Lines changed: 221 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ The `database` property is required and takes in the following:
68
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
69
We reccommend using dotenv
70
70
71
-
Wherever you create an instance of your server (see example below),
71
+
You will also need to add the following two lines of code to your express server:,
72
72
73
73
```js
74
74
// Example for REST
@@ -77,7 +77,7 @@ const app = express();
77
77
78
78
```
79
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.
80
+
you will also need to require in `chronos-tracker-7` and initialize Chronos, as well as the `./chronos-config` file in addition to implementing `chronos.track()` for all endpoints.
81
81
82
82
```js
83
83
constchronos=require('chronos-tracker');
@@ -88,6 +88,224 @@ require('./chronos-config'); // Bring in config file
88
88
app.use('/', chronos.track());
89
89
```
90
90
91
-
You should be good to go! The last step, **Docker Configuration**, is**only applicable** if you need to configure <ahref="#"><imgsrc="./app/assets/docker-logo-color.png"alt="Docker"title="Docker"align="center"height="20" /></a> for your application.
91
+
You should be good to go! The steps below for **Docker Configuration** and **Kafka Configuration**, are**only applicable** if you need to configure <ahref="#"><imgsrc="./app/assets/docker-logo-color.png"alt="Docker"title="Docker"align="center"height="20" /></a> or Kafka for your application. See the **Notifications** section below for information on how to uses the notifications propery in `chronos-config.js`.
92
92
93
93
<br>
94
+
95
+
#### Initialize Chronos Tracker for gRPC
96
+
97
+
Wherever you create an instance of your server (see example below),
For any request you wish to trace, require uuidv4 and write the following code where the initial gRPC request begins,
163
+
```js
164
+
constrequire { v4:uuidv4} =require('uuid')
165
+
constcreateMeta= () => {
166
+
constmeta=newgrpc.Metadata();
167
+
meta.add('id', uuidvd());
168
+
return meta
169
+
}
170
+
```
171
+
and then, invoke createMeta as a third argument to any client method that is the beginning of the request path.
172
+
173
+
```js
174
+
orderClient.AddOrder(
175
+
order,
176
+
(err, data) => {
177
+
if (err !==null) {
178
+
console.log(err);
179
+
// could not add order because bookID does not exist
180
+
returnres.sendStatus(404);
181
+
}
182
+
console.log('addOrder response: ', data);
183
+
returnres.sendStatus(200);
184
+
},
185
+
createMeta()
186
+
);
187
+
188
+
```
189
+
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.
190
+
191
+
```js
192
+
chronos.link(client, ServerWrapper);
193
+
```
194
+
195
+
### Apache Monitoring (Via JMX to Prometheus Exporter)
196
+
197
+
Chronos now offers the ability to monitor an Apache Kafka cluster via JMX to Prometheus Exporter. In order for this feature to work you must be running [JMX to Prometheus
198
+
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 the port exposed for metrics scraping.
199
+
200
+
To start, add the property `jmxuri` to the object in `chronos-config.js`. Your file should look similar to this:
201
+
202
+
```js
203
+
// A sample `chronos-config.js` file
204
+
205
+
constchronos=require('chronos-tracker-7');
206
+
207
+
chronos.use({
208
+
microservice:'payments',
209
+
interval:5000,
210
+
dockerized:true,
211
+
jmxuri:// your URI here
212
+
database: {
213
+
connection:'REST',
214
+
type:'MongoDB',
215
+
URI:process.env.URI,
216
+
},
217
+
notifications: [],
218
+
});
219
+
```
220
+
The `jmxuri` property should be a string whose value is the port specified for scraping when starting the exporter.
221
+
222
+
Then, in ***ONE AND ONLY ONE** of your microservices, call
223
+
224
+
```js
225
+
226
+
chronos.kafka()
227
+
228
+
```
229
+
230
+
in your express server. When viewing your information in the Chronos Electron application the data will be available in the service "kafkametrics"
231
+
232
+
### Docker Configuration
233
+
234
+
Again, this step is **only applicable** if you are currently using <ahref="#"><imgsrc="./app/assets/docker-logo-color.png"alt="Docker"title="Docker"align="center"height="20" /></a> containers for your microservices.
235
+
236
+
<ahref="#"><imgsrc="./app/assets/important.png"alt="Important"title="Important"align="center"height="20" /></a> Give your containers the same names you pass in as arguments for microservice names.
237
+
238
+
<ahref="#"><imgsrc="./app/assets/important.png"alt="Important"title="Important"align="center"height="20" /></a> 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:
239
+
```
240
+
/var/run/docker.sock
241
+
```
242
+
243
+
For example, you can type the following when starting up a container:
244
+
```
245
+
docker run -v /var/run/docker.sock:/var/run/docker.sock [your-image-tag]
246
+
```
247
+
248
+
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:
249
+
250
+
```
251
+
volumes:
252
+
- "/var/run/docker.sock:/var/run/docker.sock"
253
+
```
254
+
255
+
## Notifications
256
+
257
+
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.
258
+
259
+
Chronos only supports **Slack** and **email** notifications.
260
+
<br>
261
+
262
+
### Slack
263
+
264
+
Chronos uses the <ahref="#"><imgsrc="./app/assets/slack-logo-color.png"alt="Slack"title="Slack"align="center"height="20" /></a> API to send messages to a Slack channel and only requires the **webhook url**. Learn how to set up [Slack webhooks](https://api.slack.com/messaging/webhooks) for your team.
265
+
266
+
An example of configured **slack** settings:
267
+
268
+
```js
269
+
// ...
270
+
notifications: [
271
+
{
272
+
type:'email',
273
+
settings: {
274
+
slackurl:process.env.WEBHOOK
275
+
}
276
+
}
277
+
]
278
+
// ...
279
+
```
280
+
281
+
### Email
282
+
Chronos provides the option to send <ahref="#"><imgsrc="./app/assets/email-icon-black.png"alt="Slack"title="Slack"align="center"height="20" /></a> emails. The properties that should be provided are the following
283
+
-`emails` - The recipient list (string) can be a single email address or multiple as comma seprated values.
284
+
-`emailHost` - The smtp host (string) of your email server
285
+
-`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/)
286
+
-`user` - The email address (string) of the sender
287
+
-`password` - The password (string) of the sender email
288
+
289
+
_NOTE: Email notification settings may require alternative security settings to work_
0 commit comments