Retrieving Data by Executing Custom Query

Using the eG REST API, administrators can retrieve data from the eG backend database by executing a custom query in the target environment.

Note:

  • By default, this REST API can be executed only by a user with admin privileges.

  • Only the select * query can be executed using the eG REST API.

The table below specifies the URL and the parameters that should be used to retrieve the measures of the tests.

URL: http://<eG manager IP:port>/api/eg/analytics/getCustomQuery

Method: POST

Content-Type: application/json

Inputs to be Specified
Parameters Key values Example

Headers

managerurl: Base URL of the eG Manager i.e., http://<IP address of the eG console:Port>

user: eG username or domain/eG username

pwd: Base64 encoded password

{

"query": "select * from measure_last"

}

Body

Default:

{

"query": "select * from <table name>"

}

 

Success Response
Type Code Content

JSON

200

[

"TEST_NAME TRGT_HOST PORT_NO SITE_NAME INFO MSMT_HOST MSMT_TIME ",

"AppEvtLogTest || EGDP156 || 7077 || NULL || +all || EGDP156 || 2023-01-19 13:27:51.0",

"AppEvtLogTest || EGDP156 || 8080 || NULL || +all || EGDP156 || 2023-01-19 13:27:50.0",

"AppEvtLogTest || tomcat_1 || 8080 || NULL || +all || EGDP156 || 2023-01-19 13:27:51.0",

"AppEvtLogTest || EGDP156 || NULL || NULL || +all || EGDP156 || 2023-01-19 13:27:51.0",

"AppEvtLogTest || win_1 || NULL || NULL || +all || EGDP156 || 2023-01-19 13:27:51.0",

"DiskActivityTest || EGDP156 || NULL || NULL || +Disk0 C: || EGDP156 || 2023-01-19 13:29:08.0",

"DiskActivityTest || tomcat_1 || NULL || NULL || +Disk0 C: || EGDP156 || 2023-01-19 13:29:05.0",

"DiskActivityTest || win_1 || NULL || NULL || +Disk0 C: || EGDP156 || 2023-01-19 13:28:47.0",

"DiskSpaceTest || EGDP156 || NULL || NULL || +C || EGDP156 || 2023-01-19 13:29:29.0",

"DiskSpaceTest || tomcat_1 || NULL || NULL || +C || EGDP156 || 2023-01-19 13:22:54.0",

"DiskSpaceTest || win_1 || NULL || NULL || +C || EGDP156 || 2023-01-19 13:24:50.0",

"EgAgentInfoTest || EGDP156 || 7077 || NULL || + || EGDP156 || 2023-01-19 13:29:02.0",

"EgCleanupLogTest || EGDP156 || 7077 || NULL || +cleanup_log:error || EGDP156 || 2023-01-19 13:28:07.0",

"EgCleanupLogTest || EGDP156 || 7077 || NULL || +cleanup_log:warn || EGDP156 || 2023-01-19 13:28:07.0",

"EgCleanupTest || EGDP156 || 7077 || NULL || + || EGDP156 || 2023-01-19 13:24:08.0",

"EgClusterInfoTest || EGDP156 || 7077 || NULL || +EGDP156 || EGDP156 || 2023-01-19 13:15:56.0",

"EgConnectionPoolTest || EGDP156 || 7077 || NULL || + || EGDP156 || 2023-01-19 13:29:31.0",

"EgDBDatafile || EGDP156 || 7077 || NULL || +venkatj_28_12_2011.mdf || EGDP156 || 2023-01-19 13:21:53.0",

"EgDBDatafile || EGDP156 || 7077 || NULL || +venkatj_28_12_2011_log.LDF || EGDP156 || 2023-01-19 13:21:53.0",

.

.

.

]

 

Failure Response
Type Code Content

JSON

401 UNAUTHORIZED

{"code": 401,"error": "Invalid username or password"}

JSON

500 Server Error

{"code": 500,"error": " Server Error. Please check REST API parameter values and also check /manager/logs/error_log or managererr.log in the eG manager installation directory for more information."}

Figure 4 : Retrieving data by executing a custom query using Postman REST Client

Retrieving Data by Executing Custom Query using cURL

To retrieve data from the eG backend database by executing a custom query using cURL, the command should be specified in the following format:

curl -L -X POST "http://<eG Manager IP:Port>/api/eg/analytics/getCustomQuery" -H "user:<eG username or domain/eG username>" -H "pwd:Base64 encoded password" -H "managerurl:http://<eG Manager IP:Port>" -H"Content-Type:application/json" --data-raw "{\"query\": \"select * from (table)\"}"

Figure 5 shows an example command to retrieve the data from the eG backend database by executing a custom query using cURL.

Figure 5 : An example cURL command to retrieve data by executing a custom query