From dbce9ab0e67858975498f035a3e2a16af6de573e Mon Sep 17 00:00:00 2001 From: "Ricardo L. Stephen" <43506361+ricardolstephen@users.noreply.github.com> Date: Wed, 9 Sep 2020 17:31:53 -0700 Subject: [PATCH] Minor changes in readme and error handling --- README.md | 6 +++--- .../config/PerformanceAnalyzerController.java | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b26df376..43d17a95 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,11 @@ While the metrics api associated with performance analyzer provides the last 5 s In order to access the batch metrics api, first enable it using one of the following HTTP request: ``` -POST localhost:9200/_opendistro/performanceanalyzer/batch/config -H ‘Content-Type: application/json’ -d ‘{“enabled”: true}’ -POST localhost:9200/_opendistro/performanceanalyzer/batch/cluster/config -H ‘Content-Type: application/json’ -d ‘{“enabled”: true}’ +POST localhost:9200/_opendistro/performanceanalyzer/batch/config -H ‘Content-Type: application/json’ -d ‘{"enabled": true}’ +POST localhost:9200/_opendistro/performanceanalyzer/batch/cluster/config -H ‘Content-Type: application/json’ -d ‘{"enabled": true}’ ``` -The former enables batch metrics on a single node, while the latter enables it on nodes across the entire cluster. Batch metrics can be disabled using analogous queries with `{“enabled”: false}`. +The former enables batch metrics on a single node, while the latter enables it on nodes across the entire cluster. Batch metrics can be disabled using analogous queries with `{"enabled": false}`. You can then query either the config or cluster config apis to see how many minutes worth of batch metrics data will be retained by nodes in the cluster (`batchMetricsRetentionPeriodMinutes`): diff --git a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/config/PerformanceAnalyzerController.java b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/config/PerformanceAnalyzerController.java index d2a4d11a..6374d2c9 100644 --- a/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/config/PerformanceAnalyzerController.java +++ b/src/main/java/com/amazon/opendistro/elasticsearch/performanceanalyzer/config/PerformanceAnalyzerController.java @@ -216,11 +216,12 @@ private void initBatchMetricsStateFromConf() { boolean batchMetricsEnabledFromConf; try { batchMetricsEnabledFromConf = readBooleanFromFile(filePath); + } catch (NoSuchFileException e) { + LOG.debug("Error reading Performance Analyzer state from Conf file", e); + saveStateToConf(batchMetricsEnabledDefaultValue, BATCH_METRICS_ENABLED_CONF); + batchMetricsEnabledFromConf = batchMetricsEnabledDefaultValue; } catch (Exception e) { LOG.debug("Error reading Performance Analyzer state from Conf file", e); - if (e instanceof NoSuchFileException) { - saveStateToConf(batchMetricsEnabledDefaultValue, BATCH_METRICS_ENABLED_CONF); - } batchMetricsEnabledFromConf = batchMetricsEnabledDefaultValue; }