Skip to content

/AWS1/IF_AMP=>CREATEANOMALYDETECTOR()

About CreateAnomalyDetector

Creates an anomaly detector within a workspace using the Random Cut Forest algorithm for time-series analysis. The anomaly detector analyzes Amazon Managed Service for Prometheus metrics to identify unusual patterns and behaviors.

Method Signature

METHODS /AWS1/IF_AMP~CREATEANOMALYDETECTOR
  IMPORTING
    !IV_WORKSPACEID TYPE /AWS1/AMPWORKSPACEID OPTIONAL
    !IV_ALIAS TYPE /AWS1/AMPANOMALYDETECTORALIAS OPTIONAL
    !IV_EVALINTERVALINSECONDS TYPE /AWS1/AMPANOMALYDETECTOREVAL00 OPTIONAL
    !IO_MISSINGDATAACTION TYPE REF TO /AWS1/CL_AMPANOMALYDETECTORM00 OPTIONAL
    !IO_CONFIGURATION TYPE REF TO /AWS1/CL_AMPANOMALYDETECTORC00 OPTIONAL
    !IT_LABELS TYPE /AWS1/CL_AMPPROMETHEUSMETRIC00=>TT_PROMETHEUSMETRICLABELMAP OPTIONAL
    !IV_CLIENTTOKEN TYPE /AWS1/AMPIDEMPOTENCYTOKEN OPTIONAL
    !IT_TAGS TYPE /AWS1/CL_AMPTAGMAP_W=>TT_TAGMAP OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_ampcreanomalydetect01
  RAISING
    /AWS1/CX_AMPACCESSDENIEDEX
    /AWS1/CX_AMPCONFLICTEXCEPTION
    /AWS1/CX_AMPINTERNALSERVEREX
    /AWS1/CX_AMPSERVICEQUOTAEXCDEX
    /AWS1/CX_AMPTHROTTLINGEX
    /AWS1/CX_AMPVALIDATIONEX
    /AWS1/CX_AMPCLIENTEXC
    /AWS1/CX_AMPSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_workspaceid TYPE /AWS1/AMPWORKSPACEID /AWS1/AMPWORKSPACEID

The identifier of the workspace where the anomaly detector will be created.

iv_alias TYPE /AWS1/AMPANOMALYDETECTORALIAS /AWS1/AMPANOMALYDETECTORALIAS

A user-friendly name for the anomaly detector.

io_configuration TYPE REF TO /AWS1/CL_AMPANOMALYDETECTORC00 /AWS1/CL_AMPANOMALYDETECTORC00

The algorithm configuration for the anomaly detector.

Optional arguments:

iv_evalintervalinseconds TYPE /AWS1/AMPANOMALYDETECTOREVAL00 /AWS1/AMPANOMALYDETECTOREVAL00

The frequency, in seconds, at which the anomaly detector evaluates metrics. The default value is 60 seconds.

io_missingdataaction TYPE REF TO /AWS1/CL_AMPANOMALYDETECTORM00 /AWS1/CL_AMPANOMALYDETECTORM00

Specifies the action to take when data is missing during evaluation.

it_labels TYPE /AWS1/CL_AMPPROMETHEUSMETRIC00=>TT_PROMETHEUSMETRICLABELMAP TT_PROMETHEUSMETRICLABELMAP

The Amazon Managed Service for Prometheus metric labels to associate with the anomaly detector.

iv_clienttoken TYPE /AWS1/AMPIDEMPOTENCYTOKEN /AWS1/AMPIDEMPOTENCYTOKEN

A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

it_tags TYPE /AWS1/CL_AMPTAGMAP_W=>TT_TAGMAP TT_TAGMAP

The metadata to apply to the anomaly detector to assist with categorization and organization.

RETURNING

oo_output TYPE REF TO /aws1/cl_ampcreanomalydetect01 /AWS1/CL_AMPCREANOMALYDETECT01

Domain /AWS1/RT_ACCOUNT_ID
Primitive Type NUMC

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->createanomalydetector(
  io_configuration = new /aws1/cl_ampanomalydetectorc00(
    io_randomcutforest = new /aws1/cl_amprandomcutforestc00(
      io_ignorenearexpectedfrmab00 = new /aws1/cl_ampignorenearexpected(
        iv_amount = '0.1'
        iv_ratio = '0.1'
      )
      io_ignorenearexpectedfrmbe00 = new /aws1/cl_ampignorenearexpected(
        iv_amount = '0.1'
        iv_ratio = '0.1'
      )
      iv_query = |string|
      iv_samplesize = 123
      iv_shinglesize = 123
    )
  )
  io_missingdataaction = new /aws1/cl_ampanomalydetectorm00(
    iv_markasanomaly = ABAP_TRUE
    iv_skip = ABAP_TRUE
  )
  it_labels = VALUE /aws1/cl_ampprometheusmetric00=>tt_prometheusmetriclabelmap(
    (
      VALUE /aws1/cl_ampprometheusmetric00=>ts_prometheusmetricla00_maprow(
        value = new /aws1/cl_ampprometheusmetric00( |string| )
        key = |string|
      )
    )
  )
  it_tags = VALUE /aws1/cl_amptagmap_w=>tt_tagmap(
    (
      VALUE /aws1/cl_amptagmap_w=>ts_tagmap_maprow(
        key = |string|
        value = new /aws1/cl_amptagmap_w( |string| )
      )
    )
  )
  iv_alias = |string|
  iv_clienttoken = |string|
  iv_evalintervalinseconds = 123
  iv_workspaceid = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_anomalydetectorid = lo_result->get_anomalydetectorid( ).
  lv_anomalydetectorarn = lo_result->get_arn( ).
  lo_anomalydetectorstatus = lo_result->get_status( ).
  IF lo_anomalydetectorstatus IS NOT INITIAL.
    lv_anomalydetectorstatusco = lo_anomalydetectorstatus->get_statuscode( ).
    lv_string = lo_anomalydetectorstatus->get_statusreason( ).
  ENDIF.
  LOOP AT lo_result->get_tags( ) into ls_row.
    lv_key = ls_row-key.
    lo_value = ls_row-value.
    IF lo_value IS NOT INITIAL.
      lv_tagvalue = lo_value->get_value( ).
    ENDIF.
  ENDLOOP.
ENDIF.