Logs-2

For instructions on how to authenticate to use this endpoint, see API overview.

Endpoints

POST
GET
POST
POST
POST
GET
POST
POST
POST
GET

Create environments logs alerts simulate

Simulate a logs alert on historical data using the full state machine. Read-only — no alert check records are created.

Path parameters

  • environment_id
    string

Request parameters

  • filters
  • threshold_count
    integer
  • threshold_operator
  • window_minutes
    integer
  • evaluation_periods
    integer
    Default: 1
  • datapoints_to_alarm
    integer
    Default: 1
  • cooldown_minutes
    integer
    Default: 0
  • date_from
    string

Response


Example request

POST /api/environments/:environment_id/logs/alerts/simulate
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/alerts/simulate/\
-d filters=undefined,\
-d threshold_count="integer",\
-d threshold_operator=undefined,\
-d window_minutes="integer",\
-d date_from="string"

Example response

Status 200
RESPONSE
{
"buckets": [
{
"timestamp": "2019-08-24T14:15:22Z",
"count": 0,
"threshold_breached": true,
"state": "string",
"notification": "string",
"reason": "string"
}
],
"fire_count": 0,
"resolve_count": 0,
"total_buckets": 0,
"threshold_count": 0,
"threshold_operator": "string"
}

Create environments logs alerts simulate

Simulate a logs alert on historical data using the full state machine. Read-only — no alert check records are created.

Path parameters

  • environment_id
    string

Request parameters

  • filters
  • threshold_count
    integer
  • threshold_operator
  • window_minutes
    integer
  • evaluation_periods
    integer
    Default: 1
  • datapoints_to_alarm
    integer
    Default: 1
  • cooldown_minutes
    integer
    Default: 0
  • date_from
    string

Response


Example request

POST /api/environments/:environment_id/logs/alerts/simulate
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/alerts/simulate/\
-d filters=undefined,\
-d threshold_count="integer",\
-d threshold_operator=undefined,\
-d window_minutes="integer",\
-d date_from="string"

Example response

Status 200
RESPONSE
{
"buckets": [
{
"timestamp": "2019-08-24T14:15:22Z",
"count": 0,
"threshold_breached": true,
"state": "string",
"notification": "string",
"reason": "string"
}
],
"fire_count": 0,
"resolve_count": 0,
"total_buckets": 0,
"threshold_count": 0,
"threshold_operator": "string"
}

Retrieve environments logs attributes

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Query parameters

  • attribute_type
    string
    One of: "log""resource"
  • dateRange
  • filterGroup
    Click to open
    array
    Default:
  • limit
    integer
  • offset
    integer
  • search
    string
  • search_values
    boolean
    Default: false
  • serviceNames
    array
    Default:

Response


Example request

GET /api/environments/:environment_id/logs/attributes
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/attributes/

Example response

Status 200
RESPONSE
{
"results": [
{
"name": "string",
"propertyFilterType": "string",
"matchedOn": "key",
"matchedValue": "string"
}
],
"count": 0
}

Retrieve environments logs attributes

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Query parameters

  • attribute_type
    string
    One of: "log""resource"
  • dateRange
  • filterGroup
    Click to open
    array
    Default:
  • limit
    integer
  • offset
    integer
  • search
    string
  • search_values
    boolean
    Default: false
  • serviceNames
    array
    Default:

Response


Example request

GET /api/environments/:environment_id/logs/attributes
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/attributes/

Example response

Status 200
RESPONSE
{
"results": [
{
"name": "string",
"propertyFilterType": "string",
"matchedOn": "key",
"matchedValue": "string"
}
],
"count": 0
}

Create environments logs count

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/logs/count
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/count/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"count": 0
}

Create environments logs count

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/logs/count
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/count/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"count": 0
}

Create environments logs count ranges

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/logs/count-ranges
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/count-ranges/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"ranges": [
{
"date_from": "string",
"date_to": "string",
"count": 0
}
],
"interval": "string"
}

