{"_id":"@chronosmicro/tracker","_rev":"16-4c6670378fcc3463254a5812e485048b","name":"@chronosmicro/tracker","dist-tags":{"latest":"13.0.0"},"versions":{"8.0.3":{"name":"@chronosmicro/tracker","version":"8.0.3","keywords":[],"author":"","license":"ISC","_id":"@chronosmicro/tracker@8.0.3","maintainers":[{"name":"troyprejusa","email":"troyprejusa@gmail.com"}],"dist":{"shasum":"b10e83d978848859dd8df988df93f88f6b427a69","tarball":"https://registry.npmjs.org/@chronosmicro/tracker/-/tracker-8.0.3.tgz","fileCount":21,"integrity":"sha512-35+d+20RODVgAHuPW67fWUJj+poiPkoS6OMIA3rG2pZp+n5TLoLjUf8w5jGIsZ3Oey7c70VLz8j+WD4WTPLLVA==","signatures":[{"sig":"MEYCIQDT+jJCpucY04MKINTwjv8gGIjZZDVEPZ9///oDxDE7BwIhALNnvzSx47OVqZXQGILb5eLQPgbMHP76dNXUsgMdq7ML","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":75167,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjtlAlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpI0A//fC0M15uoI58kbzvPl8tbn4SIH/pV/YeFfiua2DMCTY7u+gZZ\r\nWf675gYH8UdyOY9yV+GG1oQd0nFSGJrW9ANZJtKQ5D92Dxiu4f+8F8NUOt5/\r\ngUNUT2vhAsws9x4F4jtDxVZbJyr9kboJB7OiyUWVV9K9TKn/ZZwHYxhII5N+\r\nrfxHALi7BVHqHHKZkS9aMd1npdV1BD35+i0gWfP6Fs3J0hvYiRurSrgHjiSU\r\nQ86DVxrsFYpUiZUaIbOW2FPWpRTh6EGSkoXn2wFskVOR+6WFzWq0/BE3Ked6\r\nricCcqZZE2NwTNVn5XJ6uYBfdauSEkukEuLWLZVmp+EtbHSUVUQ9o2u6ekUy\r\nsebywAqdASBl/Mc558qMLfK9PT/O06gTIaTRfsvBziCVR4lQRcnTSH5OHN/y\r\n038M5krEjFQLZ+qYsYWO+8zu0wwI7SSvO9ETNaR7CLPPs3sPYDF7kbMJgGUT\r\nu7KYq1uosTAxbRyctRju8zjahK/cO2BCl0gsuOrZ8vJzj3c+8J+8i1oZ4uoO\r\nsfKKYE77oFXAv7ErF42GRMMdRjY/GY1iAPA5KuexVWYbVIROfO1/RvN37eca\r\nThQ5NWWzOCW2gBPhvvR9d0ZIo0AkVPRAE/Lx1iN3CBEnA1oWuL/KRYT0ygoO\r\nkXM/oz2DrUh3p5TiTGplY4I3PrHqxX2OZLY=\r\n=vzK1\r\n-----END PGP SIGNATURE-----\r\n"},"main":"chronos.js","gitHead":"0c000730a91c968febd52a298c2698252ac070ce","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"troyprejusa","email":"troyprejusa@gmail.com"},"_npmVersion":"8.15.0","description":"Chronos microservice metrics tracker","directories":{},"_nodeVersion":"16.17.1","dependencies":{"pg":"^8.8.0","axios":"^1.2.1","mongoose":"^6.8.0","hpropagate":"1.0.1","nodemailer":"^6.8.0","@grpc/grpc-js":"^1.8.0","systeminformation":"^5.16.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tracker_8.0.3_1672892453042_0.6677645526641782","host":"s3://npm-registry-packages"}},"11.0.1":{"name":"@chronosmicro/tracker","version":"11.0.1","keywords":[],"author":"","license":"ISC","_id":"@chronosmicro/tracker@11.0.1","maintainers":[{"name":"chronosnyla","email":"chronosnyla@gmail.com"},{"name":"snowxb","email":"xueapp@gmail.com"},{"name":"troyprejusa","email":"troyprejusa@gmail.com"}],"dist":{"shasum":"90d454133730dc47b8e39cb7466a7f3a4802b03f","tarball":"https://registry.npmjs.org/@chronosmicro/tracker/-/tracker-11.0.1.tgz","fileCount":21,"integrity":"sha512-mBOLNywNPaFypoXwFXl0cQWdB7nfwL/riwzqXfkTBh4LsBVmmR5zHLUE7FZJ7EklXdeYtaioNN48eFf6+pV75w==","signatures":[{"sig":"MEQCIENjw7zdnZobx/BOYDDNQu20tPpHBEUzY7OnjSMof6koAiAtMtPVs/G/7T9gKvaA2y7mQckCJTAwSRnsV/xTrSmbnQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":75807},"main":"chronos.js","gitHead":"c8f68c854a2bdf6dd354fd025535a3ec88e56f75","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"chronosnyla","email":"chronosnyla@gmail.com"},"_npmVersion":"9.5.1","description":"Chronos microservice metrics tracker","directories":{},"_nodeVersion":"18.16.0","dependencies":{"pg":"^8.8.0","axios":"^1.2.1","mongoose":"^6.8.0","hpropagate":"1.0.1","nodemailer":"^6.8.0","@grpc/grpc-js":"^1.8.0","systeminformation":"^5.16.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tracker_11.0.1_1687368268923_0.02021854695154568","host":"s3://npm-registry-packages"}},"11.0.2":{"name":"@chronosmicro/tracker","version":"11.0.2","keywords":[],"author":"","license":"ISC","_id":"@chronosmicro/tracker@11.0.2","maintainers":[{"name":"chronosnyla","email":"chronosnyla@gmail.com"},{"name":"snowxb","email":"xueapp@gmail.com"},{"name":"troyprejusa","email":"troyprejusa@gmail.com"}],"dist":{"shasum":"a278edc5c88704e6ec87e59174a36a211e3a3f09","tarball":"https://registry.npmjs.org/@chronosmicro/tracker/-/tracker-11.0.2.tgz","fileCount":21,"integrity":"sha512-U+oH97HyVTSFwVud42MRlhkD3lmra0SgZeBDda33T6ZXsb5CSBF9Ql4RBdkqoCP75QlshK/z8pzfe9XjIQZ1YA==","signatures":[{"sig":"MEUCIA+a1NkoDtSDR+zKdrI9V1KvP0/tk1f9B+UtGd15PHQeAiEAh0E55iNVlp+MYfzQxxYtZiDgR5gjIf4ZZraTwI/gXuo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":74902},"main":"chronos.js","gitHead":"1aefd9b28bd3e7416e0f7a8be56b10fb8d9e6f94","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"chronosnyla","email":"chronosnyla@gmail.com"},"_npmVersion":"9.5.1","description":"Chronos microservice metrics tracker","directories":{},"_nodeVersion":"18.16.0","dependencies":{"pg":"^8.8.0","axios":"^1.2.1","mongoose":"^6.8.0","hpropagate":"1.0.1","nodemailer":"^6.8.0","@grpc/grpc-js":"^1.8.0","systeminformation":"^5.16.1"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tracker_11.0.2_1688574270315_0.7642831641376113","host":"s3://npm-registry-packages"}},"12.0.1":{"name":"@chronosmicro/tracker","version":"12.0.1","keywords":[],"author":"","license":"ISC","_id":"@chronosmicro/tracker@12.0.1","maintainers":[{"name":"chronosnyla","email":"chronosnyla@gmail.com"},{"name":"snowxb","email":"xueapp@gmail.com"},{"name":"troyprejusa","email":"troyprejusa@gmail.com"}],"dist":{"shasum":"9232e107c4f2dbe929fa4a06a52ec676e3d1114f","tarball":"https://registry.npmjs.org/@chronosmicro/tracker/-/tracker-12.0.1.tgz","fileCount":32,"integrity":"sha512-aNXYqaDg7Xb0rcq7DDGDqdopMWRXHR0qQWK7NyhNSgY0i6783ZAyxBITkzFQ/KM/wOI7PE7GIUCwJX7Yjweg9w==","signatures":[{"sig":"MEQCIGOPrOee2NQIouRZNnQdEe2kwEoeciDa8vQvVM6rbHZKAiBMpzFuIuon7/qVWKmm60Vf2EufLE2XXCp1N1pCVCDYrg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":159570},"main":"chronos.js","gitHead":"34f684459c30b01b34f2588812b925106dfad6c6","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"chronosnyla","email":"chronosnyla@gmail.com"},"_npmVersion":"9.6.7","description":"Chronos microservice metrics tracker","directories":{},"_nodeVersion":"18.17.1","dependencies":{"pg":"^8.8.0","axios":"^1.2.1","mongoose":"^6.11.5","hpropagate":"1.0.1","nodemailer":"^6.8.0","@grpc/grpc-js":"^1.8.0","systeminformation":"^5.16.1","set-interval-async":"^3.0.3"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tracker_12.0.1_1692650811993_0.7159115238136233","host":"s3://npm-registry-packages"}},"12.0.2":{"name":"@chronosmicro/tracker","version":"12.0.2","keywords":[],"author":"","license":"ISC","_id":"@chronosmicro/tracker@12.0.2","maintainers":[{"name":"chronosnyla","email":"chronosnyla@gmail.com"},{"name":"snowxb","email":"xueapp@gmail.com"},{"name":"troyprejusa","email":"troyprejusa@gmail.com"}],"dist":{"shasum":"736cf477dbfd75befd29802caf8d0825048a1f74","tarball":"https://registry.npmjs.org/@chronosmicro/tracker/-/tracker-12.0.2.tgz","fileCount":32,"integrity":"sha512-t7q7hrrIFUHvd2uBfcZkCXciqyRGl+vuIDSG9p7OXDQAIMAkY0xt1Mn86PEvmYVk/lCBQEDs41M3sOk6wiCbTA==","signatures":[{"sig":"MEQCIB3zJkQ4tDtpoAs1AnHXnBZZbMd+IR6rvbGM3E7A+e6DAiB/1XUp79NEiz2Z8t2tT55ZMHdlusMD3hilQGI6+/Hnyg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":160984},"main":"chronos.js","gitHead":"e455d85e692a9d4759e9d0e674ec392ef6160af5","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"chronosnyla","email":"chronosnyla@gmail.com"},"_npmVersion":"9.5.1","description":"Chronos microservice metrics tracker","directories":{},"_nodeVersion":"18.16.0","dependencies":{"pg":"^8.8.0","axios":"^1.2.1","mongoose":"^6.11.5","hpropagate":"1.0.1","nodemailer":"^6.8.0","@grpc/grpc-js":"^1.8.0","systeminformation":"^5.16.1","set-interval-async":"^3.0.3"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tracker_12.0.2_1692896481458_0.4324454541466429","host":"s3://npm-registry-packages"}},"12.0.3":{"name":"@chronosmicro/tracker","version":"12.0.3","keywords":[],"author":"","license":"ISC","_id":"@chronosmicro/tracker@12.0.3","maintainers":[{"name":"chronosnyla","email":"chronosnyla@gmail.com"},{"name":"snowxb","email":"xueapp@gmail.com"},{"name":"troyprejusa","email":"troyprejusa@gmail.com"}],"dist":{"shasum":"3e51f1d9ffc1d33205a1983470ad0692f71dfde1","tarball":"https://registry.npmjs.org/@chronosmicro/tracker/-/tracker-12.0.3.tgz","fileCount":32,"integrity":"sha512-fMOL5jWx7U2hQ5rlGyNTMLQt73NDBKFcMiHW0omaI/SpwO6MNyonig8cJuQ01xf2EZterq14p/3LT0bXUygSxg==","signatures":[{"sig":"MEYCIQDRB3WYaPsF+1l4h+a5RMUT2OigsUTViEyVHu2ThJL6uwIhANQqX2SN0dzZyIJASxPMl9RSiCl0SHv1OW+kBmm2cAC1","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":165718},"main":"chronos.js","gitHead":"4b92460088da22f4db51dc295c63887fb4bbfc11","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"chronosnyla","email":"chronosnyla@gmail.com"},"_npmVersion":"9.6.7","description":"Chronos microservice metrics tracker","directories":{},"_nodeVersion":"18.17.1","dependencies":{"pg":"^8.8.0","axios":"^1.2.1","mongoose":"^6.11.5","hpropagate":"1.0.1","nodemailer":"^6.8.0","@grpc/grpc-js":"^1.8.0","systeminformation":"^5.16.1","set-interval-async":"^3.0.3"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tracker_12.0.3_1704921571373_0.9288865170032583","host":"s3://npm-registry-packages"}},"12.0.4":{"name":"@chronosmicro/tracker","version":"12.0.4","keywords":[],"author":"","license":"ISC","_id":"@chronosmicro/tracker@12.0.4","maintainers":[{"name":"chronosnyla","email":"chronosnyla@gmail.com"},{"name":"snowxb","email":"xueapp@gmail.com"},{"name":"troyprejusa","email":"troyprejusa@gmail.com"}],"dist":{"shasum":"cd1606318acbe679f7bfb36ba667736d6990c88c","tarball":"https://registry.npmjs.org/@chronosmicro/tracker/-/tracker-12.0.4.tgz","fileCount":32,"integrity":"sha512-sd7kDCeT2UmCG6KN8TgE6ct08LU57Nft/pG/UVW6U+6b/cPQ4eAAi2qzjZZD4nYsvEiogQ/zesrZNOcTBi0KGg==","signatures":[{"sig":"MEUCIQDnewD9s+pHJNrJGaMpYN4aqObUAGLsYXuEPu1HQTyiUQIgGt8OfseBvH14iyOb07qTehC6lwbXh0RCoavbKmtApnc=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":165424},"main":"chronos.js","gitHead":"086430982a867ec64af0795a413923d4c0e3604c","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"chronosnyla","email":"chronosnyla@gmail.com"},"_npmVersion":"9.6.7","description":"Chronos microservice metrics tracker","directories":{},"_nodeVersion":"18.17.1","dependencies":{"pg":"^8.8.0","axios":"^1.2.1","mongoose":"^6.11.5","hpropagate":"1.0.1","nodemailer":"^6.8.0","@grpc/grpc-js":"^1.8.0","systeminformation":"^5.16.1","set-interval-async":"^3.0.3"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tracker_12.0.4_1704922990316_0.055880789281670395","host":"s3://npm-registry-packages"}},"13.0.0":{"name":"@chronosmicro/tracker","version":"13.0.0","description":"Chronos microservice metrics tracker","main":"dist/chronos.js","type":"module","scripts":{"start":"ts-node-dev ./src/index.ts","dev":"ts-node-dev ./src/index.ts","auth":"ts-node-dev ./src/auth.ts","client":"ts-node-dev ./src/server.ts","build":"tsc","test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"","license":"ISC","dependencies":{"@grpc/grpc-js":"^1.8.0","axios":"^1.2.1","hpropagate":"1.0.1","mongoose":"^6.11.5","nodemailer":"^6.8.0","pg":"^8.8.0","set-interval-async":"^3.0.3","systeminformation":"^5.16.1"},"gitHead":"89b516ba289ce3f2de9984db804c5a5ea9465081","_id":"@chronosmicro/tracker@13.0.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-trvk7utids1vBCTbcfaMtRjxaeDsm8g7LhJ4glm4Sso7rve4L7J10DrlU1UrdN+tPqkltzbxWgLxXtbdNMPHDQ==","shasum":"858a639df1f8e503e94b6d89778fec246197a459","tarball":"https://registry.npmjs.org/@chronosmicro/tracker/-/tracker-13.0.0.tgz","fileCount":137,"unpackedSize":1441146,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBanaO81fncuDWYmleWssOl1d0NMTWGZ1zmYCemEFS6WAiBNf1T6hu7HY4o/TBrWlu8M5qnP/IsTfJnv/oLgwEvblg=="}]},"_npmUser":{"name":"chronosnyla","email":"chronosnyla@gmail.com"},"directories":{},"maintainers":[{"name":"troyprejusa","email":"troyprejusa@gmail.com"},{"name":"chronosnyla","email":"chronosnyla@gmail.com"},{"name":"snowxb","email":"xueapp@gmail.com"},{"name":"ashleybisram","email":"ashleydevibisram@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tracker_13.0.0_1739544958236_0.5767221015696491"},"_hasShrinkwrap":false}},"time":{"created":"2023-01-05T04:20:52.976Z","modified":"2025-02-14T14:55:58.868Z","8.0.1":"2023-01-04T17:52:45.058Z","8.0.2":"2023-01-04T21:45:05.440Z","8.0.3":"2023-01-05T04:20:53.186Z","11.0.1":"2023-06-21T17:24:29.129Z","11.0.2":"2023-07-05T16:24:30.481Z","12.0.1":"2023-08-21T20:46:52.251Z","12.0.2":"2023-08-24T17:01:21.764Z","12.0.3":"2024-01-10T21:19:31.516Z","12.0.4":"2024-01-10T21:43:10.532Z","13.0.0":"2025-02-14T14:55:58.548Z"},"license":"ISC","keywords":[],"description":"Chronos microservice metrics tracker","maintainers":[{"name":"troyprejusa","email":"troyprejusa@gmail.com"},{"name":"chronosnyla","email":"chronosnyla@gmail.com"},{"name":"snowxb","email":"xueapp@gmail.com"},{"name":"ashleybisram","email":"ashleydevibisram@gmail.com"}],"readme":"## What's New?\n\n- Enhanced Metrics Collection: Docker now supports Prometheus metrics scraping, offering improved monitoring capabilities\n- Streamlined Visualization: Docker and Kubernetes integrate with Grafana to provide dynamic visualization of collected metrics\n- Kubernetes graph type customization and resource data processing\n- Bug Fixes\n- Refactored code for additional modularity and customization\n\n#\n\n## Features\n\n- Distributed tracing enabled across microservice applications\n- Supports PostgreSQL and MongoDB databases\n- Displays real-time temperature, speed, latency, and memory statistics\n- Display and compare multiple microservice metrics in a single graph\n- Monitor an Apache Kafka cluster via the JMX Prometheus Exporter\n- Monitor Docker and Kubernetes clusters via a Prometheus monitoring server and display charts using Grafana\n\n#\n\n## Using Chronos\n\nThe following steps should be performed in each microservice you want to track unless otherwise noted.\n\n### 1. Install Chronos Tracker\n\nInstall the package as a dependency in each of the microservices you want to track:\n\n```\nnpm install @chronosmicro/tracker\n```\n\n### 2. Configuring Chronos Tracker\n\nCreate 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.\n\n```js\n// A sample `chronos-config.js` file\n//replace the values with your specific configuration\n\nmodule.exports = {\n  // General Configuration\n  microservice: 'my-service', //Name of your microservice. For **Dockerized** microservices, this field **must** match the container_name of the corresponding Docker container.\n  interval: 10000, //monitoring interval in milliseconds, if ommitted, Chronos will default to recording server health every 60000 ms.\n\n  // Database Information\n  database: {\n    connection: 'REST', // Choose 'REST' or 'gRPC' for your connection type\n    type: 'MongoDB', // Choose 'MongoDB' or 'PostgreSQL'\n    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\n  },\n\n  /*  USE ONLY ONE OF THE CONFIGURATIONS BELOW:   */\n  // (a) Microservices Mode\n  mode: 'microservices',\n  dockerized: false, // set to true if your service is Dockerized\n\n  // (b) Kubernetes\n  mode: 'kubernetes',\n  promService: 'prometheus-service', // Prometheus service name\n  promPort: 8080, //Prometheus service port\n  grafanaAPIKey: process.env.CHRONOS_GRAFANA_API_KEY, //API for Grafana\n\n  // (c) Apache Kafka\n  mode: 'kafka',\n  jmxuri: '<insert URI>', //URI for JMX to Prometheus Exporter\n\n  // (d) Docker\n  mode: 'docker',\n  promService: 'docker.for.mac.localhost', //Prometheus service for Docker\n  promPort: 9090, //Prometheus service port\n  grafanaAPIKey: process.env.CHRONOS_GRAFANA_API_KEY, //API key for Grafana\n\n  // Notifications\n  //Add notification configurations here\n  notifications: [],\n};\n```\n\nNote: Consider using a `.env` file to securely store sensitive parameters like database URIs.\n\n### 3. Configuring notifications\n\nThe `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.\n\nChronos only supports **Slack** and **email** notifications at this time.\n\n**Slack**\n\n```js\n// ...\nnotifications: [\n  {\n    type: 'slack',\n    settings: {\n      slackurl: process.env.WEBHOOK,\n    },\n  },\n];\n// ...\n```\n\nChronos uses the Slack 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.\n\n**Email**\n\n```js\n// ...\nnotifications: [\n  {\n    type: 'email',\n    settings: {\n      emails: 'foobar@email.com, bizbaz@email.edu', //can be single or multiple, separated by a comma\n      emailHost: 'smpt@gmail.com', // the smtp host of your email server\n      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/)\n      user: process.env.SENDER_EMAIL, //email address of the sender\n      password: process.env.SENDER_PASSWORD, //password of the sender's email\n    },\n  },\n];\n```\n\n### 4. Utilize `chronos-config.js` in your application\n\nTo integrate the `chronos-config.js` file into your application, follow these steps:\n\n1. importing the `chronos-config.js` file\n\n```js\nconst chronosConfig = require('./chronos-config.js');\n```\n\n2. importing the Chronos class\n\n```js\nconst Chronos = require('@chronosmicro/tracker');\n```\n\n3. creating a new instance of the Chronos class\n\n```js\nconst chronos = new Chronos(chronosConfig);\n```\n\n#\n\n### Mode Specific Configurations\n\n### A. Chronos Tracker for \"Microservices\" Mode\n\nIn the `microservices` mode, Chronos employs the `dockerized` setting to determine the operational environment of the microservice.\n\n- `dockerized`: This setting is crucial for specifying the nature of the service deployment.\n  - 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.\n  - 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.\n  - 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.\n\n```js\n// Excerpt from a chronos-config.js\n\nmodule.exports = {\n  // ...\n\n  mode: 'microservices',\n  dockerized: false, // false or true\n\n  // ...\n};\n```\n\nOnce your `chronos-config.js` file is setup, use Chronos in your microservice by importing the config, creating a new instance of the class, and calling the `Chronos.track` method to start saving health metrics:\n\n```js\nconst chronosConfig = require('./chronos-config.js');\nconst Chronos = require('@chronosmicro/tracker');\nconst chronos = new Chronos(chronosConfig);\nchronos.track();\n```\n\nIf 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`.\n\nIf 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`.\n\n```js\nconst chronosConfig = require('./chronos-config.js');\nconst Chronos = require('@chronosmicro/tracker');\nconst chronos = new Chronos(chronosConfig);\n\n// THIS MUST HAPPEN BEFORE CALLING express()!\nchronos.propagate();\n\nconst app = express();\n\nconst trackingMiddleware = chronos.track();\n// Pass all requests through this middleware, which always calls next() to allow all requests to continue on to match other routes\napp.use('/', trackingMiddleware);\n```\n\n#### Special Notes on Dockerized Microservices\n\n**IMPORTANT:** Give your containers the same names you pass in as arguments for microservice names.\n\nIn order to have container statistics saved to your database along with other health info, bind volumes to this path when starting up the containers:\n\n```\n/var/run/docker.sock\n```\n\nFor example, you can type the following when starting up a container:\n\n```\ndocker run -v /var/run/docker.sock:/var/run/docker.sock [your-image-tag]\n```\n\nIf 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:\n\n```\nvolumes:\n  - \"/var/run/docker.sock:/var/run/docker.sock\"\n```\n\n#\n\n### B. Chronos Tracker for \"Kubernetes\" Mode\n\nChronos 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.\n\nIn `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.\n\nAlso add a `grafanaAPIKey` section, this API key will grant chronos access to create and update dashboards in Grafana. Be sure to include `CHRONOS_GRAFANA_API_KEY` in your `.env` with `Bearer [the access token you get from Grafana]`. For more details, please check Kubernetes example.\n\n```js\n// Excerpt from a chronos-config.js\n\nmodule.exports = {\n  // ...\n\n  mode: 'kubernetes',\n  promService: 'prometheus-service',\n  promPort: 8080,\n\n  grafanaAPIKey: process.env.CHRONOS_GRAFANA_API_KEY,\n\n  // ...\n};\n```\n\nThen, insert the code below into a **SINGLE** microservice that will be deployed only as a **SINGLE** pod (to avoid saving the same metrics as queried by multiple pods), call `Chronos.kuberbetes`:\n\n```js\nconst chronosConfig = require('./chronos-config.js');\nconst Chronos = require('@chronosmicro/tracker');\nconst chronos = new Chronos(chronosConfig);\n\nchronos.kubernetes();\n```\n\n#\n\n### C. Chronos Tracker for \"Kafka\" Mode\n\nChronos 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\nExporter](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.\n\nTo start, set the `mode` to `kafka` and add the property `jmxuri` to the object in `chronos-config.js`. The `jmxuri` property should be a string whose value is the URL and port specified for scraping when starting the exporter.\n\n```js\n// Excerpt from a chronos-config.js\n\nmodule.exports = {\n  // ...\n\n  mode: 'kafka',\n  jmxuri: 'http://localhost:12345/metrics',\n\n  // ...\n};\n```\n\nThen, in **ONE AND ONLY ONE** of your microservices, call `Chronos.kafka`:\n\n```js\nconst chronosConfig = require('./chronos-config.js');\nconst Chronos = require('@chronosmicro/tracker');\nconst chronos = new Chronos(chronosConfig);\n\nchronos.kafka();\n```\n\nWhen viewing your information in the Chronos Electron application the data will be available in the service \"kafkametrics\"\n\n**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.\n\n#\n\n### D. Chronos Tracker for \"Docker\" Mode\n\nChronos monitors Docker containers by storing metric data through instant Prometheus queries within your Docker container environment.\n\nIn `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.\n\nAlso add a `grafanaAPIKey` section, this API key will authorize Chronos for dashboard creation and updates in Grafana.\n\n```js\n// Excerpt from a chronos-config.js\n\nmodule.exports = {\n  // ...\n\n  mode: 'docker',\n  promService: 'docker.for.mac.localhost',\n  promPort: 8080,\n\n  grafanaAPIKey: process.env.CHRONOS_GRAFANA_API_KEY,\n\n  // ...\n};\n```\n\nThen, implement the subsequent code snippet within a **SINGLE** microservice that will be deployed only as a **SINGLE** container, and call `Chronos.docker`:\n\n```js\nconst chronosConfig = require('./chronos-config.js');\nconst Chronos = require('@chronosmicro/tracker');\nconst chronos = new Chronos(chronosConfig);\n\nchronos.docker();\n```\n\n#\n\n### Chronos Tracker for gRPC\n\nTo 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`.\n\n```js\nmodule.exports = {\n  microservice: 'my-service',\n  interval: 10000,\n\n  // Database Information\n  database: {\n    connection: 'gRPC', // 'REST' or 'gRPC'\n    type: 'MongoDB', // 'MongoDB' or 'PostgreSQL'\n    URI: '<insert URI>', // <insert URI>\n  },\n\n  mode: 'microservices',\n  dockerized: false, // false or true\n\n  // ...\n};\n```\n\nThen require in the `chronos-config.js` and `Chronos` and call `Chronos.track` to start tracking health metrics.\n\n```js\n// Example of gRPC server\nconst chronosConfig = require('./chronos-config.js');\nconst Chronos = require('@chronosmicro/tracker');\n\nconst chronos = new Chronos(chronosConfig);\nchronos.track();\n\nconst server = new grpc.Server();\n\nserver.bindAsync('127.0.0.1:30044', grpc.ServerCredentials.createInsecure(), () => {\n  server.start();\n  console.log('Server running at http://127.0.0.1:30044');\n});\n```\n\nTo trace requests, first wrap the gRPC client using Chronos:\n\n```js\nconst grpc = require('@grpc/grpc-js');\nconst protoLoader = require('@grpc/proto-loader');\n\nconst PROTO_PATH = './order.proto';\n\nconst packageDefinition = protoLoader.loadSync(PROTO_PATH, {\n  keepCase: true,\n  longs: String,\n  enums: String,\n  arrays: true,\n});\nconst OrderToBookService = grpc.loadPackageDefinition(packageDefinition).OrderToBook;\nconst bookClient = new OrderToBookService('localhost:30044', grpc.credentials.createInsecure());\n\nconst ClientWrapper = chronos.ClientWrapper(bookClient, OrderToBookService);\n```\n\nNext wrap the gRPC server using Chronos\n\n```js\nconst ServerWrapper = chronos.ServerWrapper(server, Proto.protoname.service, {\n  AddBook: (call, callback) => {\n    // console.log(call.metadata)\n    // get the properties from the gRPC client call\n    const { title, author, numberOfPages, publisher, bookID } = call.request;\n    // create a book in our book collection\n    BookModel.create({\n      title,\n      author,\n      numberOfPages,\n      publisher,\n      bookID,\n    });\n    callback(null, {});\n  },\n});\n```\n\nFor any request you wish to trace, require uuidv4 and write the following code where the initial gRPC request begins,\n\n```js\nconst require { v4: uuidv4} = require('uuid')\nconst createMeta = () => {\n  const meta = new grpc.Metadata();\n  meta.add('id', uuidvd());\n  return meta\n}\n```\n\nand then, invoke createMeta as a third argument to any client method that is the beginning of the request path.\n\n```js\norderClient.AddOrder(\n  order,\n  (err, data) => {\n    if (err !== null) {\n      console.log(err);\n      // could not add order because bookID does not exist\n      return res.sendStatus(404);\n    }\n    console.log('addOrder response: ', data);\n    return res.sendStatus(200);\n  },\n  createMeta()\n);\n```\n\nFinally, on all servers that will be involved in the request path, invoke `chronos.link` with parameters of `client` and `ServerWrapper` in the server wrapper.\n\n```js\nchronos.link(client, ServerWrapper);\n```\n\n#\n\n### Viewing Chronos Data\n\nOnce 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.\n\n#\n\n## Examples\n\nWe provide working example microservice applications in Chronos desktop app repo in the [**examples**](../chronos_npm_package/README.md) folder.\n\n#\n\n## Technologies\n\n- Electron\n- JavaScript\n- TypeScript\n- PostgreSQL\n- MongoDB\n- Node\n- Express\n- HTTP\n- gRPC\n- Docker\n- Apache Kafka\n- Docker\n- Kubernetes\n\n#\n\n## Contributing\n\nChronos hopes to inspire an active community of both users and developers. For questions, comments, or contributions, please submit a pull request.\n\nRead our [contributing README](../../CONTRIBUTING.md) to further learn how you can take part in improving Chronos.\n\n#\n\n## License\n\n[MIT](https://github.com/oslabs-beta/Chronos/blob/master/LICENSE.md)\n\n#\n\n###### Return to [Top](#whats-new)\n","readmeFilename":"README.md"}