Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(logs): facet log-body attributes, not just resource attributes (#78775)

Jon McCallumd5bc1f3237a6
diff --git a/products/logs/backend/log_facet_values_query_runner.py b/products/logs/backend/log_facet_values_query_runner.py
index 839a495e5bf3..590ed3740b94 100644
--- a/products/logs/backend/log_facet_values_query_runner.py
+++ b/products/logs/backend/log_facet_values_query_runner.py
@@ -1,4 +1,5 @@
import datetime as dt
+from dataclasses import dataclass
from functools import cached_property
from typing import cast
from zoneinfo import ZoneInfo
@@ -27,21 +28,39 @@ FACET_FIELDS: frozenset[str] = frozenset({"severity_text", "service_name"})
DEFAULT_FACET_LIMIT = 100
-# Resource-attribute facets read the pre-aggregated log_attributes rollup; cap the read and return
+# Attribute facets read the pre-aggregated log_attributes rollup; cap the read and return
# partial results rather than erroring, matching LogValuesQueryRunner.
-MAX_RESOURCE_READ_BYTES = 5_000_000_000
+MAX_ATTRIBUTE_READ_BYTES = 5_000_000_000
+
+
+@dataclass(frozen=True, kw_only=True)
+class _AttributeFacet:
+ """A facet over an attribute map key, served from the log_attributes rollup.
+
+ `attribute_type` is the rollup's own discriminator: 'resource' for OTel resource attributes,
+ 'log' for log-body attributes. Both fields are strings, so keyword-only construction keeps
+ them from being swapped at the call site.
+ """
+
+ attribute_type: str
+ key: str
class LogFacetValuesQueryRunner(AnalyticsQueryRunner[LogsQueryResponse], LogsQueryRunnerMixin):
"""Per-value counts for a single facet.
- A column facet (severity_text/service_name) groups the logs table directly. A resource-attribute
- facet (e.g. k8s.namespace.name) reads the pre-aggregated log_attributes rollup instead of the
- logs Map column — orders of magnitude cheaper, and the only way to keep the query under the read
- cap at scale. Both exclude the facet's own filter so selecting a value re-scopes the *other*
- facets. Resource-attribute facet counts honour service_name, severity levels and other
- resource-attribute filters (severity_text lives on the rollup), but not body-search / log-attribute
- filters (those dimensions aren't in the rollup).
+ A column facet (severity_text/service_name) groups the logs table directly. An attribute facet —
+ a resource attribute like k8s.namespace.name, or a log-body attribute like log.iostream — reads
+ the pre-aggregated log_attributes rollup instead of the logs Map column: orders of magnitude
+ cheaper, and the only way to keep the query under the read cap at scale.
+
+ Cross-filtering (a facet's counts reflect every *other* active filter, so selecting a value
+ re-scopes its siblings rather than itself) is exact for column facets, which strip their own
+ WHERE clause. On the rollup it depends on what the rollup carries. Every attribute facet honours
+ service_name, severity levels and resource-attribute filters, but not body search or
+ log-attribute filters — those dimensions aren't there. And only a resource-attribute facet can
+ strip its own filter, because rollup rows for a resource key share a resource_fingerprint; log
+ attributes have no equivalent grouping column, so a log-attribute facet can't exclude itself.
"""
query: LogsQuery
@@ -53,30 +72,36 @@ class LogFacetValuesQueryRunner(AnalyticsQueryRunner[LogsQueryResponse], LogsQue
*args,
facet_field: str | None = None,
facet_resource_attribute: str | None = None,
+ facet_attribute: str | None = None,
facet_search: str | None = None,
**kwargs,
):
super().__init__(query, *args, **kwargs)
- # A facet targets either a top-level column (severity_text/service_name) or a resource
- # attribute map key (e.g. k8s.namespace.name). Exactly one must be supplied.
- if bool(facet_field) == bool(facet_resource_attribute):
- raise ValueError("Provide exactly one of facet_field or facet_resource_attribute")
+ # A facet targets a top-level column (severity_text/service_name), a resource attribute map
+ # key (e.g. k8s.namespace.name), or a log-body attribute map key (e.g. log.iostream).
+ # Exactly one must be supplied.
+ if sum(1 for target in (facet_field, facet_resource_attribute, facet_attribute) if target) != 1:
+ raise ValueError("Provide exactly one of facet_field, facet_resource_attribute or facet_attribute")
if facet_field is not None and facet_field not in FACET_FIELDS:
raise ValueError(f"Unsupported facet field: {facet_field!r}")
self.facet_field = facet_field
- self.facet_resource_attribute = facet_resource_attribute
+ self.attribute_facet: _AttributeFacet | None = None
+ if facet_resource_attribute:
+ self.attribute_facet = _AttributeFacet(attribute_type="resource", key=facet_resource_attribute)
+ elif facet_attribute:
+ self.attribute_facet = _AttributeFacet(attribute_type="log", key=facet_attribute)
# Type-ahead over the facet's *own* values (e.g. service name contains "kafka"), distinct from
# query.searchTerm which searches log bodies. Lets a dynamic facet search past the LIMIT window.
self.facet_search = (facet_search or "").strip() or None
@cached_property
def settings(self) -> HogQLGlobalSettings:
- if self.facet_resource_attribute is not None:
+ if self.attribute_facet is not None:
# The rollup is small; "break" returns partial results instead of erroring if we ever
# hit the cap (mirrors LogValuesQueryRunner).
return HogQLGlobalSettings(
read_overflow_mode="break",
- max_bytes_to_read=MAX_RESOURCE_READ_BYTES,
+ max_bytes_to_read=MAX_ATTRIBUTE_READ_BYTES,
)
# Column facets still group the logs table — fail fast rather than scan unbounded data.
return HogQLGlobalSettings(
@@ -112,8 +137,8 @@ class LogFacetValuesQueryRunner(AnalyticsQueryRunner[LogsQueryResponse], LogsQue
return LogsQueryResponse(results=results)
def to_query(self) -> ast.SelectQuery:
- if self.facet_resource_attribute is not None:
- return self._resource_attribute_query()
+ if self.attribute_facet is not None:
+ return self._attribute_query(self.attribute_facet)
return self._column_facet_query()
def _column_facet_query(self) -> ast.SelectQuery:
@@ -165,12 +190,12 @@ class LogFacetValuesQueryRunner(AnalyticsQueryRunner[LogsQueryResponse], LogsQue
assert isinstance(query, ast.SelectQuery)
return query
- def _resource_attribute_query(self) -> ast.SelectQuery:
+ def _attribute_query(self, facet: _AttributeFacet) -> ast.SelectQuery:
# Served from the pre-aggregated log_attributes rollup (sum(attribute_count)) rather than
- # grouping the logs Map column, which reads the whole resource_attributes column and blows
- # past the read cap at scale. The rollup carries severity_text and service_name, so severity
- # levels, service_name and other resource-attribute filters re-scope the counts; body-search,
- # log-attribute filters and personId scoping still aren't in the rollup.
+ # grouping the logs Map column, which reads the whole attribute column and blows past the
+ # read cap at scale. The rollup carries severity_text and service_name, so severity levels,
+ # service_name and resource-attribute filters re-scope the counts; body-search, log-attribute
+ # filters and personId scoping still aren't in the rollup.
date_range = self._attributes_query_date_range
where_exprs: list[ast.Expr] = []
if self.query.serviceNames:
@@ -193,13 +218,14 @@ class LogFacetValuesQueryRunner(AnalyticsQueryRunner[LogsQueryResponse], LogsQue
},
)
)
- # Cross-filter by other resource attributes, excluding this facet's own key so selecting a
- # value doesn't collapse the facet to that single value.
+ # Cross-filter by resource attributes. A resource-attribute facet excludes its own key so
+ # selecting a value doesn't collapse the facet to that single value; a log-attribute facet
+ # has nothing to exclude here, since its own filter isn't a resource one.
filter_builder = LogsFilterBuilder(
self.query,
self.team,
date_range,
- exclude_resource_attribute=self.facet_resource_attribute,
+ exclude_resource_attribute=facet.key if facet.attribute_type == "resource" else None,
)
where_exprs.append(filter_builder.resource_filter(existing_filters=where_exprs))
@@ -219,8 +245,8 @@ class LogFacetValuesQueryRunner(AnalyticsQueryRunner[LogsQueryResponse], LogsQue
LIMIT {limit}
""",
placeholders={
- "attribute_type": ast.Constant(value="resource"),
- "attribute_key": ast.Constant(value=cast(str, self.facet_resource_attribute)),
+ "attribute_type": ast.Constant(value=facet.attribute_type),
+ "attribute_key": ast.Constant(value=facet.key),
# ilike_pattern(None) -> '%', i.e. match every value when no facet search is given.
"search": ast.Constant(value=ilike_pattern(self.facet_search)),
"where": ast.And(exprs=where_exprs),
diff --git a/products/logs/backend/presentation/views/api.py b/products/logs/backend/presentation/views/api.py
index b52d093d2caf..9f62b9741fd4 100644
--- a/products/logs/backend/presentation/views/api.py
+++ b/products/logs/backend/presentation/views/api.py
@@ -400,15 +400,22 @@ class _LogsFacetValuesBodySerializer(serializers.Serializer):
choices=["severity_text", "service_name"],
required=False,
allow_null=True,
- help_text="Top-level column to facet on. Provide exactly one of facetField or facetResourceAttribute. "
- "Its own filter is excluded so counts reflect the other active filters.",
+ help_text="Top-level column to facet on. Provide exactly one of facetField, facetResourceAttribute or "
+ "facetAttribute. Its own filter is excluded so counts reflect the other active filters.",
)
facetResourceAttribute = serializers.CharField(
required=False,
allow_null=True,
help_text="Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of "
- "facetField or facetResourceAttribute. Its own log_resource_attribute filter is excluded so counts "
- "reflect the other active filters.",
+ "facetField, facetResourceAttribute or facetAttribute. Its own log_resource_attribute filter is excluded "
+ "so counts reflect the other active filters.",
+ )
+ facetAttribute = serializers.CharField(
+ required=False,
+ allow_null=True,
+ help_text="Log attribute key to facet on (e.g. 'log.iostream'). Provide exactly one of facetField, "
+ "facetResourceAttribute or facetAttribute. Counts honour severity, service and resource-attribute "
+ "filters, but not body search, other log-attribute filters, or this facet's own filter.",
)
dateRange = _DateRangeSerializer(required=False, help_text="Date range. Defaults to last hour.")
severityLevels = serializers.ListField(
@@ -1339,8 +1346,9 @@ class LogsViewSet(TeamAndOrgViewSetMixin, PydanticModelMixin, viewsets.ViewSet):
facet_field = query_data.get("facetField")
facet_resource_attribute = query_data.get("facetResourceAttribute")
- if bool(facet_field) == bool(facet_resource_attribute):
- raise ParseError("Provide exactly one of facetField or facetResourceAttribute")
+ facet_attribute = query_data.get("facetAttribute")
+ if sum(1 for target in (facet_field, facet_resource_attribute, facet_attribute) if target) != 1:
+ raise ParseError("Provide exactly one of facetField, facetResourceAttribute or facetAttribute")
if facet_field and facet_field not in FACET_FIELDS:
raise ParseError(f"facetField must be one of {sorted(FACET_FIELDS)}")
@@ -1361,6 +1369,7 @@ class LogsViewSet(TeamAndOrgViewSetMixin, PydanticModelMixin, viewsets.ViewSet):
query=query,
facet_field=facet_field or None,
facet_resource_attribute=facet_resource_attribute or None,
+ facet_attribute=facet_attribute or None,
facet_search=query_data.get("facetSearch"),
)
response = runner.run(
diff --git a/products/logs/backend/test/test_log_facet_values.py b/products/logs/backend/test/test_log_facet_values.py
index a84c01433e93..992b72a851b2 100644
--- a/products/logs/backend/test/test_log_facet_values.py
+++ b/products/logs/backend/test/test_log_facet_values.py
@@ -36,8 +36,8 @@ class TestLogFacetValues(ClickhouseTestMixin, APIBaseTest):
self.assertEqual(response.status_code, status.HTTP_200_OK)
return {r["value"]: r["count"] for r in response.json()["results"]}
- def _facet_attr(self, key: str, **filters) -> dict[str, int]:
- body = {"query": {"facetResourceAttribute": key, "dateRange": self.DATE_RANGE, **filters}}
+ def _facet_attr(self, key: str, target: str = "facetResourceAttribute", **filters) -> dict[str, int]:
+ body = {"query": {target: key, "dateRange": self.DATE_RANGE, **filters}}
response = self.client.post(f"/api/projects/{self.team.pk}/logs/facet_values", body, format="json")
self.assertEqual(response.status_code, status.HTTP_200_OK)
return {r["value"]: r["count"] for r in response.json()["results"]}
@@ -105,13 +105,34 @@ class TestLogFacetValues(ClickhouseTestMixin, APIBaseTest):
response = self.client.post(f"/api/projects/{self.team.pk}/logs/facet_values", body, format="json")
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
- @parameterized.expand([("k8s.namespace.name",), ("k8s.pod.name",), ("k8s.node.name",)])
- def test_facet_on_resource_attribute_returns_values(self, key):
- """A resource attribute key can be faceted and returns its values with counts."""
- result = self._facet_attr(key)
+ # Resource and log attributes share the log_attributes rollup, so every behaviour that doesn't
+ # depend on resource_fingerprint is shared and parameterized over (request field, key).
+ @parameterized.expand(
+ [
+ ("facetResourceAttribute", "k8s.namespace.name"),
+ ("facetResourceAttribute", "k8s.pod.name"),
+ ("facetResourceAttribute", "k8s.node.name"),
+ ("facetAttribute", "log.iostream"),
+ ("facetAttribute", "hostname"),
+ ("facetAttribute", "level"),
+ ]
+ )
+ def test_facet_on_attribute_returns_values(self, target, key):
+ result = self._facet_attr(key, target=target)
self.assertGreater(len(result), 0)
self.assertTrue(all(count > 0 for count in result.values()))
+ @parameterized.expand(
+ [
+ ("facetAttribute", "k8s.namespace.name"),
+ ("facetResourceAttribute", "log.iostream"),
+ ]
+ )
+ def test_attribute_types_are_not_interchangeable(self, target, key):
+ # One rollup table holds both types, discriminated by attribute_type. A key looked up under
+ # the wrong type must come back empty rather than leaking the other type's values.
+ self.assertEqual(self._facet_attr(key, target=target), {})
+
def test_resource_facet_excludes_blank_for_missing_key(self):
"""Logs lacking the key read back '' from the map; that bucket must not appear as a facet value."""
# k8s.deployment.name is present on only some fixture rows (others carry a daemonset instead).
@@ -160,22 +181,36 @@ class TestLogFacetValues(ClickhouseTestMixin, APIBaseTest):
self.assertTrue(set(scoped).issubset(set(base)))
self.assertLess(sum(scoped.values()), sum(base.values()))
- def test_resource_facet_honors_severity_filter(self):
- # severity_text now lives on the log_attributes rollup, so a severity filter re-scopes
- # resource-attribute facet counts (previously it was accepted but silently ignored).
- base = self._facet_attr("k8s.namespace.name")
+ @parameterized.expand(
+ [
+ ("facetResourceAttribute", "k8s.namespace.name"),
+ ("facetAttribute", "log.iostream"),
+ ]
+ )
+ def test_attribute_facet_honors_severity_filter(self, target, key):
+ # severity_text lives on the log_attributes rollup, so a severity filter re-scopes attribute
+ # facet counts of either type (it used to be accepted but silently ignored).
+ base = self._facet_attr(key, target=target)
self.assertGreater(len(base), 0)
one_severity = next(iter(self._facet("severity_text")))
- scoped = self._facet_attr("k8s.namespace.name", severityLevels=[one_severity])
+ scoped = self._facet_attr(key, target=target, severityLevels=[one_severity])
self.assertGreater(len(scoped), 0)
self.assertTrue(set(scoped).issubset(set(base)))
self.assertLess(sum(scoped.values()), sum(base.values()))
- @parameterized.expand([("exact",), ("is_not",)])
- def test_resource_facet_honors_other_resource_attribute_filter(self, operator):
- # A different resource-attribute filter — include or exclude — re-scopes the counts via the
- # rollup's resource_fingerprint subquery — proves cross-filtering still works on log_attributes.
- base = self._facet_attr("k8s.pod.name")
+ @parameterized.expand(
+ [
+ ("facetResourceAttribute", "k8s.pod.name", "exact"),
+ ("facetResourceAttribute", "k8s.pod.name", "is_not"),
+ ("facetAttribute", "log.iostream", "exact"),
+ ("facetAttribute", "log.iostream", "is_not"),
+ ]
+ )
+ def test_attribute_facet_honors_other_resource_attribute_filter(self, target, key, operator):
+ # A resource-attribute filter — include or exclude — re-scopes the counts via the rollup's
+ # resource_fingerprint subquery. Covers both facet types because a log-attribute facet reads
+ # the same rollup and must keep applying resource_filter().
+ base = self._facet_attr(key, target=target)
one_namespace = next(iter(self._facet_attr("k8s.namespace.name")))
filter_group = [
{
@@ -185,24 +220,44 @@ class TestLogFacetValues(ClickhouseTestMixin, APIBaseTest):
"value": one_namespace,
}
]
- scoped = self._facet_attr("k8s.pod.name", filterGroup=filter_group)
+ scoped = self._facet_attr(key, target=target, filterGroup=filter_group)
self.assertGreater(len(scoped), 0)
self.assertTrue(set(scoped).issubset(set(base)))
self.assertLess(sum(scoped.values()), sum(base.values()))
- @parameterized.expand([("argo",), ("ARGO",)])
- def test_resource_facet_search_is_case_insensitive(self, term):
- searched = self._facet_attr("k8s.namespace.name", facetSearch=term)
+ @parameterized.expand(
+ [
+ ("facetResourceAttribute", "k8s.namespace.name", "argo"),
+ ("facetResourceAttribute", "k8s.namespace.name", "ARGO"),
+ ("facetAttribute", "log.iostream", "out"),
+ ("facetAttribute", "log.iostream", "OUT"),
+ ]
+ )
+ def test_attribute_facet_search_is_case_insensitive(self, target, key, term):
+ searched = self._facet_attr(key, target=target, facetSearch=term)
self.assertGreater(len(searched), 0)
self.assertTrue(all(term.lower() in value.lower() for value in searched))
- def test_resource_facet_search_no_match_returns_empty(self):
- self.assertEqual(self._facet_attr("k8s.namespace.name", facetSearch="no-such-namespace-xyz"), {})
+ @parameterized.expand(
+ [
+ ("facetResourceAttribute", "k8s.namespace.name"),
+ ("facetAttribute", "log.iostream"),
+ ]
+ )
+ def test_attribute_facet_search_no_match_returns_empty(self, target, key):
+ self.assertEqual(self._facet_attr(key, target=target, facetSearch="no-such-value-xyz"), {})
def test_requires_exactly_one_facet_target(self):
for query in (
- {}, # neither
- {"facetField": "service_name", "facetResourceAttribute": "k8s.pod.name"}, # both
+ {}, # none
+ {"facetField": "service_name", "facetResourceAttribute": "k8s.pod.name"},
+ {"facetField": "service_name", "facetAttribute": "log.iostream"},
+ {"facetResourceAttribute": "k8s.pod.name", "facetAttribute": "log.iostream"},
+ { # all three
+ "facetField": "service_name",
+ "facetResourceAttribute": "k8s.pod.name",
+ "facetAttribute": "log.iostream",
+ },
):
body = {"query": {**query, "dateRange": self.DATE_RANGE}}
response = self.client.post(f"/api/projects/{self.team.pk}/logs/facet_values", body, format="json")
diff --git a/products/logs/frontend/generated/api.schemas.ts b/products/logs/frontend/generated/api.schemas.ts
index 8772e974e0b4..d7a68fd430ab 100644
--- a/products/logs/frontend/generated/api.schemas.ts
+++ b/products/logs/frontend/generated/api.schemas.ts
@@ -1050,16 +1050,21 @@ export const FacetFieldEnumApi = {
} as const
export interface _LogsFacetValuesBodyApi {
- /** Top-level column to facet on. Provide exactly one of facetField or facetResourceAttribute. Its own filter is excluded so counts reflect the other active filters.
+ /** Top-level column to facet on. Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Its own filter is excluded so counts reflect the other active filters.
*
* * `severity_text` - severity_text
* * `service_name` - service_name */
facetField?: FacetFieldEnumApi | null
/**
- * Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of facetField or facetResourceAttribute. Its own log_resource_attribute filter is excluded so counts reflect the other active filters.
+ * Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Its own log_resource_attribute filter is excluded so counts reflect the other active filters.
* @nullable
*/
facetResourceAttribute?: string | null
+ /**
+ * Log attribute key to facet on (e.g. 'log.iostream'). Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Counts honour severity, service and resource-attribute filters, but not body search, other log-attribute filters, or this facet's own filter.
+ * @nullable
+ */
+ facetAttribute?: string | null
/** Date range. Defaults to last hour. */
dateRange?: _DateRangeApi
/** Filter by log severity levels (ignored when faceting on severity_text). */
diff --git a/products/logs/frontend/generated/api.zod.ts b/products/logs/frontend/generated/api.zod.ts
index d542e4e7a2be..d7251f43f624 100644
--- a/products/logs/frontend/generated/api.zod.ts
+++ b/products/logs/frontend/generated/api.zod.ts
@@ -618,13 +618,19 @@ export const LogsFacetValuesCreateBody = /* @__PURE__ */ zod.object({
])
.optional()
.describe(
- 'Top-level column to facet on. Provide exactly one of facetField or facetResourceAttribute. Its own filter is excluded so counts reflect the other active filters.\n\n\* `severity_text` - severity_text\n\* `service_name` - service_name'
+ 'Top-level column to facet on. Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Its own filter is excluded so counts reflect the other active filters.\n\n\* `severity_text` - severity_text\n\* `service_name` - service_name'
),
facetResourceAttribute: zod
.string()
.nullish()
.describe(
- "Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of facetField or facetResourceAttribute. Its own log_resource_attribute filter is excluded so counts reflect the other active filters."
+ "Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Its own log_resource_attribute filter is excluded so counts reflect the other active filters."
+ ),
+ facetAttribute: zod
+ .string()
+ .nullish()
+ .describe(
+ "Log attribute key to facet on (e.g. 'log.iostream'). Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Counts honour severity, service and resource-attribute filters, but not body search, other log-attribute filters, or this facet's own filter."
),
dateRange: zod
.object({
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index f787690b99bb..849399187bd9 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -76749,16 +76749,21 @@ export namespace Schemas {
}
export interface _LogsFacetValuesBody {
- /** Top-level column to facet on. Provide exactly one of facetField or facetResourceAttribute. Its own filter is excluded so counts reflect the other active filters.
+ /** Top-level column to facet on. Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Its own filter is excluded so counts reflect the other active filters.
*
* * `severity_text` - severity_text
* * `service_name` - service_name */
facetField?: FacetFieldEnum | null;
/**
- * Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of facetField or facetResourceAttribute. Its own log_resource_attribute filter is excluded so counts reflect the other active filters.
+ * Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Its own log_resource_attribute filter is excluded so counts reflect the other active filters.
* @nullable
*/
facetResourceAttribute?: string | null;
+ /**
+ * Log attribute key to facet on (e.g. 'log.iostream'). Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Counts honour severity, service and resource-attribute filters, but not body search, other log-attribute filters, or this facet's own filter.
+ * @nullable
+ */
+ facetAttribute?: string | null;
/** Date range. Defaults to last hour. */
dateRange?: _DateRange;
/** Filter by log severity levels (ignored when faceting on severity_text). */
diff --git a/services/mcp/src/generated/logs/api.ts b/services/mcp/src/generated/logs/api.ts
index c3de375a8f1b..1bcda2e0b0ee 100644
--- a/services/mcp/src/generated/logs/api.ts
+++ b/services/mcp/src/generated/logs/api.ts
@@ -4489,13 +4489,19 @@ export const LogsFacetValuesCreateBody = /* @__PURE__ */ zod.object({
])
.optional()
.describe(
- 'Top-level column to facet on. Provide exactly one of facetField or facetResourceAttribute. Its own filter is excluded so counts reflect the other active filters.\n\n\* `severity_text` - severity_text\n\* `service_name` - service_name'
+ 'Top-level column to facet on. Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Its own filter is excluded so counts reflect the other active filters.\n\n\* `severity_text` - severity_text\n\* `service_name` - service_name'
),
facetResourceAttribute: zod
.string()
.nullish()
.describe(
- "Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of facetField or facetResourceAttribute. Its own log_resource_attribute filter is excluded so counts reflect the other active filters."
+ "Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Its own log_resource_attribute filter is excluded so counts reflect the other active filters."
+ ),
+ facetAttribute: zod
+ .string()
+ .nullish()
+ .describe(
+ "Log attribute key to facet on (e.g. 'log.iostream'). Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Counts honour severity, service and resource-attribute filters, but not body search, other log-attribute filters, or this facet's own filter."
),
dateRange: zod
.object({
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/logs-facet-values-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/logs-facet-values-create.json
index cb7652f2d920..211431ec6695 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/logs-facet-values-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/logs-facet-values-create.json
@@ -32,6 +32,17 @@
},
"type": "object"
},
+ "facetAttribute": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Log attribute key to facet on (e.g. 'log.iostream'). Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Counts honour severity, service and resource-attribute filters, but not body search, other log-attribute filters, or this facet's own filter."
+ },
"facetField": {
"anyOf": [
{
@@ -43,7 +54,7 @@
"type": "null"
}
],
- "description": "Top-level column to facet on. Provide exactly one of facetField or facetResourceAttribute. Its own filter is excluded so counts reflect the other active filters.\n\n* `severity_text` - severity_text\n* `service_name` - service_name"
+ "description": "Top-level column to facet on. Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Its own filter is excluded so counts reflect the other active filters.\n\n* `severity_text` - severity_text\n* `service_name` - service_name"
},
"facetResourceAttribute": {
"anyOf": [
@@ -54,7 +65,7 @@
"type": "null"
}
],
- "description": "Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of facetField or facetResourceAttribute. Its own log_resource_attribute filter is excluded so counts reflect the other active filters."
+ "description": "Resource attribute key to facet on (e.g. 'k8s.namespace.name'). Provide exactly one of facetField, facetResourceAttribute or facetAttribute. Its own log_resource_attribute filter is excluded so counts reflect the other active filters."
},
"facetSearch": {
"description": "Type-ahead filter over the faceted field's own values (case-insensitive substring match). Distinct from searchTerm, which searches log bodies.",