Skip to content

Latest commit

 

History

History
457 lines (304 loc) · 35.1 KB

File metadata and controls

457 lines (304 loc) · 35.1 KB

Logs

Overview

Available Operations

aggregate

Return severity counts grouped by time buckets at a configurable grain (auto, minute, hour, day).

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.logs.aggregate()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
from_ date ➖ N/A
to date ➖ N/A
grain Optional[str] ➖ Time bucket grain: "auto" | "minute" | "hour" | "day". "auto" picks the
grain from the requested time range. Empty returns rows without time
buckets.
filters List[models.TraceFilter] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.AggregateLogsResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

list_facets

Return the facet hierarchy: attribute families (native, attribute, resource, scope) with their keys, counts, and top values. Accepts optional filters and free-text query to narrow the counted subset.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.logs.list_facets()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
from_ date ➖ N/A
to date ➖ N/A
key_limit Optional[int] ➖ N/A
value_limit Optional[int] ➖ N/A
query Optional[str] ➖ N/A
filter_operator Optional[str] ➖ N/A
filters List[models.TraceFilter] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListLogFacetsResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

list_facet_values

Return distinct values with occurrence counts for a given facet field.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.logs.list_facet_values(field="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
field str ✔️ N/A
limit Optional[int] ➖ N/A
from_ date ➖ N/A
to date ➖ N/A
search Optional[str] ➖ Optional case-insensitive substring search over facet values.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListLogFacetValuesResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

list_fields

Return all queryable fields: static columns and dynamic attribute families (attribute., resource.).

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.logs.list_fields()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListLogFieldsResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

find_patterns

Find stable templates in a bounded sample of matching log bodies. The response reports sampling and truncation metadata and never returns an unbounded list of raw bodies.

Example Usage

from orq_ai_sdk import Orq
from orq_ai_sdk.utils import parse_datetime
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.logs.find_patterns(from_=parse_datetime("2025-09-21T07:55:29.692Z"), to=parse_datetime("2024-10-05T00:49:57.596Z"))

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
from_ date ✔️ N/A
to date ✔️ N/A
query Optional[str] ➖ N/A
filter_operator Optional[str] ➖ N/A
filters List[models.TraceFilter] ➖ N/A
limit Optional[int] ➖ Maximum patterns to return. Defaults to 50.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.FindLogPatternsResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

query

Run an OQL log query using the pipeline grammar fetch logs | filter <expr> | sort timestamp desc | limit N. The query is compiled onto the same engine as SearchLogs; timestamp desc is the only supported sort.

Example Usage

from orq_ai_sdk import Orq
from orq_ai_sdk.utils import parse_datetime
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.logs.query(oql="<value>", from_=parse_datetime("2026-04-01T20:23:07.108Z"), to=parse_datetime("2025-08-17T16:51:30.424Z"))

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
oql str ✔️ OQL query string, e.g.
fetch logs | filter severity_number > 10 | filter body contains "error".
from_ date ✔️ N/A
to date ✔️ N/A
limit Optional[int] ➖ Maximum rows to return; a | limit N pipeline command takes precedence.
page_token Optional[str] ➖ Opaque cursor for pagination.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.QueryLogsResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

search

Query log records with filters, free-text search, and keyset pagination. Results are ordered timestamp desc (the only supported sort, mirroring traces).

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.logs.search()

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
from_ date ➖ N/A
to date ➖ N/A
query Optional[str] ➖ Free-text query matched against the body field (case-insensitive).
filter_operator Optional[str] ➖ How to combine multiple filters: "and" (default) or "or", mirroring
the traces filter_operator.
filters List[models.TraceFilter] ➖ N/A
sort List[models.TraceSort] ➖ N/A
limit Optional[int] ➖ Maximum rows to return. Defaults to 100 and is capped at 1000.
page_token Optional[str] ➖ Opaque cursor for pagination; empty or absent means the first page.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.SearchLogsResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

get

Retrieve a log record by its ULID. Returns 404 if the record does not exist or belongs to another workspace.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.logs.get(id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetLogResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

context

Retrieve the matching log records immediately before and after an anchor log. Neighbors use the same free-text and structured filter dialect as SearchLogs and are returned in chronological order.

Example Usage

from orq_ai_sdk import Orq
from orq_ai_sdk.utils import parse_datetime
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.logs.context(id="<id>", from_=parse_datetime("2025-10-13T07:44:36.992Z"), to=parse_datetime("2025-04-02T17:30:56.013Z"))

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
id str ✔️ N/A
from_ date ✔️ N/A
to date ✔️ N/A
query Optional[str] ➖ N/A
filter_operator Optional[str] ➖ N/A
filters List[models.TraceFilter] ➖ N/A
before Optional[int] ➖ Number of matching records earlier than the anchor. Defaults to 10.
after Optional[int] ➖ Number of matching records later than the anchor. Defaults to 10.
oql Optional[str] ➖ Optional OQL pipeline. It cannot be combined with query or filters.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.GetLogContextResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

list_trace_logs

Return all log records correlated with a given trace_id. Results are scoped to the authenticated workspace.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.logs.list_trace_logs(trace_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
trace_id str ✔️ N/A
limit Optional[int] ➖ N/A
page_token Optional[str] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListTraceLogsResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*