download_datasource_entity_logs¶
- DatasourcesApi.download_datasource_entity_logs(datasource_id, entity_id, role_id, servicename, action, timestamp_range_with_next_token, filter_pattern=None, encoding=None, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)¶
View, generate, or download Streams entity logs
Retrieves CloudWatch logs for a Streams data transformation entity. The caller (identified by role_id) needs datasources.view and at least read-only access on the path datasource (else AUTH-1010). Use servicename=streams-entity. Actions: view-logs, generate-logs, download-logs. Body startTime and endTime are required (YYYY-MM-DDTHH:MM:SS UTC).
- Parameters:
datasource_id (str) – UUID of the datasource used for authorization. Rejected with AUTH-1010 if the user has no access. (required)
entity_id (str) – Entity UUID (EntityId). Rejected with IPV-1002 if not found. (required)
role_id (str) – Amorphic role ID. Must grant datasources.view. Missing role_id returns AUTH-1001. (required)
servicename (str) – Must be streams-entity for this path. (required)
action (str) – view-logs returns a preview page. generate-logs starts async generation and emails when ready. download-logs returns PresignedUrl when logs for the time window are ready. (required)
timestamp_range_with_next_token (TimestampRangeWithNextToken) – startTime and endTime required as YYYY-MM-DDTHH:MM:SS (UTC). Optional nextToken for view-logs pagination (last page when response omits nextToken). (required)
filter_pattern (str) – Optional CloudWatch Logs filter pattern for view-logs and generate-logs.
encoding (str) – Set to base64 when filter_pattern is base64-encoded. Otherwise omit.
_request_timeout (int, tuple(int, int), optional) – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.
_request_auth (dict, optional) – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.
_content_type (str, Optional) – force content-type for the request.
_headers (dict, optional) – set to override the headers for a single request; this effectively ignores the headers in the spec for a single request.
_host_index (int, optional) – set to override the host_index for a single request; this effectively ignores the host_index in the spec for a single request.
- Return type:
- Returns:
Returns the result object.
Request and Response Examples¶
HTTP: POST /datasources/{datasource_id}/entities/{entity_id}/logs
Request¶
startTime and endTime required as YYYY-MM-DDTHH:MM:SS (UTC). Optional nextToken for view-logs pagination (last page when response omits nextToken).
Required time window
{
"startTime": "2024-06-01T12:00:00",
"endTime": "2024-06-01T13:00:00"
}
view-logs with nextToken
{
"startTime": "2024-06-01T12:00:00",
"endTime": "2024-06-01T13:00:00",
"nextToken": "abc123"
}
Success (HTTP 200)¶
view-logs: logPreview, logTruncated, optional nextToken. generate-logs: Message. download-logs: Presignedurl when ready, or Message if generate-logs has not completed for that timeframe.
action=view-logs
{
"logPreview": "2024-06-01T12:00:01 INFO handler starting...",
"logTruncated": false
}
action=generate-logs
{
"Message": "Log generation started, an alert will be sent send to email after successful log retrieval"
}
action=download-logs when ready
{
"Presignedurl": "https://amorphic-logs.s3.amazonaws.com/streams-data-transformations-logs/...?X-Amz-Algorithm=..."
}
action=download-logs before generate completes
{
"Message": "Log file is not available to download for the given timeframe, please generate logs first."
}
Errors¶
Documented error codes: AUTH-1001, AUTH-1010, IPV-1001, IPV-1041, IPV-1002, IPV-1008, IPV-1054, LOG-1002, GE-1034, DB-1002, LOG-1007.
HTTP 400
Validation or authorization failure. Body is {“Message”: “<CODE> - <text>”}. Common codes: AUTH-1001 (missing role_id), AUTH-1010 (no datasource access), IPV-1001 (invalid/missing servicename), IPV-1041 (invalid action), IPV-1002 (entity not found), IPV-1008 (missing startTime/endTime), IPV-1054 (bad timestamp format), LOG-1002 (1970-01-01T00:00:00), GE-1034 (view-logs empty/unavailable window).
No datasource access
{
"Message": "AUTH-1010 - User user1 is not authorized to perform this operation"
}
Missing startTime/endTime
{
"Message": "IPV-1008 - Invalid request body, missing key(s) - startTime/endTime"
}
EntityId not found
{
"Message": "IPV-1002 - Invalid ResourceId - c3d8e4f2-9a6b-5c7d-0e1f-3a4b5c6d7e8f, resource not found."
}
HTTP 500
Backend failure. Body is {“Message”: “<CODE> - <text>”}. Common codes: DB-1002 (failed to mark generate-logs triggered), LOG-1007 (generic download failure).
Generic log download failure
{
"Message": "LOG-1007 - Unable to download log files, please try again later."
}