Skip to content

Commit 75bbaf1

Browse files
committed
edit readme
1 parent 128f96a commit 75bbaf1

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

assets/kubernetes-example2.png

1010 KB
Loading

chronos_npm_package/controllers/mongo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ mongo.setQueryOnInterval = async config => {
266266
// console.log(`${config.mode} metrics recorded in MongoDB`)
267267
// })
268268
.catch(err => console.log(`Error inserting ${config.mode} documents in MongoDB: `, err));
269-
}, 40000);
269+
}, config.interval);
270270
};
271271

272272
mongo.getSavedMetricsLength = async (mode, currentMetricNames) => {

examples/docker/README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,38 @@ Docker also ensures that the versions that worked well on dev are bundled up and
2323

2424
For additional details on how Chronos works this example, please review the Docker section in the [Chronos NPM Package README](../../chronos_npm_package/README.md).
2525

26-
## Steps to Run Example
2726

27+
28+
## Grafana API KEY
29+
30+
1. Run docker compose command below (LN 64) to start your Grafana container before you can access your service account token.
31+
32+
2. In your browser, go to `localhost:32000`, which will be the login page of grafana. Use `admin` as both username and password to login. You can change the password after login.
33+
34+
3. Navigate to `Home -> Administration -> Service accounts`, then click `Add service account` to create an service account. Be sure to choose `Admin` as the role. Then click `Add service account token`, hit `generate`, you are done! Remember this token, you will be using this token to access Grafana HTTP API programmatically.
35+
36+
## Steps to Run Example
2837
Peform the following steps in each of the _books_, _customers_, _frontend_, and _orders_ directories
2938

30-
1. Add a `.env` file to _each_ folder with the following key/value pairs:
39+
1. Add a `.env` file to each of _books_, _customers_, _frontend_, and _orders_ folders with the following key/value pairs:
3140

3241
- **NOTE**: Ensure that there are no quotes surrounding any of the keys and values.
3342

34-
> > > New collaboration group - testing all 5 url added to each .env// --> testing now...<<<
35-
3643
```
3744
CHRONOS_DB = MongoDB or PostgreSQL
3845
CHRONOS_URI = The URI to the desired MongoDB or PostgreSQL database to save health metrics via Chronos
3946
BOOK_URI = A MongoDB URI for the bookserver microservice to use
4047
CUSTOMER_URI = A MongoDB URI for the customerserver microservice to use
4148
ORDER_URI = A MongoDB URI for the orderserver microservice to use
49+
CHRONOS_GRAFANA_API_KEY = Bearer [the access token you created in above section (Grafana API Key)]
4250
```
4351

4452
2. Verify that `@chronosmicro/tracker` is a dependency in each of the _books_, _customers_, _frontend_, and _orders_ folders (see the `package.json` in each folder).
4553

46-
- If the @chronosmicro/tracker dependency is listed as a **remote** npm package (i.e. `"@chronosmicro/tracker": "^11.0.1"`) and you've ran `npm install`, no further work is needed continue to step 3.
54+
- If the @chronosmicro/tracker dependency is listed as a **remote** npm package (i.e. `"@chronosmicro/tracker": "^12.0.1"`) and you've ran `npm install`, no further work is needed continue to step 3. **However, confirm that the "@chronosmicro/tracker" you've installed from npm has the correct database names you will query later because the database automation will build from the npm installed version
4755

4856
- If you have the dependency as
49-
`"@chronosmicro/tracker": "file:./chronos_npm_package"`, which is a **local** file, make sure to change the version from `"file:./chronos_npm_package"` to `"^11.0.1"` and run npm install.
57+
`"@chronosmicro/tracker": "file:./chronos_npm_package"`, which is a **local** file, make sure to change the version from `"file:./chronos_npm_package"` to `"^12.0.1"` and run npm install.
5058

5159
3. With the terminal navigated to the the _examples/docker_ folder, run the command:
5260

@@ -56,9 +64,10 @@ ORDER_URI = A MongoDB URI for the orderserver microservice to use
5664
docker-compose -f docker-compose.yml up
5765
```
5866

59-
4. If you run into any issues regarding 'linux/amd64,linux/arm/v7,linux/arm64/v8' for cadvisor, navigate to the docker-compose.yml and find the cadvisor dictionary. Change "platform" to linux/arm64/v8 for M1 Chips and linux/amd64 for Intel Chips.
60-
61-
If you run into any issues regarding versions/images cadvisor, navigate to the docker-compose.yml and find the cadvisor dictionary. Change "image" to `image: gcr.io/cadvisor/cadvisor:latest` to `image: gcr.io/cadvisor/cadvisor:v0.47.0`
67+
4. If you run into any issues regarding `linux/amd64,linux/arm/v7,linux/arm64/v8` for cadvisor, navigate to the docker-compose.yml and find the cadvisor dictionary and try the below solutions.
68+
1. Change `platform` to `linux/arm64/v8` for M1 Chips and `linux/amd64` for Intel Chips.
69+
2. Change "image" to `image: gcr.io/cadvisor/cadvisor:latest` to `image: gcr.io/cadvisor/cadvisor:v0.47.0`
70+
3. Alternatively, use Docker Buildx to specify multi-platform.
6271

6372
###
6473

examples/kubernetes/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ docker build -t backend:1.0 .
7171

7272
2. run `npm start` to start npm server.
7373

74-
7574
## Deploy the Cluster
7675
1. `cd` into the launch folder and run the following commands to start the services and deployments described in the YAML files:
7776
```
@@ -86,6 +85,10 @@ kubectl apply -f frontend.yml
8685
<p align="center">
8786
<img alt="Kubernetes containers created" src="../../assets/examples_kubernetes_created.png">
8887
</p>
88+
<p align="center">
89+
<img alt="dashboards created" src="../../assets/kubernetes-example2.png">
90+
</p>
91+
(The second image is inside k8s_node-backend_node-backend-d597768c-6zm5j_default_46da04f8-99c6-4522-9141-6c05f8d5141d_0, it may take a while to show up in Docker desktop based on the scraping interval)
8992

9093

9194
Your microservice health metrics can now be viewed at the given `CHRONOS_URI` or, preferrably, in the Electron.js desktop application.
@@ -103,7 +106,7 @@ kubectl delete -f frontend.yml
103106

104107
**Mac Users:** Alternative to running the above commands, `cd` into the *scripts* folder and run the `stopKuber.sh` script
105108

106-
**Note**: The above part only teardown Prometheus and Kubernetes, it leaves Grafana running. This is because if you teardown Grafana, the next time you redeploy you will be login with a new account, the access token and dashboard you created within this account will lose.
109+
**Note**: The above part only teardown Prometheus and Kubernetes, it leaves Grafana running. This is because if you teardown Grafana, the next time you redeploy you will be login with a new account, the access token and dashboard you created within this account will be lost.
107110

108111
To teardown grafana, run the following commands:
109112
```

examples/kubernetes/server/chronos-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require('dotenv').config();
33
module.exports = {
44
// General configuration
55
microservice: 'kubernetesmetrics',
6-
interval: 25000,
6+
interval: 40000,
77

88
// Mode Specific
99
mode: 'kubernetes',

0 commit comments

Comments
 (0)