Metrics

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

Endpoints

POST
GET
POST
GET
POST
GET
POST
GET

Create environments metrics characterize

Characterize a metric anomaly: compare an anomaly window against a baseline, find the onset, and rank which label values moved.

Required API key scopes

metrics:read

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/metrics/characterize
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/metrics/characterize/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"metric_name": "string",
"aggregation": "string",
"interval": "string",
"baseline_from": "string",
"baseline_to": "string",
"anomaly_from": "string",
"anomaly_to": "string",
"baseline_mean": 0.1,
"baseline_stddev": 0.1,
"anomaly_mean": 0.1,
"anomaly_peak": 0.1,
"change_ratio": 0.1,
"direction": "up",
"onset_time": "string",
"top_movers": [
{
"key": "string",
"label": "string",
"baseline_value": 0.1,
"anomaly_value": 0.1,
"change_ratio": 0.1
}
],
"series": {
"labels": {
"property1": "string",
"property2": "string"
},
"points": [
{
"time": "string",
"value": 0.1
}
],
"metric_name": "string",
"clause": "string"
}
}

Create environments metrics characterize

Characterize a metric anomaly: compare an anomaly window against a baseline, find the onset, and rank which label values moved.

Required API key scopes

metrics:read

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/metrics/characterize
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/metrics/characterize/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"metric_name": "string",
"aggregation": "string",
"interval": "string",
"baseline_from": "string",
"baseline_to": "string",
"anomaly_from": "string",
"anomaly_to": "string",
"baseline_mean": 0.1,
"baseline_stddev": 0.1,
"anomaly_mean": 0.1,
"anomaly_peak": 0.1,
"change_ratio": 0.1,
"direction": "up",
"onset_time": "string",
"top_movers": [
{
"key": "string",
"label": "string",
"baseline_value": 0.1,
"anomaly_value": 0.1,
"change_ratio": 0.1
}
],
"series": {
"labels": {
"property1": "string",
"property2": "string"
},
"points": [
{
"time": "string",
"value": 0.1
}
],
"metric_name": "string",
"clause": "string"
}
}

Retrieve environments metrics has metrics

Required API key scopes

metrics:read

Example request

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

Example response

Status 200

Retrieve environments metrics has metrics

Required API key scopes

metrics:read

Example request

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

Example response

Status 200

Create environments metrics query

Required API key scopes

metrics:read

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/metrics/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/metrics/query/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"results": [
{
"labels": {
"property1": "string",
"property2": "string"
},
"points": [
{
"time": "string",
"value": 0.1
}
],
"metric_name": "string",
"clause": "string"
}
]
}

Create environments metrics query

Required API key scopes

metrics:read

Request parameters

  • query

Response


Example request

POST /api/environments/:environment_id/metrics/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/metrics/query/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"results": [
{
"labels": {
"property1": "string",
"property2": "string"
},
"points": [
{
"time": "string",
"value": 0.1
}
],
"metric_name": "string",
"clause": "string"
}
]
}

Retrieve environments metrics values

Distinct metric names for the team. Backs the picker UI.

Required API key scopes

metrics:read

Query parameters

  • limit
    integer
  • value
    string

Response


Example request

GET /api/environments/:environment_id/metrics/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/metrics/values/

Example response

Status 200
RESPONSE
{
"results": [
{
"name": "string",
"metric_type": "string"
}
]
}

Retrieve environments metrics values

Distinct metric names for the team. Backs the picker UI.

Required API key scopes

metrics:read

Query parameters

  • limit
    integer
  • value
    string

Response


Example request

GET /api/environments/:environment_id/metrics/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/metrics/values/

Example response

Status 200
RESPONSE
{
"results": [
{
"name": "string",
"metric_type": "string"
}
]
}

Create metrics characterize

Characterize a metric anomaly: compare an anomaly window against a baseline, find the onset, and rank which label values moved.

Required API key scopes

metrics:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_id/metrics/characterize
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/metrics/characterize/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"metric_name": "string",
"aggregation": "string",
"interval": "string",
"baseline_from": "string",
"baseline_to": "string",
"anomaly_from": "string",
"anomaly_to": "string",
"baseline_mean": 0.1,
"baseline_stddev": 0.1,
"anomaly_mean": 0.1,
"anomaly_peak": 0.1,
"change_ratio": 0.1,
"direction": "up",
"onset_time": "string",
"top_movers": [
{
"key": "string",
"label": "string",
"baseline_value": 0.1,
"anomaly_value": 0.1,
"change_ratio": 0.1
}
],
"series": {
"labels": {
"property1": "string",
"property2": "string"
},
"points": [
{
"time": "string",
"value": 0.1
}
],
"metric_name": "string",
"clause": "string"
}
}

Create metrics characterize

Characterize a metric anomaly: compare an anomaly window against a baseline, find the onset, and rank which label values moved.

Required API key scopes

metrics:read

Request parameters

  • query

Response


Example request

POST /api/projects/:project_id/metrics/characterize
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/metrics/characterize/\
-d query=undefined

Example response

Status 200
RESPONSE
{
"metric_name": "string",
"aggregation": "string",
"interval": "string",
"baseline_from": "string",
"baseline_to": "string",
"anomaly_from": "string",
"anomaly_to": "string",
"baseline_mean": 0.1,
"baseline_stddev": 0.1,
"anomaly_mean": 0.1,
"anomaly_peak": 0.1,
"change_ratio": 0.1,
"direction": "up",
"onset_time": "string",
"top_movers": [
{
"key": "string",
"label": "string",
"baseline_value": 0.1,
"anomaly_value": 0.1,
"change_ratio": 0.1
}
],
"series": {
"labels": {
"property1": "string",
"property2": "string"
},
"points": [
{
"time": "string",
"value": 0.1
}
],
"metric_name": "string",
"clause": "string"
}
}

Retrieve metrics has metrics

Required API key scopes

metrics:read

Example request

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

Example response

Status 200

Retrieve metrics has metrics

Required API key scopes

metrics:read

Example request

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

Example response

Status 200

Create metrics query

Required API key scopes

metrics:read

Request parameters

  • query

Response


Example request

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

Example response

Status 200
RESPONSE
{
"results": [
{
"labels": {
"property1": "string",
"property2": "string"
},
"points": [
{
"time": "string",
"value": 0.1
}
],
"metric_name": "string",
"clause": "string"
}
]
}

Create metrics query

Required API key scopes

metrics:read

Request parameters

  • query

Response


Example request

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

Example response

Status 200
RESPONSE
{
"results": [
{
"labels": {
"property1": "string",
"property2": "string"
},
"points": [
{
"time": "string",
"value": 0.1
}
],
"metric_name": "string",
"clause": "string"
}
]
}

Retrieve metrics values

Distinct metric names for the team. Backs the picker UI.

Required API key scopes

metrics:read

Query parameters

  • limit
    integer
  • value
    string

Response


Example request

GET /api/projects/:project_id/metrics/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/metrics/values/

Example response

Status 200
RESPONSE
{
"results": [
{
"name": "string",
"metric_type": "string"
}
]
}

Retrieve metrics values

Distinct metric names for the team. Backs the picker UI.

Required API key scopes

metrics:read

Query parameters

  • limit
    integer
  • value
    string

Response


Example request

GET /api/projects/:project_id/metrics/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/metrics/values/

Example response

Status 200
RESPONSE
{
"results": [
{
"name": "string",
"metric_type": "string"
}
]
}

Community questions

Questions about this page? or post a community question.