Skip to content

Commit 578a2aa

Browse files
committed
make a if statement for docker
1 parent 884ff3f commit 578a2aa

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

chronos_npm_package/controllers/mongo.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -234,24 +234,28 @@ mongo.setQueryOnInterval = async config => {
234234
///////
235235
length = await mongo.addMetrics(parsedArray, config.mode, currentMetricNames, model);
236236
}
237-
const documents = [];
238-
for (const metric of parsedArray) {
239-
/**
240-
* This will check if the current metric in the parsed array
241-
* evaluates to true within the currentMetricNames object
242-
* which is updated by the user when they select/deselect metrics on the electron app
243-
* helping to avoid overloading the db with unnecessary data.
244-
*/
245-
246-
if (currentMetricNames[metric.metric]) documents.push(model(metric));
247-
}
248-
await model.insertMany(parsedArray, err => {
249-
if (err) {
250-
console.error(err)
251-
} else {
252-
console.log(`${config.mode} metrics recorded in MongoDB`)
237+
238+
if (config.mode === 'docker') {
239+
const documents = [];
240+
for (const metric of parsedArray) {
241+
/**
242+
* This will check if the current metric in the parsed array
243+
* evaluates to true within the currentMetricNames object
244+
* which is updated by the user when they select/deselect metrics on the electron app
245+
* helping to avoid overloading the db with unnecessary data.
246+
*/
247+
248+
if (currentMetricNames[metric.metric]) documents.push(model(metric));
253249
}
254-
});
250+
await model.insertMany(parsedArray, err => {
251+
if (err) {
252+
console.error(err)
253+
} else {
254+
console.log(`${config.mode} metrics recorded in MongoDB`)
255+
}
256+
});
257+
}
258+
255259

256260
let allMetrics = await model.find({});
257261
console.log('allMetrics.length: ', allMetrics.length);
@@ -263,7 +267,7 @@ mongo.setQueryOnInterval = async config => {
263267
// console.log(`${config.mode} metrics recorded in MongoDB`)
264268
// })
265269
.catch(err => console.log(`Error inserting ${config.mode} documents in MongoDB: `, err));
266-
}, config.interval);
270+
}, 40000);
267271
};
268272

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

chronos_npm_package/server/output.csv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ size,path
22
"",Namespace: default
33
"",Namespace: default/Service: grafana/Pod: grafana-85d768d55b-jkr84
44
"",Namespace: default/Service: grafana
5-
"",Namespace: default/Service: frontend/Pod: nginx-frontend-55b44fbc7-9b8k8
6-
"",Namespace: default/Service: frontend/Pod: nginx-frontend-55b44fbc7-n2x6n
5+
"",Namespace: default/Service: frontend/Pod: nginx-frontend-55b44fbc7-25c27
6+
"",Namespace: default/Service: frontend/Pod: nginx-frontend-55b44fbc7-6dmj4
77
"",Namespace: default/Service: frontend
8-
"",Namespace: default/Service: backend/Pod: node-backend-d597768c-6zm5j
8+
"",Namespace: default/Service: backend/Pod: node-backend-d597768c-2rmjk
99
"",Namespace: default/Service: backend
10-
"",Namespace: default/Service: prometheus-service/Pod: prometheus-deployment-96898bbc9-2nlj2
10+
"",Namespace: default/Service: prometheus-service/Pod: prometheus-deployment-96898bbc9-jhh6q
1111
"",Namespace: default/Service: prometheus-service

0 commit comments

Comments
 (0)