Aggregate Event Unique Values

async AsyncCogniteClient.events.aggregate_unique_values(
filter: EventFilter | dict[str, Any] | None = None,
property: EventProperty | str | list[str] | None = None,
advanced_filter: Filter | dict[str, Any] | None = None,
aggregate_filter: AggregationFilter | dict[str, Any] | None = None,
) UniqueResultList

Get unique properties with counts for events.

Parameters:
  • filter (EventFilter | dict[str, Any] | None) – The filter to narrow down the events to count requiring exact match.

  • property (EventPropertyLike | None) – The property name(s) to apply the aggregation on.

  • advanced_filter (Filter | dict[str, Any] | None) – The filter to narrow down the events to consider.

  • aggregate_filter (AggregationFilter | dict[str, Any] | None) – The filter to apply to the resulting buckets.

Returns:

List of unique values of events matching the specified filters and search.

Return type:

UniqueResultList

Examples:

Get the unique types with count of events in your CDF project:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.events import EventProperty
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> result = client.events.aggregate_unique_values(property=EventProperty.type)
>>> print(result.unique)

Get the unique types of events after 2020-01-01 in your CDF project:

>>> from cognite.client.data_classes import filters
>>> from cognite.client.data_classes.events import EventProperty
>>> from cognite.client.utils import timestamp_to_ms
>>> from datetime import datetime
>>> is_after_2020 = filters.Range(
...     EventProperty.start_time, gte=timestamp_to_ms(datetime(2020, 1, 1))
... )
>>> result = client.events.aggregate_unique_values(
...     EventProperty.type, advanced_filter=is_after_2020
... )
>>> print(result.unique)

Get the unique types of events after 2020-01-01 in your CDF project, but exclude all types that start with “planned”:

>>> from cognite.client.data_classes.events import EventProperty
>>> from cognite.client.data_classes import aggregations
>>> agg = aggregations
>>> not_planned = agg.Not(agg.Prefix("planned"))
>>> is_after_2020 = filters.Range(
...     EventProperty.start_time, gte=timestamp_to_ms(datetime(2020, 1, 1))
... )
>>> result = client.events.aggregate_unique_values(
...     EventProperty.type, advanced_filter=is_after_2020, aggregate_filter=not_planned
... )
>>> print(result.unique)