Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed Up metrics to look for just Success response #1340

Merged
merged 1 commit into from
Oct 16, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,11 @@ public Object getValueForQuery(DataSourceInfo dataSource, String query) {

if (null == jsonObject) {
return null;
} else {
return "1"; //if it returns HTTP STATUS_OK 200
}

JSONArray result = jsonObject.getJSONObject(KruizeConstants.DataSourceConstants.DataSourceQueryJSONKeys.DATA).getJSONArray(KruizeConstants.DataSourceConstants.DataSourceQueryJSONKeys.RESULT);
for (Object result_obj : result) {
JSONObject result_json = (JSONObject) result_obj;
if (result_json.has(KruizeConstants.DataSourceConstants.DataSourceQueryJSONKeys.VALUE)
&& !result_json.getJSONArray(KruizeConstants.DataSourceConstants.DataSourceQueryJSONKeys.VALUE).isEmpty()) {
return result_json.getJSONArray(KruizeConstants.DataSourceConstants.DataSourceQueryJSONKeys.VALUE).getString(1);
}
}

} catch (JSONException e) {
LOGGER.error(e.getMessage());
} catch (NullPointerException e) {
Expand Down Expand Up @@ -159,6 +154,7 @@ public JSONObject getJsonObjectForQuery(DataSourceInfo dataSource, String query)
JSONObject jsonObject = apiClient.fetchMetricsJson(
KruizeConstants.HttpConstants.MethodType.GET,
query);
/* TODO need to separate it out this logic form here
if (!jsonObject.has(KruizeConstants.DataSourceConstants.DataSourceQueryJSONKeys.STATUS))
return null;
if (!jsonObject.getString(KruizeConstants.DataSourceConstants.DataSourceQueryJSONKeys.STATUS).equalsIgnoreCase(KruizeConstants.DataSourceConstants.DataSourceQueryStatus.SUCCESS))
Expand All @@ -170,6 +166,8 @@ public JSONObject getJsonObjectForQuery(DataSourceInfo dataSource, String query)
if (jsonObject.getJSONObject(KruizeConstants.DataSourceConstants.DataSourceQueryJSONKeys.DATA).getJSONArray(KruizeConstants.DataSourceConstants.DataSourceQueryJSONKeys.RESULT).isEmpty())
return null;

*/

return jsonObject;

} catch (HttpHostConnectException e) {
Expand Down
Loading