CloudWatch 使用 for SDK 的示例 SAP ABAP - Amazon SDK对于 SAP ABAP
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

CloudWatch 使用 for SDK 的示例 SAP ABAP

以下代码示例向您展示了如何使用 for with 来执行操作和实现常见场景 CloudWatch。 Amazon SDK SAP ABAP

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

场景是向您展示如何通过在一个服务中调用多个函数或与其他 Amazon Web Services 服务结合来完成特定任务的代码示例。

每个示例都包含一个指向完整源代码的链接,您可以在其中找到有关如何在上下文中设置和运行代码的说明。

操作

以下代码示例显示了如何使用DeleteAlarms

SDK对于 SAP ABAP
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

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详细信息,请参阅DeleteAlarms中的Amazon SDK以供SAPABAPAPI参考

以下代码示例显示了如何使用DescribeAlarms

SDK对于 SAP ABAP
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

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详细信息,请参阅DescribeAlarms中的Amazon SDK以供SAPABAPAPI参考

以下代码示例显示了如何使用DisableAlarmActions

SDK对于 SAP ABAP
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

"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详细信息,请参阅DisableAlarmActions中的Amazon SDK以供SAPABAPAPI参考

以下代码示例显示了如何使用EnableAlarmActions

SDK对于 SAP ABAP
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

"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详细信息,请参阅EnableAlarmActions中的Amazon SDK以供SAPABAPAPI参考

以下代码示例显示了如何使用ListMetrics

SDK对于 SAP ABAP
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

"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详细信息,请参阅ListMetrics中的Amazon SDK以供SAPABAPAPI参考

以下代码示例显示了如何使用PutMetricAlarm

SDK对于 SAP ABAP
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

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详细信息,请参阅PutMetricAlarm中的Amazon SDK以供SAPABAPAPI参考

场景

以下代码示例显示了操作流程:

  • 创建警报。

  • 禁用警报操作。

  • 描述警报。

  • 删除警报。

SDK对于 SAP ABAP
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

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." CREATE OBJECT lo_alarmname EXPORTING 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.