Skip to content

/AWS1/IF_AMP=>PUTANOMALYDETECTOR()

About PutAnomalyDetector

When you call PutAnomalyDetector, the operation creates a new anomaly detector if one doesn't exist, or updates an existing one. Each call to this operation triggers a complete retraining of the detector, which includes querying the minimum required samples and backfilling the detector with historical data. This process occurs regardless of whether you're making a minor change like updating the evaluation interval or making more substantial modifications. The operation serves as the single method for creating, updating, and retraining anomaly detectors.

Method Signature

METHODS /AWS1/IF_AMP~PUTANOMALYDETECTOR
  IMPORTING
    !IV_WORKSPACEID TYPE /AWS1/AMPWORKSPACEID OPTIONAL
    !IV_ANOMALYDETECTORID TYPE /AWS1/AMPANOMALYDETECTORID 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
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_ampputanomalydetect01
  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 containing the anomaly detector to update.

iv_anomalydetectorid TYPE /AWS1/AMPANOMALYDETECTORID /AWS1/AMPANOMALYDETECTORID

The identifier of the anomaly detector to update.

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.

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.

RETURNING

oo_output TYPE REF TO /aws1/cl_ampputanomalydetect01 /AWS1/CL_AMPPUTANOMALYDETECT01

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->putanomalydetector(
  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|
      )
    )
  )
  iv_anomalydetectorid = |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.