From b34f487db8ba9e28f664662088012994aa85ee6a Mon Sep 17 00:00:00 2001 From: Aditya Jindal Date: Mon, 26 Oct 2020 10:21:11 -0700 Subject: [PATCH] Changes to the ReadMe File and deserializing the summary in the Json format. (#494) Co-authored-by: Aditya Jindal --- README.md | 36 ++++++++++++- .../persistence/actions/PersistedAction.java | 3 +- .../rest/QueryActionRequestHandler.java | 52 ++++++------------- 3 files changed, 52 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index c2fc23f06..56f3e9534 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,6 @@ The sample RCA response from above api ``` ### Temperature profiles ------------------------- There are ways to get the temperature profile of a cluster and of individual nodes. The cluster level RCA can only be queried from the elected master using the following rest API. @@ -124,6 +123,41 @@ In order to get the temperature of a particular node, we can use: `curl "localhost:9600/_opendistro/_performanceanalyzer/rca?name=AllTemperatureDimensions&local=true"` +## Rest API to get the ACTIONS suggested by the decider + +This api returns the last suggested action set by the decider framework. + +``` +curl --url "localhost:9650/_opendistro/_performanceanalyzer/actions" -XGET +``` + +The sample response from the above API: + +``` +{ + "LastSuggestedActionSet": [ + { + "actionName": "ModifyQueueCapacity", + "actionable": true, + "coolOffPeriod": 300000, + "muted": false, + "nodeIds": "{oSN5LEstThe25y8NrCGyAg}", + "nodeIps": "{10.212.52.87}", + "summary": { + "Id": "oSN5LEstThe25y8NrCGyAg", + "Ip": "10.212.52.87", + "canUpdate": true, + "coolOffPeriodInMillis": 300000, + "currentCapacity": 0, + "desiredCapacity": 1000, + "resource": 5 + } + "timestamp": 1603671580290 + } + ] +} +``` + ## Building, Deploying, and Running the RCA Framework Please refer to the [Install Guide](./INSTALL.md) for detailed information on building, installing and running the RCA framework. diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/persistence/actions/PersistedAction.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/persistence/actions/PersistedAction.java index 9c5c7c38f..06386f49d 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/persistence/actions/PersistedAction.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rca/persistence/actions/PersistedAction.java @@ -4,6 +4,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -114,7 +115,7 @@ public JsonElement toJson() { summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.ACTION_COL_NAME, this.actionName); summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.TIMESTAMP_COL_NAME, this.timestamp); summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.NODE_IDS_NAME, this.nodeIds); - summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.SUMMARY_NAME, this.summary); + summaryObj.add(SQL_SCHEMA_CONSTANTS.SUMMARY_NAME, new JsonParser().parse(this.summary)); summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.ACTIONABLE_NAME, this.actionable); summaryObj.addProperty(SQL_SCHEMA_CONSTANTS.COOLOFFPERIOD_NAME, this.coolOffPeriod); return summaryObj; diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rest/QueryActionRequestHandler.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rest/QueryActionRequestHandler.java index 072d669f7..95f479873 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rest/QueryActionRequestHandler.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/rest/QueryActionRequestHandler.java @@ -46,44 +46,22 @@ * { * "LastSuggestedActionSet": [ * { - * "actionName": "MockAction1", - * "actionable": false, - * "coolOffPeriod": 10, + * "actionName": "ModifyQueueCapacity", + * "actionable": true, + * "coolOffPeriod": 300000, * "muted": false, - * "nodeIds": "1,11", - * "nodeIps": "1.1.1.1,11.11.11.11", - * "summary": "MockSummary", - * "timestamp": 1602538860025 - * }, - * { - * "actionName": "MockAction2", - * "actionable": false, - * "coolOffPeriod": 20, - * "muted": false, - * "nodeIds": "2,22", - * "nodeIps": "2.2.2.2,22.22.22.22", - * "summary": "MockSummary", - * "timestamp": 1602538860025 - * }, - * { - * "actionName": "MockAction1", - * "actionable": false, - * "coolOffPeriod": 30, - * "muted": false, - * "nodeIds": "1,11", - * "nodeIps": "1.1.1.1,11.11.11.11", - * "summary": "MockSummary", - * "timestamp": 1602538860025 - * }, - * { - * "actionName": "MockAction2", - * "actionable": false, - * "coolOffPeriod": 40, - * "muted": false, - * "nodeIds": "2,22", - * "nodeIps": "2.2.2.2,22.22.22.22", - * "summary": "MockSummary", - * "timestamp": 1602538860025 + * "nodeIds": "{oSN5LEstThe25y8NrCGyAg}", + * "nodeIps": "{10.212.52.87}", + * "summary": { + * "Id": "oSN5LEstThe25y8NrCGyAg", + * "Ip": "10.212.52.87", + * "canUpdate": true, + * "coolOffPeriodInMillis": 300000, + * "currentCapacity": 0, + * "desiredCapacity": 1000, + * "resource": 5 + * } + * "timestamp": 1603671580290 * } * ] * }