logs

put/api/projects/{project_id}/logs/metric_rules/{id}/

Request

  • Base URL: https://us.posthog.com
  • URL: https://us.posthog.com/api/projects/{project_id}/logs/metric_rules/{id}/
  • Auth: HTTP bearer

Path parameters

idstring uuid required

A UUID string identifying this logs metric rule.

project_idstring required

Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.

Request body

idstring uuid required

Unique identifier for this metric rule.

namestring required

User-visible label for this rule.

metric_namestring required

Name of the generated metric as it appears in the Metrics product. Must start with a letter and contain only letters, digits, dots, underscores, and dashes. Unique per project and immutable after creation — create a new rule to emit under a different name.

enabledboolean

When true, ingestion evaluates this rule against every log record. At most 10 rules can be enabled per project.

filter_groupunknown
value_attributestring nullable

Attribute key holding a numeric value to aggregate into a distribution (count + sum), e.g. attributes.duration_ms or resource_attributes.batch.size, prefixed with attributes. / resource_attributes.. For source=spans rules, the span pseudo-key duration_ms (span wall-clock duration) is also allowed. Omit to count matching records instead. Immutable after creation — it determines the emitted metric type.

group_bystring[]

Up to 5 dimension keys; each distinct value combination becomes its own metric series. For source=logs rules allowed: service_name, severity_text, event_name; for source=spans rules allowed: service_name, name, status_code, kind; for either, map keys prefixed with attributes. / resource_attributes.. Avoid high-cardinality keys (user IDs, request IDs) — excess series are dropped at ingestion. For source=spans rules, note that name is high-cardinality on poorly instrumented services (route params or SQL fragments in the span name), so grouping by name can overflow the per-rule series cap on its own.

source'logs' | 'spans'
  • logs - Logs
  • spans - Spans
versioninteger required

Incremented on each update for worker cache coherency.

created_byinteger required
created_atstring date-time required
updated_atstring date-time nullable required

Response

idstring uuid required

Unique identifier for this metric rule.

namestring required

User-visible label for this rule.

metric_namestring required

Name of the generated metric as it appears in the Metrics product. Must start with a letter and contain only letters, digits, dots, underscores, and dashes. Unique per project and immutable after creation — create a new rule to emit under a different name.

enabledboolean

When true, ingestion evaluates this rule against every log record. At most 10 rules can be enabled per project.

filter_groupunknown
value_attributestring nullable

Attribute key holding a numeric value to aggregate into a distribution (count + sum), e.g. attributes.duration_ms or resource_attributes.batch.size, prefixed with attributes. / resource_attributes.. For source=spans rules, the span pseudo-key duration_ms (span wall-clock duration) is also allowed. Omit to count matching records instead. Immutable after creation — it determines the emitted metric type.

group_bystring[]

Up to 5 dimension keys; each distinct value combination becomes its own metric series. For source=logs rules allowed: service_name, severity_text, event_name; for source=spans rules allowed: service_name, name, status_code, kind; for either, map keys prefixed with attributes. / resource_attributes.. Avoid high-cardinality keys (user IDs, request IDs) — excess series are dropped at ingestion. For source=spans rules, note that name is high-cardinality on poorly instrumented services (route params or SQL fragments in the span name), so grouping by name can overflow the per-rule series cap on its own.

source'logs' | 'spans'
  • logs - Logs
  • spans - Spans
versioninteger required

Incremented on each update for worker cache coherency.

created_byinteger required
created_atstring date-time required
updated_atstring date-time nullable required

Changes

No recorded changes to this operation across all 1 revision of this API.