Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
334 changes: 243 additions & 91 deletions plugins/eginnovations/v1/data_streams.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion plugins/eginnovations/v1/handlerConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { getLiveMeasure } from './readDataSource/getLiveMeasure.js';
import { getMeasureForTest } from './readDataSource/getMeasureForTest.js';
import { getTestForType } from './readDataSource/getTestForType.js';
import { getUserComponentsForType } from './readDataSource/getUserComponentsForType.js';
import { getDescriptorForComponentTestLive } from './readDataSource/getDescriptorForComponentTestLive.js';
import { getDescriptorForComponentTestHistorical } from './readDataSource/getDescriptorForComponentTestHistorical.js';

// ============================================================================

Expand Down Expand Up @@ -165,5 +167,7 @@ export const dataSourceFns = {
getComponentsByType,
getUserComponentsForType,
getTestForType,
getMeasureForTest
getMeasureForTest,
getDescriptorForComponentTestLive,
getDescriptorForComponentTestHistorical
};
13 changes: 12 additions & 1 deletion plugins/eginnovations/v1/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eGInnovations",
"displayName": "eG Enterprise",
"version": "1.1.6",
"version": "1.1.9",
"author": "eG Innovations Pvt Ltd",
"description": "Monitor key application metrics from your eG environment",
"category": "APM",
Expand Down Expand Up @@ -72,6 +72,17 @@
"connector": "nodejs",
"version": "2.0.0",
"config": { "scriptPath": "handler.js", "entryPoint": "readDataSource" }
},
"getDescriptorForComponentTestLive": {
"connector": "nodejs",
"version": "2.0.0",
"config": { "scriptPath": "handler.js", "entryPoint": "readDataSource" }
},
"getDescriptorForComponentTestHistorical": {
"connector": "nodejs",
"version": "2.0.0",
"config": { "scriptPath": "handler.js", "entryPoint": "readDataSource" }
}

}
}
2 changes: 1 addition & 1 deletion plugins/eginnovations/v1/readDataSource/alarmCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function getAlarmCount(context) {
const serverUrl = context.pluginConfig.serverUrl;
const url = `${serverUrl}/api/eg/analytics/getAlarmCount`;
context.log.info(url);

const agent = new https.Agent({
rejectUnauthorized: false
});
Expand Down
1 change: 1 addition & 0 deletions plugins/eginnovations/v1/readDataSource/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export async function getAlerts(context) {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}


// Check if response is JSON
const contentType = response.headers.get('content-type');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// import _ from 'lodash';
import https from 'https';
import fetch from 'node-fetch';

export async function getDescriptorForComponentTestHistorical(context) {
const serverUrl = context.pluginConfig.serverUrl;
const url = `${serverUrl}/api/eg/analytics/getDescriptorForComponentTest`;
context.log.info(url);
const agent = new https.Agent({
rejectUnauthorized: false
});

// Define the body of the request
const body = {
componentName: context.dataSourceConfig.componentName, //'172.16.8.112:7077',
componentType: context.dataSourceConfig.componentType,
test: context.dataSourceConfig.test,
from: 'squaredup',
dataMode:'historical'
};
context.log.info(JSON.stringify(context.dataSourceConfig));
const headers = {
'Content-Type': 'application/json',
user: context.pluginConfig.user,
pwd: Buffer.from(context.pluginConfig.pwd).toString('base64'),
managerurl: `${serverUrl}`,
accessID: context.pluginConfig.accessID
};

try {
// Await the fetch request
const response = await fetch(url, {
method: 'POST',
body: JSON.stringify(body),
headers: headers,
agent: agent
});

// Check if the response is OK
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

// Check if response is JSON
const contentType = response.headers.get('content-type');
if (!contentType || !contentType.includes('application/json')) {
throw new Error('Response is not JSON');
}

let data = await response.json();

return data;
} catch (error) {
// Catch and log any errors
context.log.error(`Error in getDescriptorForComponentTestHistorical: ${error.message}`);
throw new Error(`HTTP error! status: ${error.message}`);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// import _ from 'lodash';
import https from 'https';
import fetch from 'node-fetch';

export async function getDescriptorForComponentTestLive(context) {
const serverUrl = context.pluginConfig.serverUrl;
const url = `${serverUrl}/api/eg/analytics/getDescriptorForComponentTest`;
context.log.info(url);
const agent = new https.Agent({
rejectUnauthorized: false
});

// Define the body of the request
const body = {
componentName: context.dataSourceConfig.componentName, //'172.16.8.112:7077',
componentType: context.dataSourceConfig.componentType,
test: context.dataSourceConfig.test,
from: 'squaredup',
dataMode:'live'
};
context.log.info(JSON.stringify(context.dataSourceConfig));
const headers = {
'Content-Type': 'application/json',
user: context.pluginConfig.user,
pwd: Buffer.from(context.pluginConfig.pwd).toString('base64'),
managerurl: `${serverUrl}`,
accessID: context.pluginConfig.accessID
};

try {
// Await the fetch request
const response = await fetch(url, {
method: 'POST',
body: JSON.stringify(body),
headers: headers,
agent: agent
});

// Check if the response is OK
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}

// Check if response is JSON
const contentType = response.headers.get('content-type');
if (!contentType || !contentType.includes('application/json')) {
throw new Error('Response is not JSON');
}

let data = await response.json();

return data;
} catch (error) {
// Catch and log any errors
context.log.error(`Error in getDescriptorForComponentTestLive: ${error.message}`);
throw new Error(`HTTP error! status: ${error.message}`);
}
}
31 changes: 22 additions & 9 deletions plugins/eginnovations/v1/readDataSource/getHistoricalData.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,38 @@ import fetch from 'node-fetch';

export async function getHistoricalData(context) {
const serverUrl = context.pluginConfig.serverUrl;
var info = '';
const url = `${serverUrl}/api/eg/analytics/getHistoricalData`;
context.log.info(url);
context.log.info(JSON.stringify(context.dataSourceConfig));

const agent = new https.Agent({
rejectUnauthorized: false
});


if (context.dataSourceConfig.descriptor != 'Not Applicable') {
if (Array.isArray(context.dataSourceConfig.descriptor)) {
info =
context.dataSourceConfig.descriptor.length > 0
? context.dataSourceConfig.descriptor.join(',') // or [0]
: '';
} else {
info = context.dataSourceConfig.descriptor;
}
} else {
info = '';
}

// Define the body of the request
const body = {
timeline: context.dataSourceConfig.timeline,//'1 hour',
componentName:context.dataSourceConfig.componentName, //'172.16.8.112:7077',
timeline: context.dataSourceConfig.timeline, //'1 hour',
componentName: context.dataSourceConfig.componentName, //'172.16.8.112:7077',
componentType: context.dataSourceConfig.componentType, //'eG Manager',
test: context.dataSourceConfig.test, //'Network',
measure: context.dataSourceConfig.measure,//'Packet Loss',
test: context.dataSourceConfig.test, //'HTTP',
info: info, //'HomePage',
measure: context.dataSourceConfig.measure, //'web availability',
from: 'squaredup'
};
context.log.info(JSON.stringify(body));

const headers = {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -52,9 +66,8 @@ export async function getHistoricalData(context) {
}

let data = await response.json();
const dynamicKey = Object.keys(data)[0];
context.log.info(dynamicKey);
return data[dynamicKey];

return data.data;
} catch (error) {
// Catch and log any errors
context.log.error(`Error in getHistoricalData: ${error.message}`);
Expand Down
11 changes: 10 additions & 1 deletion plugins/eginnovations/v1/readDataSource/getLiveMeasure.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,30 @@ import fetch from 'node-fetch';
export async function getLiveMeasure(context) {
const serverUrl = context.pluginConfig.serverUrl;
const url = `${serverUrl}/api/eg/analytics/getLiveMeasure`;
var info = '';
context.log.info(url);

const agent = new https.Agent({
rejectUnauthorized: false
});

if (context.dataSourceConfig.descriptor != 'All' && context.dataSourceConfig.descriptor != 'Not Applicable') {
info = context.dataSourceConfig.descriptor;
}else{
info = '';
}

// Define the body of the request
const body = {
componentName: context.dataSourceConfig.componentName, //'172.16.8.112:7077',
componentType: context.dataSourceConfig.componentType,
test: context.dataSourceConfig.test,
measure: context.dataSourceConfig.measure, //'eG Manager'
measure: context.dataSourceConfig.measure,
info: info, //'eG Manager'
from: 'squaredup'
};
context.log.info(JSON.stringify(context.dataSourceConfig));
context.log.info(JSON.stringify(body));
const headers = {
'Content-Type': 'application/json',
user: context.pluginConfig.user,
Expand Down
Loading