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

Migrate Get Detector stats to SDK using SDKRestClient #382

Closed
9 tasks done
Tracked by #5224
dbwiddis opened this issue Jan 29, 2023 · 5 comments
Closed
9 tasks done
Tracked by #5224

Migrate Get Detector stats to SDK using SDKRestClient #382

dbwiddis opened this issue Jan 29, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@dbwiddis
Copy link
Member

dbwiddis commented Jan 29, 2023

Is your feature request related to a problem?

Part of opensearch-project/OpenSearch#5224

What solution would you like?

Migrate the Get Detector stats Rest API to Extensions SDK using SDKRestClient.

Use the implementation of #353 as a reference. Add new issues for any steps you skip.

Implement the following API endpoints:

  • GET _plugins/_anomaly_detection/stats
  • GET _plugins/_anomaly_detection/<nodeId>/stats
  • GET _plugins/_anomaly_detection/<nodeId>/stats/<stat>

The Get detector stats api's are responsible for providing information about how the plugin is performing.

  • Add components required for RestStatsAnomalyDetectorExtension in createComponents Extension Point in AnomalyDetectorExtension
  • Modify RestStatsAnomalyDetectorExtension Constructor
  • Replace clusterservice to sdkclusterservice
  • Implement TransportAction in StatsAnomalyDetectoTransportAction
  • Implement getClusterStats and getNodeStats changes
  • Test the above api's
@vibrantvarun
Copy link
Member

vibrantvarun commented Mar 28, 2023

Added necessary objects in create components but there is a method named stats missing in SDKIndicesClient which needs to be created on Opensearch-sdk-java. Need to discuss with @dbwiddis regarding that

IndicesAdminClient on opensearch has a 2 method

  /**
     * Indices stats.
     */
    void stats(IndicesStatsRequest request, ActionListener<IndicesStatsResponse> listener);

    /**
     * Indices stats.
     */
    IndicesStatsRequestBuilder prepareStats(String... indices);

There is a need to create there counter part on sdkindicesclient as well.

@minalsha
Copy link
Collaborator

@vibrantvarun what are the blockers for this draft PR to be opened up?

@minalsha
Copy link
Collaborator

As per @vibrantvarun , this issue is blocked on resolving this bug: #654 . @dbwiddis / @owaiskazi19 thoughts?

@dbwiddis
Copy link
Member Author

As per @vibrantvarun , this issue is blocked on resolving this bug: #654 . @dbwiddis / @owaiskazi19 thoughts?

Per this comment #654 is not an actual bug, there was an incorrect base path used. However, in the process of troubleshooting I did implement deprecated and replaced routes in #666, which should be merged and this PR rebased to the new format (closer to original AD format/minimize the diff).

@vibrantvarun
Copy link
Member

vibrantvarun commented Apr 17, 2023

  • curl -X GET "localhost:9200/_extensions/_ad-extension-1/stats/"
{
  "anomaly_detectors_index_status": "non-existent",
  "anomaly_detection_state_status": "non-existent",
  "single_entity_detector_count": 0,
  "detector_count": 0,
  "multi_entity_detector_count": 0,
  "anomaly_detection_job_index_status": "non-existent",
  "models_checkpoint_index_status": "non-existent",
  "anomaly_results_index_status": "non-existent",
  "nodes": {
    "ad-extension-1": {
      "ad_execute_request_count": 0,
      "models": [
        
      ],
      "ad_canceled_batch_task_count": 0,
      "ad_hc_execute_request_count": 0,
      "ad_hc_execute_failure_count": 0,
      "model_count": 0,
      "ad_execute_failure_count": 0,
      "ad_batch_task_failure_count": 0,
      "ad_total_batch_task_execution_count": 0,
      "ad_executing_batch_task_count": 0
    }
  }
}
  • curl -X GET "localhost:9200/_extensions/_ad-extension-1/stats/ad_hc_execute_failure_count"
{
 "nodes": {
   "ad-extension-1": {
     "ad_hc_execute_failure_count": 0
   }
 }
}
  • curl -X GET "localhost:9200/_extensions/_ad-extension-1/_ad-extension-1/stats/ad_hc_execute_failure_count"
{
  "nodes": {
    "ad-extension-1": {
      "ad_hc_execute_failure_count": 0
    }
  }
}

  • curl -X GET "localhost:9200/_extensions/_ad-extension-1/_ad-extension-1/stats"
{
  "anomaly_detectors_index_status": "non-existent",
  "anomaly_detection_state_status": "non-existent",
  "single_entity_detector_count": 0,
  "detector_count": 0,
  "multi_entity_detector_count": 0,
  "anomaly_detection_job_index_status": "non-existent",
  "models_checkpoint_index_status": "non-existent",
  "anomaly_results_index_status": "non-existent",
  "nodes": {
    "ad-extension-1": {
      "ad_execute_request_count": 0,
      "models": [
        
      ],
      "ad_canceled_batch_task_count": 0,
      "ad_hc_execute_request_count": 0,
      "ad_hc_execute_failure_count": 0,
      "model_count": 0,
      "ad_execute_failure_count": 0,
      "ad_batch_task_failure_count": 0,
      "ad_total_batch_task_execution_count": 0,
      "ad_executing_batch_task_count": 0
    }
  }
}

  • Response of detector stats after triggering create detector api
{
  "anomaly_detectors_index_status": "yellow",
  "anomaly_detection_state_status": "non-existent",
  "single_entity_detector_count": 1,
  "detector_count": 1,
  "multi_entity_detector_count": 0,
  "anomaly_detection_job_index_status": "non-existent",
  "models_checkpoint_index_status": "non-existent",
  "anomaly_results_index_status": "non-existent",
  "nodes": {
    "ad-extension-1": {
      "ad_execute_request_count": 0,
      "models": [
        
      ],
      "ad_canceled_batch_task_count": 0,
      "ad_hc_execute_request_count": 0,
      "ad_hc_execute_failure_count": 0,
      "model_count": 0,
      "ad_execute_failure_count": 0,
      "ad_batch_task_failure_count": 0,
      "ad_total_batch_task_execution_count": 0,
      "ad_executing_batch_task_count": 0
    }
  }
}


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants