Logs-6

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

Endpoints

GET
POST
GET
POST
GET
PATCH
DELETE
POST
POST
POST

Retrieve logs has logs

Required API key scopes

logs:read

Example request

GET /api/projects/:project_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/projects/:project_id/logs/has_logs/

Example response

Status 200

Create logs query

Required API key scopes

logs:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_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/projects/:project_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 logs query

Required API key scopes

logs:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_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/projects/:project_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
}

List all logs sampling rules

Required API key scopes

logs:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

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

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"rule_type": "severity_sampling",
"scope_service": "string",
"scope_path_pattern": "string",
"scope_attribute_filters": [
{}
],
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}
]
}

List all logs sampling rules

Required API key scopes

logs:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

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

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"rule_type": "severity_sampling",
"scope_service": "string",
"scope_path_pattern": "string",
"scope_attribute_filters": [
{}
],
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}
]
}

Create logs sampling rules

Required API key scopes

logs:write

Request parameters

  • name
    string
  • enabled
    boolean
    Default: false
  • priority
    integernull
  • rule_type
  • scope_service
    stringnull
  • scope_path_pattern
    stringnull
  • scope_attribute_filters
    array
  • config

Response


Example request

POST /api/projects/:project_id/logs/sampling_rules
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/projects/:project_id/logs/sampling_rules/\
-d name="string",\
-d rule_type=undefined,\
-d config=undefined

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"rule_type": "severity_sampling",
"scope_service": "string",
"scope_path_pattern": "string",
"scope_attribute_filters": [
{}
],
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Create logs sampling rules

Required API key scopes

logs:write

Request parameters

  • name
    string
  • enabled
    boolean
    Default: false
  • priority
    integernull
  • rule_type
  • scope_service
    stringnull
  • scope_path_pattern
    stringnull
  • scope_attribute_filters
    array
  • config

Response


Example request

POST /api/projects/:project_id/logs/sampling_rules
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/projects/:project_id/logs/sampling_rules/\
-d name="string",\
-d rule_type=undefined,\
-d config=undefined

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"rule_type": "severity_sampling",
"scope_service": "string",
"scope_path_pattern": "string",
"scope_attribute_filters": [
{}
],
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Retrieve logs sampling rules

Required API key scopes

logs:read

Path parameters

  • id
    string

Response


Example request

GET /api/projects/:project_id/logs/sampling_rules/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/logs/sampling_rules/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"rule_type": "severity_sampling",
"scope_service": "string",
"scope_path_pattern": "string",
"scope_attribute_filters": [
{}
],
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Retrieve logs sampling rules

Required API key scopes

logs:read

Path parameters

  • id
    string

Response


Example request

GET /api/projects/:project_id/logs/sampling_rules/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/logs/sampling_rules/:id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"rule_type": "severity_sampling",
"scope_service": "string",
"scope_path_pattern": "string",
"scope_attribute_filters": [
{}
],
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Update logs sampling rules

Required API key scopes

logs:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • enabled
    boolean
    Default: false
  • priority
    integernull
  • rule_type
  • scope_service
    stringnull
  • scope_path_pattern
    stringnull
  • scope_attribute_filters
    array
  • config

Response


Example request

PATCH /api/projects/:project_id/logs/sampling_rules/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/logs/sampling_rules/:id/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"rule_type": "severity_sampling",
"scope_service": "string",
"scope_path_pattern": "string",
"scope_attribute_filters": [
{}
],
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Update logs sampling rules

Required API key scopes

logs:write

Path parameters

  • id
    string

Request parameters

  • name
    string
  • enabled
    boolean
    Default: false
  • priority
    integernull
  • rule_type
  • scope_service
    stringnull
  • scope_path_pattern
    stringnull
  • scope_attribute_filters
    array
  • config

Response


Example request

PATCH /api/projects/:project_id/logs/sampling_rules/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X PATCH \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/logs/sampling_rules/:id/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"rule_type": "severity_sampling",
"scope_service": "string",
"scope_path_pattern": "string",
"scope_attribute_filters": [
{}
],
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}

Delete logs sampling rules

Required API key scopes

logs:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/logs/sampling_rules/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/logs/sampling_rules/:id/

Example response

Status 204 No response body

Delete logs sampling rules

Required API key scopes

logs:write

Path parameters

  • id
    string

Example request

DELETE /api/projects/:project_id/logs/sampling_rules/:id
export POSTHOG_PERSONAL_API_KEY=[your personal api key]
curl -X DELETE \
-H "Authorization: Bearer $POSTHOG_PERSONAL_API_KEY" \
<ph_app_host>/api/projects/:project_id/logs/sampling_rules/:id/

Example response

Status 204 No response body

Create logs sampling rules simulate

Dry-run estimate for how much volume this rule would remove (placeholder response until CH-backed simulation is wired).

Path parameters

  • id
    string

Response


Example request

POST /api/projects/:project_id/logs/sampling_rules/:id/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/projects/:project_id/logs/sampling_rules/:id/simulate/

Example response

Status 200
RESPONSE
{
"estimated_reduction_pct": 0.1,
"notes": "string"
}

Create logs sampling rules simulate

Dry-run estimate for how much volume this rule would remove (placeholder response until CH-backed simulation is wired).

Path parameters

  • id
    string

Response


Example request

POST /api/projects/:project_id/logs/sampling_rules/:id/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/projects/:project_id/logs/sampling_rules/:id/simulate/

Example response

Status 200
RESPONSE
{
"estimated_reduction_pct": 0.1,
"notes": "string"
}

Create logs sampling rules reorder

Atomically reassign priorities so the given ID order maps to ascending priorities (0..n-1).

Query parameters

  • limit
    integer
  • offset
    integer

Request parameters

  • ordered_ids
    array

Response


Example request

POST /api/projects/:project_id/logs/sampling_rules/reorder
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/projects/:project_id/logs/sampling_rules/reorder/\
-d ordered_ids="array"

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"rule_type": "severity_sampling",
"scope_service": "string",
"scope_path_pattern": "string",
"scope_attribute_filters": [
{}
],
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}
]
}

Create logs sampling rules reorder

Atomically reassign priorities so the given ID order maps to ascending priorities (0..n-1).

Query parameters

  • limit
    integer
  • offset
    integer

Request parameters

  • ordered_ids
    array

Response


Example request

POST /api/projects/:project_id/logs/sampling_rules/reorder
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/projects/:project_id/logs/sampling_rules/reorder/\
-d ordered_ids="array"

Example response

Status 200
RESPONSE
{
"count": 123,
"next": "http://api.example.org/accounts/?offset=400&limit=100",
"previous": "http://api.example.org/accounts/?offset=200&limit=100",
"results": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"enabled": false,
"priority": 0,
"rule_type": "severity_sampling",
"scope_service": "string",
"scope_path_pattern": "string",
"scope_attribute_filters": [
{}
],
"config": null,
"version": 0,
"created_by": 0,
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z"
}
]
}

Create logs services

Required API key scopes

logs:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_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/projects/:project_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,
"volume_share_pct": 0.1,
"severity_breakdown": {
"debug": 0,
"info": 0,
"warn": 0,
"error": 0
},
"active_rules": [
{
"rule_id": "728c1541-d6d1-4290-9a53-cdf01dd32d60",
"rule_name": "string",
"summary_string": "string"
}
]
}
],
"sparkline": [
{
"time": "string",
"service_name": "string",
"count": 0
}
],
"summary": {
"top_services_count": 0,
"top_services_volume_share_pct": 0.1
}
}

Community questions

Questions about this page? or post a community question.