Host logs API v1 - POST analysis job
Starts the log analysis job.
Optionally, you can indicate a start and end timestamp or query to filter log content.
The request produces an application/json
payload.
POST | ManagedDynatrace for Government | https://{your-domain}/e/{your-environment-id}/api/v1/entity/infrastructure/hosts/{hostId}/logs/{logPath} |
SaaS | https://{your-environment-id}.live.dynatrace.com/api/v1/entity/infrastructure/hosts/{hostId}/logs/{logPath} | |
Environment ActiveGate | https://{your-activegate-domain}:9999/e/{your-environment-id}/api/v1/entity/infrastructure/hosts/{hostId}/logs/{logPath} |
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
All special characters in the log path must be escaped.
Parameter | Type | Description | In | Required |
---|---|---|---|---|
hostId | string | The Dynatrace entity ID of the required host. | path | required |
logPath | string | The full pathname of the log. | path | required |
query | string | Narrows down the scope of the analysis to the entries, matching the specified criteria. The criteria must use the text pattern query syntax. | query | optional |
startTimestamp | integer | The start timestamp of the analysis range, in UTC milliseconds. If not set, then 2 hours behind from current timestamp is used. | query | optional |
endTimestamp | integer | The end timestamp of the analysis range, in UTC milliseconds. If not set, then the current timestamp is used. | query | optional |
body | ExtractFields | Extract fields from the log content to form custom columns. See Search patterns in log data and parse results in Dynatrace Documentation for the syntax definition and examples. The special characters must be escaped. | body | optional |
Request body objects
The ExtractFields
object
A query to extract log content to a custom column.
Element | Type | Description | Required |
---|---|---|---|
customParsingPatterns | string | The query for content extraction. See Search patterns in log data and parse results in Dynatrace Documentation for the syntax definition and examples. | optional |
parsingMode | string | The parsing mode for log analysis entries presentation. Possible values are: | optional |
Request body JSON model
This is a model of the request body, showing the possible elements. It has to be adjusted for usage in an actual request.
1{2 "customParsingPatterns": "\"user %{STRING:User} logged\", \"job took %{INTEGER:Time} ms\"",3 "parsingMode": "json"4}
Response
Response codes
Code | Type | Description |
---|---|---|
202 | string | Success. The response body contains the ID of the job. |
400 | ErrorEnvelope | Failed. See the response body for details. |
404 | ErrorEnvelope | Not found. See the response body for details. |
Example
In this example the request starts a log analysis job for the Windows Application Log from the HOST-EA474F61FFBD5C97 host. The timeframe of analysis lies between timestamps 1537840000000 and 1537880000000.
The API token is passed in the Authorization header.
The response contains the ID of the started analysis job.
Curl
1curl -X POST \2 https://mySampleEnv.live.dynatrace.com/api/v1/entity/infrastructure/hosts/HOST-FE05D86A03025CAA/logs/Windows%20Application%20Log?startTimestamp=1537840000000&endTimestamp=1537880000000 \3 -H 'Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890' \
Request URL
1https://mySampleEnv.live.dynatrace.com/api/v1/entity/infrastructure/hosts/HOST-FE05D86A03025CAA/logs/Windows%20Application%20Log?startTimestamp=1537840000000&endTimestamp=1537880000000
Response content
1{2 "jobId": "32502e45-ed3d-47b9-b150-23e787ee285e"3}
Response code
202