翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
SDK for SAP ABAP を使用した CloudWatch の例
次のコード例は、CloudWatch で AWS SDK for SAP ABAP を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。
アクションはより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。
シナリオは、1 つのサービス内から、または他の AWS のサービスと組み合わせて複数の関数を呼び出し、特定のタスクを実行する方法を示すコード例です。
各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。
アクション
次のコード例は、DeleteAlarms を使用する方法を示しています。
- SDK for SAP ABAP
-
注記
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 TRY. lo_cwt->deletealarms( it_alarmnames = it_alarm_names ). MESSAGE 'Alarms deleted.' TYPE 'I'. CATCH /aws1/cx_cwtresourcenotfound. MESSAGE 'Resource being accessed is not found.' TYPE 'E'. ENDTRY.-
API の詳細については、「AWS SDK for SAP ABAP API リファレンス」の「DeleteAlarms」を参照してください。
-
次のコード例は、DescribeAlarms を使用する方法を示しています。
- SDK for SAP ABAP
-
注記
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 TRY. oo_result = lo_cwt->describealarms( " oo_result is returned for testing purposes. " it_alarmnames = it_alarm_names ). MESSAGE 'Alarms retrieved.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API の詳細については、「AWS SDK for SAP ABAP API リファレンス」の「DescribeAlarms」を参照してください。
-
次の例は、DescribeAlarmsForMetric を使用する方法を説明しています。
- SDK for SAP ABAP
-
注記
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 TRY. oo_result = lo_cwt->describealarmsformetric( " oo_result is returned for testing purposes. " iv_namespace = iv_namespace iv_metricname = iv_metric_name it_dimensions = it_dimensions iv_statistic = iv_statistic iv_period = iv_period iv_unit = iv_unit ). MESSAGE 'Alarms for metric retrieved.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API の詳細については、 AWS SDK for SAP ABAP API リファレンスの「DescribeAlarmsForMetric」を参照してください。
-
次の例は、DisableAlarmActions を使用する方法を説明しています。
- SDK for SAP ABAP
-
注記
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 "Disables actions on the specified alarm. " TRY. lo_cwt->disablealarmactions( it_alarmnames = it_alarm_names ). MESSAGE 'Alarm actions disabled.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API の詳細については、「AWS SDK for SAP ABAP API リファレンス」の「DisableAlarmActions」を参照してください。
-
次のコード例は、EnableAlarmActions を使用する方法を示しています。
- SDK for SAP ABAP
-
注記
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 "Enable actions on the specified alarm." TRY. lo_cwt->enablealarmactions( it_alarmnames = it_alarm_names ). MESSAGE 'Alarm actions enabled.' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_exception). DATA(lv_error) = |"{ lo_exception->av_err_code }" - { lo_exception->av_err_msg }|. MESSAGE lv_error TYPE 'E'. ENDTRY.-
API の詳細については、「AWS SDK for SAP ABAP API リファレンス」の「EnableAlarmActions」を参照してください。
-
次の例は、GetMetricStatistics を使用する方法を説明しています。
- SDK for SAP ABAP
-
注記
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 TRY. oo_result = lo_cwt->getmetricstatistics( " oo_result is returned for testing purposes. " iv_namespace = iv_namespace iv_metricname = iv_metric_name iv_starttime = iv_start_time iv_endtime = iv_end_time iv_period = iv_period it_statistics = it_statistics ). MESSAGE 'Metric statistics retrieved.' TYPE 'I'. CATCH /aws1/cx_cwtinvparamvalueex. MESSAGE 'The specified argument was not valid.' TYPE 'E'. ENDTRY.-
API の詳細については、 AWS SDK for SAP ABAP API リファレンスのGetMetricStatistics」を参照してください。
-
次の例は、ListMetrics を使用する方法を説明しています。
- SDK for SAP ABAP
-
注記
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 "The following list-metrics example displays the metrics for Amazon CloudWatch." TRY. oo_result = lo_cwt->listmetrics( " oo_result is returned for testing purposes. " iv_namespace = iv_namespace ). DATA(lt_metrics) = oo_result->get_metrics( ). MESSAGE 'Metrics retrieved.' TYPE 'I'. CATCH /aws1/cx_cwtinvparamvalueex. MESSAGE 'The specified argument was not valid.' TYPE 'E'. ENDTRY.-
API の詳細については、「AWS SDK for SAP ABAP API リファレンス」の「ListMetrics」を参照してください。
-
次のコード例は、PutMetricAlarm を使用する方法を示しています。
- SDK for SAP ABAP
-
注記
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 TRY. lo_cwt->putmetricalarm( iv_alarmname = iv_alarm_name iv_comparisonoperator = iv_comparison_operator iv_evaluationperiods = iv_evaluation_periods iv_metricname = iv_metric_name iv_namespace = iv_namespace iv_statistic = iv_statistic iv_threshold = iv_threshold iv_actionsenabled = iv_actions_enabled iv_alarmdescription = iv_alarm_description iv_unit = iv_unit iv_period = iv_period it_dimensions = it_dimensions ). MESSAGE 'Alarm created.' TYPE 'I'. CATCH /aws1/cx_cwtlimitexceededfault. MESSAGE 'The request processing has exceeded the limit' TYPE 'E'. ENDTRY.-
API の詳細については、「AWS SDK for SAP ABAP API リファレンス」の「PutMetricAlarm」を参照してください。
-
次の例は、PutMetricData を使用する方法を説明しています。
- SDK for SAP ABAP
-
注記
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 DATA lt_metricdata TYPE /aws1/cl_cwtmetricdatum=>tt_metricdata. "Create metric data object. DATA(lo_metricdatum) = NEW /aws1/cl_cwtmetricdatum( iv_metricname = iv_metric_name iv_value = iv_value iv_unit = iv_unit ). INSERT lo_metricdatum INTO TABLE lt_metricdata. TRY. lo_cwt->putmetricdata( iv_namespace = iv_namespace it_metricdata = lt_metricdata ). MESSAGE 'Metric data added.' TYPE 'I'. CATCH /aws1/cx_cwtinvparamvalueex. MESSAGE 'The specified argument was not valid.' TYPE 'E'. ENDTRY.一連のデータを CloudWatch メトリクスに配置します。
DATA lt_metricdata TYPE /aws1/cl_cwtmetricdatum=>tt_metricdata. "Create metric data object with values and counts. DATA(lo_metricdatum) = NEW /aws1/cl_cwtmetricdatum( iv_metricname = iv_metric_name iv_timestamp = iv_timestamp iv_unit = iv_unit it_values = it_values it_counts = it_counts ). INSERT lo_metricdatum INTO TABLE lt_metricdata. TRY. lo_cwt->putmetricdata( iv_namespace = iv_namespace it_metricdata = lt_metricdata ). MESSAGE 'Metric data set added.' TYPE 'I'. CATCH /aws1/cx_cwtinvparamvalueex. MESSAGE 'The specified argument was not valid.' TYPE 'E'. ENDTRY.-
API の詳細については、 AWS SDK for SAP ABAP API リファレンスの「PutMetricData」を参照してください。
-
シナリオ
次のコード例は、以下の操作方法を示しています。
アラームを作成します。
アラームアクションの無効化。
アラームの記述。
アラームの削除。
- SDK for SAP ABAP
-
注記
GitHub には、その他のリソースもあります。用例一覧を検索し、AWS コード例リポジトリ
での設定と実行の方法を確認してください。 DATA lt_alarmnames TYPE /aws1/cl_cwtalarmnames_w=>tt_alarmnames. DATA lo_alarmname TYPE REF TO /aws1/cl_cwtalarmnames_w. "Create an alarm" TRY. lo_cwt->putmetricalarm( iv_alarmname = iv_alarm_name iv_comparisonoperator = iv_comparison_operator iv_evaluationperiods = iv_evaluation_periods iv_metricname = iv_metric_name iv_namespace = iv_namespace iv_statistic = iv_statistic iv_threshold = iv_threshold iv_actionsenabled = iv_actions_enabled iv_alarmdescription = iv_alarm_description iv_unit = iv_unit iv_period = iv_period it_dimensions = it_dimensions ). MESSAGE 'Alarm created' TYPE 'I'. CATCH /aws1/cx_cwtlimitexceededfault. MESSAGE 'The request processing has exceeded the limit' TYPE 'E'. ENDTRY. "Create an ABAP internal table for the created alarm." lo_alarmname = NEW #( iv_value = iv_alarm_name ). INSERT lo_alarmname INTO TABLE lt_alarmnames. "Disable alarm actions." TRY. lo_cwt->disablealarmactions( it_alarmnames = lt_alarmnames ). MESSAGE 'Alarm actions disabled' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_disablealarm_exception). DATA(lv_disablealarm_error) = |"{ lo_disablealarm_exception->av_err_code }" - { lo_disablealarm_exception->av_err_msg }|. MESSAGE lv_disablealarm_error TYPE 'E'. ENDTRY. "Describe alarm using the same ABAP internal table." TRY. oo_result = lo_cwt->describealarms( " oo_result is returned for testing purpose " it_alarmnames = lt_alarmnames ). MESSAGE 'Alarms retrieved' TYPE 'I'. CATCH /aws1/cx_rt_service_generic INTO DATA(lo_describealarms_exception). DATA(lv_describealarms_error) = |"{ lo_describealarms_exception->av_err_code }" - { lo_describealarms_exception->av_err_msg }|. MESSAGE lv_describealarms_error TYPE 'E'. ENDTRY. "Delete alarm." TRY. lo_cwt->deletealarms( it_alarmnames = lt_alarmnames ). MESSAGE 'Alarms deleted' TYPE 'I'. CATCH /aws1/cx_cwtresourcenotfound. MESSAGE 'Resource being access is not found.' TYPE 'E'. ENDTRY.-
API の詳細については、「AWS SDK for SAP ABAP API リファレンス」の次のトピックを参照してください。
-