Create environments logs count ranges

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/logs/count-ranges
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/count-ranges/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"ranges": [
{
"date_from": "string",
"date_to": "string",
"count": 0
}
],
"interval": "string"
}

Create environments logs export

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Example request

POST /api/environments/:environment_id/logs/export
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/export/

Example response

Status 201

Create environments logs export

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Example request

POST /api/environments/:environment_id/logs/export
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/export/

Example response

Status 201

Retrieve environments logs has logs

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Example request

GET /api/environments/:environment_id/logs/has_logs
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/has_logs/

Example response

Status 200

Retrieve environments logs has logs

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Example request

GET /api/environments/:environment_id/logs/has_logs
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/has_logs/

Example response

Status 200

Create environments logs query

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/logs/query
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/query/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"query": {},
"results": [
{
"uuid": "string",
"timestamp": "string",
"observed_timestamp": "string",
"body": "string",
"severity_text": "string",
"severity_number": 0,
"level": "string",
"trace_id": "string",
"span_id": "string",
"trace_flags": 0,
"attributes": {
"property1": "string",
"property2": "string"
},
"resource_attributes": {
"property1": "string",
"property2": "string"
},
"event_name": "string"
}
],
"hasMore": true,
"nextCursor": "string",
"maxExportableLogs": 0
}

Create environments logs query

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/logs/query
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/query/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"query": {},
"results": [
{
"uuid": "string",
"timestamp": "string",
"observed_timestamp": "string",
"body": "string",
"severity_text": "string",
"severity_number": 0,
"level": "string",
"trace_id": "string",
"span_id": "string",
"trace_flags": 0,
"attributes": {
"property1": "string",
"property2": "string"
},
"resource_attributes": {
"property1": "string",
"property2": "string"
},
"event_name": "string"
}
],
"hasMore": true,
"nextCursor": "string",
"maxExportableLogs": 0
}

Create environments logs services

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/logs/services
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/services/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"services": [
{
"service_name": "string",
"log_count": 0,
"error_count": 0,
"error_rate": 0.1
}
],
"sparkline": [
{
"time": "string",
"service_name": "string",
"count": 0
}
]
}

Create environments logs services

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/logs/services
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/services/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"services": [
{
"service_name": "string",
"log_count": 0,
"error_count": 0,
"error_rate": 0.1
}
],
"sparkline": [
{
"time": "string",
"service_name": "string",
"count": 0
}
]
}

Create environments logs sparkline

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/logs/sparkline
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/sparkline/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"results": [
{
"time": "string",
"severity": "string",
"service": "string",
"count": 0
}
]
}

Create environments logs sparkline

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/logs/sparkline
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl
-H 'Content-Type: application/json'\
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/sparkline/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"results": [
{
"time": "string",
"severity": "string",
"service": "string",
"count": 0
}
]
}

Retrieve environments logs values

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Query parameters

  • attribute_type
    string
    One of: "log""resource"
  • dateRange
  • filterGroup
    Click to open
    array
    Default:
  • key
    string
  • serviceNames
    array
    Default:
  • value
    string

Response


Example request

GET /api/environments/:environment_id/logs/values
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/values/

Example response

Status 200
RESPONSE
{
"results": [
{
"id": "string",
"name": "string"
}
],
"refreshing": true
}

Retrieve environments logs values

Required API key scopes

logs:read

Path parameters

  • environment_id
    string

Query parameters

  • attribute_type
    string
    One of: "log""resource"
  • dateRange
  • filterGroup
    Click to open
    array
    Default:
  • key
    string
  • serviceNames
    array
    Default:
  • value
    string

Response


Example request

GET /api/environments/:environment_id/logs/values
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/environments/:environment_id/logs/values/

Example response

Status 200
RESPONSE
{
"results": [
{
"id": "string",
"name": "string"
}
],
"refreshing": true
}
Next page →

Community questions

Questions about this page? or post a community question.