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 Profile Detector to SDK using SDKRestClient #381

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

Migrate Profile Detector to SDK using SDKRestClient #381

dbwiddis opened this issue Jan 29, 2023 · 10 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 Profile Detector 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/detectors/<detectorId>/_profile/
  • GET _plugins/_anomaly_detection/detectors/<detectorId>/_profile?_all=true
  • GET _plugins/_anomaly_detection/detectors/<detectorId>/_profile/<type>
  • GET _plugins/_anomaly_detection/detectors/<detectorId>/_profile/<type1>,<type2>
  • GET _plugins/_anomaly_detection/detectors/<detectorId>/_profile/ad_task

Work required to be done to enable the api

  • Enabling api endpoints by adding them in getRouteHandlers() method in RestGetAnomalyDetectorExtension
  • Implement Transport Action in GetAnomalyDetectorTransportAction and make necessary changes in RestGetAnomalyDetectorAction in client.execute
  • Make necessary changes required for extensions in RFCPollingTransportAction
  • Make necessary changes required for extensions in ProfileTransportAction
  • Test the work flow
@vibrantvarun
Copy link
Member

vibrantvarun commented Mar 23, 2023

I triggered the below profile api and got the error as index not found. The index is created via start detector api

curl -X POST "localhost:9200/_extensions/_ad-extension-1/detectors/FwmsEIcBRUi-__qyjsK2/_profile"
{"error":"Request failed with exception: [[.opendistro-anomaly-detector-jobs] OpenSearchStatusException[OpenSearch exception [type=index_not_found_exception, reason=no such index [.opendistro-anomaly-detector-jobs]]]]"}%

It has a direct dependency on start detector
#383

Once the start detector gets completed I will pick this again.

cc: @minalsha @owaiskazi19 @dbwiddis

@joshpalis
Copy link
Member

@vibrantvarun to unblock you for now, you can pass in the AnomalyDetectionIndices object from create components into the transport action constructor. Since this is bound to guice, it will be injected. You can then invoke this method to initialize the job index.

@vibrantvarun
Copy link
Member

@joshpalis Okay Trying out the heck

@joshpalis
Copy link
Member

@vibrantvarun you can refer to this method here to see how the method is invoked.

@vibrantvarun
Copy link
Member

Hey @joshpalis there is a lot of similar work which you already did in the start detector needed to be done in order to make the heck mentioned above work. Though, I have done the work to implement the TransportAction in GetAnomalyDetectorTransportAction. However, I would test it once the start detector PR gets merged

@vibrantvarun
Copy link
Member

vibrantvarun commented Apr 28, 2023

curl -XGET "localhost:9200/_extensions/_ad-extension-1/detectors/hIkWxocBfv5Mrc62nERw/_profile?_all=true&pretty"
{
  "state": "RUNNING",
  "error": "",
  "models": [
    {
      "model_id": "hIkWxocBfv5Mrc62nERw_model_rcf_0",
      "model_size_in_bytes": 582896,
      "node_id": "ad-extension-1"
    }
  ],
  "shingle_size": 8,
  "coordinating_node": "ad-extension-1",
  "total_size_in_bytes": 582896,
  "init_progress": {
    "percentage": "100%"
  }
}%                           

@vibrantvarun
Copy link
Member

curl -XGET "localhost:9200/_extensions/_ad-extension-1/detectors/hIkWxocBfv5Mrc62nERw/_profile"
{"state":"RUNNING","error":""}%    

@vibrantvarun
Copy link
Member

vibrantvarun commented May 1, 2023

curl -XGET "localhost:9200/_extensions/_ad-extension-1/detectors/hIkWxocBfv5Mrc62nERw/_profile/init_progress"


{"init_progress":{"percentage":"100%"}}%  

@vibrantvarun
Copy link
Member

curl -XGET "localhost:9200/_extensions/_ad-extension-1/detectors/hIkWxocBfv5Mrc62nERw/_profile/init_progress,total_size_in_bytes"


{"total_size_in_bytes":582896,"init_progress":{"percentage":"100%"}}%  

@vibrantvarun
Copy link
Member

vibrantvarun commented May 1, 2023

curl -XGET "localhost:9200/_extensions/_ad-extension-1/detectors/hIkWxocBfv5Mrc62nERw/_profile/ad_task"

{
  "ad_task": {
    "ad_task": {
      "task_id": "NYKb2YcBHow9Nz8vxCaP",
      "last_update_time": 1682983100576,
      "state": "FINISHED",
      "detector_id": "hIkWxocBfv5Mrc62nERw",
      "task_progress": 1.0,
      "init_progress": 1.0,
      "current_piece": 1683099480000,
      "execution_start_time": 1682983077001,
      "execution_end_time": 1682983100519,
      "is_latest": true,
      "task_type": "HISTORICAL_SINGLE_ENTITY",
      "coordinating_node": "ad-extension-1",
      "worker_node": "ad-extension-1",
      "detector": {
        "name": "test-detector1",
        "description": "Test detector",
        "time_field": "@timestamp",
        "indices": [
          "server_log"
        ],
        "filter_query": {
          "match_all": {
            "boost": 1.0
          }
        },
        "detection_interval": {
          "period": {
            "interval": 1,
            "unit": "Minutes"
          }
        },
        "window_delay": {
          "period": {
            "interval": 1,
            "unit": "Minutes"
          }
        },
        "shingle_size": 8,
        "schema_version": 0,
        "feature_attributes": [
          {
            "feature_id": "CfMWxocBRbjWsKgzc8qY",
            "feature_name": "test",
            "feature_enabled": true,
            "aggregation_query": {
              "test": {
                "avg": {
                  "field": "jvmGcTime"
                }
              }
            }
          }
        ],
        "last_update_time": 1682655583341,
        "detector_type": "SINGLE_ENTITY"
      },
      "detection_date_range": {
        "start_time": 1682799531000,
        "end_time": 1683099521000
      }
    }
  }                 

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