Log Monitoring API - GET search logs

Gets the log records matching the provided criteria. Matching log records are sorted by the criteria specified in the sort query parameter, and then the first X records (as specified by the limit query parameter) are returned. To run a query without a size limit, use the GET export logs request.

If the resulting log is too large, it is divided into slices. In such cases, the first response contains the nextSliceKey for the second slice. Use it in the nextSliceKey query parameter to obtain the second slice, which in turn contains the nextSliceKey for the third slice, and so on.

Results might be distributed unevenly between slices, and some slices might be empty.

The request produces an application/json payload.

This request is an Early Adopter release and may be changed in non-compatible way.

GETSaaShttps://{your-environment-id}.live.dynatrace.com/api/v2/logs/search
Environment ActiveGateCluster ActiveGatehttps://{your-activegate-domain}:9999/e/{your-environment-id}/api/v2/logs/search

Authentication

To execute this request, you need an access token with logs.read scope.

To learn how to obtain and use it, see Tokens and authentication.

Parameters

ParameterTypeDescriptionInRequired
fromstring

The start of the requested timeframe.

You can use one of the following formats:

  • Timestamp in UTC milliseconds.
  • Human-readable format of 2021-01-25T05:57:01.123+01:00. If no time zone is specified, UTC is used. You can use a space character instead of the T. Seconds and fractions of a second are optional.
  • Relative timeframe, back from now. The format is now-NU/A, where N is the amount of time, U is the unit of time, and A is an alignment. The alignment rounds all the smaller values to the nearest zero in the past. For example, now-1y/w is one year back, aligned by a week. You can also specify relative timeframe without an alignment: now-NU. Supported time units for the relative timeframe are:
    • m: minutes
    • h: hours
    • d: days
    • w: weeks
    • M: months
    • y: years

If not set, the relative timeframe of two weeks is used (now-2w).

queryoptional
tostring

The end of the requested timeframe.

You can use one of the following formats:

  • Timestamp in UTC milliseconds.
  • Human-readable format of 2021-01-25T05:57:01.123+01:00. If no time zone is specified, UTC is used. You can use a space character instead of the T. Seconds and fractions of a second are optional.
  • Relative timeframe, back from now. The format is now-NU/A, where N is the amount of time, U is the unit of time, and A is an alignment. The alignment rounds all the smaller values to the nearest zero in the past. For example, now-1y/w is one year back, aligned by a week. You can also specify relative timeframe without an alignment: now-NU. Supported time units for the relative timeframe are:
    • m: minutes
    • h: hours
    • d: days
    • w: weeks
    • M: months
    • y: years

If not set, the current timestamp is used.

queryoptional
limitinteger

The desired amount of log records.

The maximal allowed limit is 1000.

If not set, 1000 is used.

queryoptional
querystring

The log search query.

The query must use the Dynatrace search query language.

queryoptional
sortstring

Defines the ordering of the log records.

Each field has a sign prefix (+/-) for sorting order. If no sign prefix is set, then the + option will be applied.

Currently, ordering is available only for the timestamp (+timestamp for the oldest records first, or -timestamp for the newest records first).

When millisecond resolution provided by the timestamp is not enough, log records are sorted based on the order in which they appear in the log source (remote process writing to REST API endpoint or remote process from which logs are collected).

queryoptional
nextSliceKeystring

The cursor for the next slice of results. You can find it in the nextSliceKey field of the previous response.

The first slice is always returned if you don't specify this parameter.

If this parameter is set, all other query parameters are ignored.

Unsupported on Log Management and Analytics, powered by Grail.

queryoptional

Response

Response codes

CodeTypeDescription
200LogRecordsList

Success

400ErrorEnvelope

Failed. The input is invalid.

4XXErrorEnvelope

Client side error.

5XXErrorEnvelope

Server side error.

Response body objects

The LogRecordsList object

A list of retrieved log records.

ElementTypeDescription
nextSliceKeystring

The cursor for the next slice of log records. Always null on Log Management and Analytics, powered by Grail.

resultsLogRecord[]

A list of retrieved log records.

sliceSizeinteger

The total number of records in a slice.

warningsstring

Optional warning messages.

The LogRecord object

A single log record.

ElementTypeDescription
additionalColumnsobject

Additional columns of the log record.

contentstring

The content of the log record.

eventTypestring

Type of event

  • K8S
  • LOG
  • SFM
statusstring

The log status (based on the log level).

  • ERROR
  • INFO
  • NONE
  • NOT_APPLICABLE
  • WARN
timestampinteger

The timestamp of the log record, in UTC milliseconds.

Response body JSON model

{
"nextSliceKey": "___-2hI03q0AAAAAAAAAAAAAA-gAAAAAAAAH0P____8AAABkAAAACXRpbWVzdGFtcAD___7aEjTerQ",
"results": [
{
"additionalColumns": {
"custom.attribute": [
"value1",
"value2"
],
"loglevel": [
"SEVERE"
]
},
"content": "example log content",
"event.type": "LOG",
"status": "ERROR",
"timestamp": "1631193089000"
}
],
"sliceSize": 100
}