Logs-4

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

Endpoints

DELETE
POST
POST
POST
POST
GET
GET
POST
GET
PATCH
DELETE

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 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

Also available via the PostHog MCP server:

  • logs-services-createList services with stats

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
}
}

Create logs sparkline

Required API key scopes

logs:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_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/projects/:project_id/logs/sparkline/\
-d query=undefined

Example response

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

Retrieve logs values

Required API key scopes

logs:read

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/projects/:project_id/logs/values
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/values/

Example response

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

List all logs views

Required API key scopes

logs:read

Query parameters

  • limit
    integer
  • offset
    integer

Response


Example request

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

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",
"short_id": "string",
"name": "string",
"filters": {},
"pinned": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"updated_at": "2019-08-24T14:15:22Z"
}
]
}

Create logs views

Required API key scopes

logs:write

Request parameters

  • name
    string
  • filters
    object
  • pinned
    boolean

Response


Example request

POST /api/projects/:project_id/logs/views
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/views/\
-d name="string"

Example response

Status 201
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"short_id": "string",
"name": "string",
"filters": {},
"pinned": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"updated_at": "2019-08-24T14:15:22Z"
}

Retrieve logs views

Required API key scopes

logs:read

Path parameters

  • short_id
    string

Response


Example request

GET /api/projects/:project_id/logs/views/:short_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/views/:short_id/

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"short_id": "string",
"name": "string",
"filters": {},
"pinned": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"updated_at": "2019-08-24T14:15:22Z"
}

Update logs views

Required API key scopes

logs:write

Path parameters

  • short_id
    string

Request parameters

  • name
    string
  • filters
    object
  • pinned
    boolean

Response


Example request

PATCH /api/projects/:project_id/logs/views/:short_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/views/:short_id/\
-d name="string"

Example response

Status 200
RESPONSE
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"short_id": "string",
"name": "string",
"filters": {},
"pinned": true,
"created_at": "2019-08-24T14:15:22Z",
"created_by": {
"id": 0,
"uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f",
"distinct_id": "string",
"first_name": "string",
"last_name": "string",
"email": "user@example.com",
"is_email_verified": true,
"hedgehog_config": {},
"role_at_organization": "engineering"
},
"updated_at": "2019-08-24T14:15:22Z"
}

Delete logs views

Required API key scopes

logs:write

Path parameters

  • short_id
    string

Example request

DELETE /api/projects/:project_id/logs/views/:short_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/views/:short_id/

Example response

Status 204 No response body

Community questions

Questions about this page? or post a community question.