Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Publish Shard State Metrics #436

Merged
merged 8 commits into from
Oct 20, 2020
Merged

Publish Shard State Metrics #436

merged 8 commits into from
Oct 20, 2020

Conversation

amathur1893
Copy link
Contributor

@amathur1893 amathur1893 commented Sep 25, 2020

Fixes #:opendistro-for-elasticsearch/performance-analyzer#213

Description of changes:
This change will start publishing shard state - Initializing, Unassigned and Relocating for each shard. We have not published Active shards to save space.

Testing

  1. ./gradlew test
SUCCESS: Executed 455 tests in 41m 55s (1 skipped)

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 42m 22s
11 actionable tasks: 2 executed, 9 up-to-date
  1. Tested using docker.

Tmp File -

^shard_state_metrics
{"current_time":1602500493586}
{"IndexName":pmc}
{"ShardID":2,"ShardType":"p","NodeName":"elasticsearch2","Shard_State":"UNASSIGNED"}
{"ShardID":4,"ShardType":"p","NodeName":"elasticsearch2","Shard_State":"INITIALIZING"}
{"IndexName":pmc1}
{"ShardID":1,"ShardType":"p","NodeName":"elasticsearch1","Shard_State":"UNASSIGNED"}
{"ShardID":0,"ShardType":"p","NodeName":"elasticsearch2","Shard_State":"UNASSIGNED"}
$

Table created

sqlite> .tables
Shard_State

Content of the table

sqlite> select * from Shard_State;
pmc|4|p|elasticsearch1|UNASSIGNED|1.0|1.0|1.0|1.0
pmc|2|p|elasticsearch2|INITIALIZING|1.0|1.0|1.0|1.0
pmc1|1|p|elasticsearch2|UNASSIGNED|1.0|1.0|1.0|1.0
pmc1|0|p|elasticsearch1|UNASSIGNED|1.0|1.0|1.0|1.0

Rest API

arpitamt@c4b301d5bc1f ~> curl -XGET "localhost:9600/_opendistro/_performanceanalyzer/metrics?metrics=Shard_State&agg=avg&dim=Shard_State&nodes=all" | python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   188  100   188    0     0     22      0  0:00:08  0:00:08 --:--:--    45
{
    "id3qQArxRPSA2EHbEfPlew": {
        "timestamp": 1602771645000,
        "data": {
            "fields": [
                {
                    "name": "Shard_State",
                    "type": "VARCHAR"
                },
                {
                    "name": "Shard_State",
                    "type": "DOUBLE"
                }
            ],
            "records": [
                [
                    "UNASSIGNED",
                    0.0
                ]
            ]
        }
    }
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@yojs yojs requested a review from vigyasharma October 1, 2020 18:34
@yojs yojs requested a review from rguo-aws October 9, 2020 17:52
yojs
yojs previously approved these changes Oct 16, 2020
yojs
yojs previously approved these changes Oct 19, 2020
@@ -65,6 +66,7 @@ public void run() {
() -> StatExceptionCode.OTHER_COLLECTION_ERROR.toString());
StatsCollector.instance().logException(StatExceptionCode.OTHER_COLLECTION_ERROR);
} finally {
LOG.debug("{} took {} time to execute", collectorName, System.nanoTime() - startTime);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we change this to a metric ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, it would be good to have a "timetook" metric to indicate the time taken for metric collection.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already made the change in PA PR - opendistro-for-elasticsearch/performance-analyzer#212

@yojs yojs requested review from khushbr and adityaj1107 and removed request for vigyasharma and rguo-aws October 19, 2020 20:54
@@ -65,6 +66,7 @@ public void run() {
() -> StatExceptionCode.OTHER_COLLECTION_ERROR.toString());
StatsCollector.instance().logException(StatExceptionCode.OTHER_COLLECTION_ERROR);
} finally {
LOG.debug("{} took {} time to execute", collectorName, System.nanoTime() - startTime);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, it would be good to have a "timetook" metric to indicate the time taken for metric collection.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants