Skip to main content
Monitoring & Collection/Logging
POSTLoggingSince 1.0SynchronousAuth Required

GetLogContext

Retrieve surrounding log lines before and after a specific log entry

Execution Availability

Try It Out

Submit a mock request using the current auth context and example-driven inputs.

Request Inputs

Body Fields

  • logIdStringRequired

    Unique identifier of the target log entry to retrieve context for

    Example: logline-0042

  • sourceStringRequired

    Log source identifier that contains the target log entry

    Example: /var/log/app/service.log

  • beforeIntegerRequired

    Number of log lines to return before the target log entry

    Example: 10

  • afterIntegerRequired

    Number of log lines to return after the target log entry

    Example: 10

Responses

200 OK

On success, this API returns the following response structure.

  • targetObject

    Target for this resource

    • idString

      Unique identifier of this log line

      Example: logline-0042

    • timestampString

      Timestamp for this resource

      Example: 2026-01-15T08:00:00Z

    • levelString

      Severity level of this log line

      Example: error

    • sourceString

      Log source path or stream identifier

      Example: /var/log/app/service.log

    • messageString

      Human-readable log message content

      Example: NullPointerException in OrderProcessor

    • hostString

      Hostname of the machine that emitted this log line

      Example: node-01.prod

    • fieldsLinkedHashMap

      Field list to include in the response

      Example: (nested object)

  • beforeList

    Before for this resource

    Example: (nested array)

    • idString

      Unique identifier of this log line

      Example: logline-0042

    • timestampString

      Timestamp for this resource

      Example: 2026-01-15T08:00:00Z

    • levelString

      Severity level of this log line

      Example: error

    • sourceString

      Log source path or stream identifier

      Example: /var/log/app/service.log

    • messageString

      Human-readable log message content

      Example: NullPointerException in OrderProcessor

    • hostString

      Hostname of the machine that emitted this log line

      Example: node-01.prod

    • fieldsLinkedHashMap

      Field list to include in the response

      Example: (nested object)

  • afterList

    After for this resource

    Example: (nested array)

    • idString

      Unique identifier of this log line

      Example: logline-0042

    • timestampString

      Timestamp for this resource

      Example: 2026-01-15T08:00:00Z

    • levelString

      Severity level of this log line

      Example: error

    • sourceString

      Log source path or stream identifier

      Example: /var/log/app/service.log

    • messageString

      Human-readable log message content

      Example: NullPointerException in OrderProcessor

    • hostString

      Hostname of the machine that emitted this log line

      Example: node-01.prod

    • fieldsLinkedHashMap

      Field list to include in the response

      Example: (nested object)

  • totalLinesInteger

    Total number of lines returned including before, target, and after

    Example: 21

  • hasMoreBoolean

    Whether additional context lines exist beyond the requested range

    Example: false

Endpoint

POST/api/v1/logs/context

/api/v1/logs/context

Operation ID

GetLogContext

Permalink

Request Example

curl -X POST '{host}/api/v1/logs/context' -H 'Authorization: Bearer {token}' -H 'Content-Type: application/json' -d '{"logId":"logline-0042","source":"/var/log/app/service.log","before":10,"after":10}'

Response Example

200
{
  "target": {},
  "before": [
    {}
  ],
  "after": [
    {}
  ],
  "totalLines": 21,
  "hasMore": false
}

Change History

This API has no change history records yet.

View all change history