Host logs API v1 - GET log content
Gets the content of the specified log.
The log content can be retrieved using this call only when logAnalysisStatus equals READY
in the job status call.
The request produces an application/json
payload.
GET | ManagedDynatrace for Government | https://{your-domain}/e/{your-environment-id}/api/v1/entity/infrastructure/hosts/{hostId}/logs/jobs/{jobId}/records |
SaaS | https://{your-environment-id}.live.dynatrace.com/api/v1/entity/infrastructure/hosts/{hostId}/logs/jobs/{jobId}/records | |
Environment ActiveGate | https://{your-activegate-domain}:9999/e/{your-environment-id}/api/v1/entity/infrastructure/hosts/{hostId}/logs/jobs/{jobId}/records |
Authentication
To execute this request, you need an access token with LogExport
scope.
To learn how to obtain and use it, see Tokens and authentication.
Parameters
Parameter | Type | Description | In | Required |
---|---|---|---|---|
hostId | string | The Dynatrace entity ID of the required host. | path | required |
jobId | string | The ID of the required log analysis job. You can retrieve it from the response of the POST analysis job request. | path | required |
scrollToken | string | The scrollToken value from the previous response. You can use it to get the next page of results. Without it, the first page is always returned. | query | optional |
pageSize | integer | The number of records per result page. If not set, each page contains 100 results. Maximum allowed value is | query | optional |
Response
When scrolling through the result records using a scroll token, the last result page contains an empty records array and no scrollToken field.
Response codes
Code | Type | Description |
---|---|---|
200 | LogJobRecordsResult | Success |
400 | ErrorEnvelope | Failed. See the response body for details |
Response body objects
The LogJobRecordsResult
object
The results of the log analysis job.
Element | Type | Description |
---|---|---|
records | LogRecord[] | The list of log analysis results. The last page contains empty list. |
scrollToken | string | The scroll token for the next page of results. Without it you'll get the first page again. |
The LogRecord
object
The analysis result for a single log entry.
Element | Type | Description |
---|---|---|
customFields | object | The map of the log entry custom fields. |
hostId | string | The entity ID of the host that produced the log. Not applicable to OS logs. |
logLevel | string | The severity level of the log entry. |
text | string | The text of the log entry. |
timestamp | integer | The timestamp of the log entry, in UTC milliseconds. |
Response body JSON model
1{2 "records": [3 {4 "customFields": {},5 "hostId": "string",6 "logLevel": "string",7 "text": "string",8 "timestamp": 19 }10 ],11 "scrollToken": "string"12}
Example
In this example the request lists the content of the OS log from the HOST-FE05D86A03025CAA host, which has been processed by the job with ID 32502e45-ed3d-47b9-b150-23e787ee285e.
The API token is passed in the Authorization header.
The response contains OS logs of this host. The result is truncated to three entries.
Curl
1curl -X GET \2 https://mySampleEnv.live.dynatrace.com/api/v1/entity/infrastructure/hosts/HOST-FE05D86A03025CAA/logs/jobs/32502e45-ed3d-47b9-b150-23e787ee285e/records \3 -H 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890'
Request URL
1https://mySampleEnv.live.dynatrace.com/api/v1/entity/infrastructure/hosts/HOST-FE05D86A03025CAA/logs/jobs/32502e45-ed3d-47b9-b150-23e787ee285e/records
Response content
1{2 "records": [3 {4 "timestamp": 1537954219052,5 "logLevel": "INFO",6 "text": "2018/09/26 09:30:19 UTC\tInformation\tClassic\t\t11707\t\tSYSTEM\tInfo\tProduct: Dynatrace Updater -- Installation completed successfully.",7 "customFields": {}8 },9 {10 "timestamp": 1537954219052,11 "logLevel": "INFO",12 "text": "2018/09/26 09:30:19 UTC\tInformation\tClassic\t\t1033\t\tSYSTEM\tInfo\tWindows Installer installed the product. Product Name: Dynatrace Updater. Product Version: 1.156.0. Product Language: 1033. Manufacturer: Dynatrace. Installation success or error status: 0.",13 "customFields": {}14 },15 {16 "timestamp": 1537954219052,17 "logLevel": "INFO",18 "text": "2018/09/26 09:30:19 UTC\tInformation\tClassic\t\t11707\t\tSYSTEM\tInfo\tProduct: Dynatrace Updater -- Installation completed successfully.",19 "customFields": {}20 }21 ]22}
Response code
200