There are more AWS SDK examples available in the AWS Doc SDK Examples
CloudWatch Logs examples using SDK for SAP ABAP
The following code examples show you how to perform actions and implement common scenarios by using the AWS SDK for SAP ABAP with CloudWatch Logs.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use GetQueryResults.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. oo_result = lo_cwl->getqueryresults( iv_queryid = iv_query_id ). " Display query status and result count DATA(lv_status) = oo_result->get_status( ). DATA(lt_results) = oo_result->get_results( ). DATA(lv_result_count) = lines( lt_results ). MESSAGE |Query status: { lv_status }. Retrieved { lv_result_count } log event(s).| TYPE 'I'. CATCH /aws1/cx_cwlinvalidparameterex. MESSAGE 'Invalid parameter.' TYPE 'E'. CATCH /aws1/cx_cwlresourcenotfoundex. MESSAGE 'Resource not found.' TYPE 'E'. CATCH /aws1/cx_cwlserviceunavailex. MESSAGE 'Service unavailable.' TYPE 'E'. ENDTRY.-
For API details, see GetQueryResults in AWS SDK for SAP ABAP API reference.
-
The following code example shows how to use StartQuery.
- SDK for SAP ABAP
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository
. TRY. " iv_log_group_name = '/aws/lambda/my-function' " iv_query_string = 'fields @timestamp, @message | sort @timestamp desc | limit 20' " iv_start_time and iv_end_time must be in Unix epoch milliseconds (ms since Jan 1, 1970 00:00:00 UTC) oo_result = lo_cwl->startquery( iv_loggroupname = iv_log_group_name iv_starttime = iv_start_time iv_endtime = iv_end_time iv_querystring = iv_query_string iv_limit = iv_limit ). " Display the query ID for tracking DATA(lv_query_id) = oo_result->get_queryid( ). MESSAGE |Query started successfully with ID: { lv_query_id }| TYPE 'I'. CATCH /aws1/cx_cwlinvalidparameterex. MESSAGE 'Invalid parameter.' TYPE 'E'. CATCH /aws1/cx_cwllimitexceededex. MESSAGE 'Limit exceeded.' TYPE 'E'. CATCH /aws1/cx_cwlmalformedqueryex. MESSAGE 'Malformed query.' TYPE 'E'. CATCH /aws1/cx_cwlresourcenotfoundex. MESSAGE 'Resource not found.' TYPE 'E'. CATCH /aws1/cx_cwlserviceunavailex. MESSAGE 'Service unavailable.' TYPE 'E'. ENDTRY.-
For API details, see StartQuery in AWS SDK for SAP ABAP API reference.
-