PlatformEventUsageMetric
Contains usage data for event publishing and delivery to CometD and Pub/Sub API clients, empApi Lightning components, and event relays. If Enhanced Usage Metrics isn’t enabled, usage data is available for the last 24 hours, ending at the last hour, and for historical daily usage. In API 58.0 and later, you can enable Enhanced Usage Metrics to get usage data by event name and client for granular time intervals. PlatformEventUsageMetric contains separate usage metrics for platform events and change data capture events.
Introduced in API version 50.0.
describeSObjects(), query()
-
Type: string
-
Properties: Filter, Group, Nillable, Sort
-
Introduced: API version 58.0
-
Description:
This field is available only when Enhanced Usage Metrics is enabled. The ID of the client. The
Clientfield is populated with one of the following values.The
Clientfield can be one of these values.- For a Streaming API (CometD) client and the empApi Lightning component, the client value is the ID of the CometD session.
- For a Pub/Sub API client, the client value is
PUB_SUB_API. - For an event relay, the client value is
EVENT_RELAY. - For the publish usage of Change Data Capture events, the client value is
SYSTEM. - For publish usages using REST API, the client value is
REST_API. - For publish usages using Flow, the client value is
FLOW. - For publish usages using SOAP API, the client value is
SOAP_API. - For publish usages using Bulk API, the client value is
BULK_API. - For Apex, the publish usage client value is
APEXand the delivery usage client value is the Apex Trigger ID starting with 01q.
-
Type: datetime
-
Properties: Filter, Nillable, Sort
-
Description:
The end date and time in UTC used for querying usage metrics. The date granularity is hourly.
To get usage data for the last 24 hours, the end date is the current date in UTC. The time is the current time in UTC rounded down to the previous hour. For example, 11:23 is 11:00 and the date format is: 2020-08-04T11:00:00.000Z
To get historical data, the end date in UTC is the end of the date range with hours specified as 0. For example: 2020-08-04T00:00:00.000Z. To query a date range, you can use the < or <= operators.
For the date format to use, see Date Formats and Date Literals in the SOQL and SOSL Reference.
-
Type: string
-
Properties: Filter, Group, Nillable, Sort
-
Introduced: API version 58.0
-
Description:
This field is available only when Enhanced Usage Metrics is enabled. The API name of a custom platform event or a change event.
- Custom platform event with the label My Event:
My_Event__e - Change event example:
AccountChangeEvent
When you query usage metrics for
EventName, specify theUsageTypefield in theSELECTorWHEREclause. - Custom platform event with the label My Event:
-
Type: picklist
-
Properties: Filter, Group, Nillable, Restricted picklist, Sort
-
Introduced: API version 58.0
-
Description:
This field is available when Enhanced Usage Metrics is enabled. The type of event you would like to query usage metrics for, such as a change event or a custom platform event.
When you query usage metrics for
EventType, specify theUsageTypefield in theSELECTorWHEREclause. -
Possible values:
- CHANGE_EVENT — CHANGE_EVENT — A Change Data Capture event.
- CUSTOM_PLATFORM_EVENT — CUSTOM_PLATFORM_EVENT — A platform event that an admin defined in your Salesforce org.
- Type: id
- Properties: Filter, Group, Nillable, Sort
- Description: This field is not in use.
- Type: picklist
- Properties: Filter, Group, Restricted picklist, Sort
- Description: The name of the metric to get usage for.
- Possible values:
- CHANGE_EVENTS_DELIVERED — CHANGE_EVENTS_DELIVERED — Number of change data capture events delivered to CometD and Pub/Sub API clients,
empApiLightning components, and event relays - CHANGE_EVENTS_PUBLISHED — CHANGE_EVENTS_PUBLISHED — Number of change data capture events published
- PLATFORM_EVENTS_DELIVERED — PLATFORM_EVENTS_DELIVERED — Number of platform events delivered to CometD and Pub/Sub API clients,
empApiLightning components, and event relays - PLATFORM_EVENTS_PUBLISHED — PLATFORM_EVENTS_PUBLISHED — Number of platform events published
- CHANGE_EVENTS_DELIVERED — CHANGE_EVENTS_DELIVERED — Number of change data capture events delivered to CometD and Pub/Sub API clients,
-
Type: datetime
-
Properties: Filter, Nillable, Sort
-
Description:
The start date and time in UTC used for querying usage metrics. The date granularity is hourly.
To get usage data for the last 24 hours, the start date is the previous day in UTC. The time is the current time in UTC rounded down to the previous hour. For example, 11:23 is 11:00 and the date format is: 2020-08-03T11:00:00.000Z
To get historical data, the start date is the start of the date range with hours specified as 0. For example: 2020-08-03T00:00:00.000Z. To specify a date range, you can use the > or >= operators.
If Enhanced Usage Metrics is enabled, keep in mind these tips.
- Make sure the time span between
StartDateandEndDateis valid for theTimeSegmentvalue chosen. - The maximum date range that you can specify between
StartDateandEndDateis 60 days.
For the date format to use, see Date Formats and Date Literals in the SOQL and SOSL Reference.
- Make sure the time span between
-
Type: picklist
-
Properties: Filter, Group, Nillable, Restricted picklist, Sort
-
Introduced: API version 58.0
-
Description:
This field is available when Enhanced Usage Metrics is enabled. The time interval used for aggregating usage data returned in the query results. Valid
TimeSegmentvalues depend on the time range specified withStartDateandEndDate.Possible values are:
DailyUsage data is aggregated for each day within the specified time range. Valid only if the time range specified with StartDateandEndDatein the query is at least 24 hours.HourlyUsage data is aggregated for each hour within the specified time range. Valid only if the time range specified with StartDateandEndDatein the query is between one hour and 24 hours.FifteenMinutesUsage data is aggregated for each 15-minute period within the specified time range. Valid only if the time range specified with StartDateandEndDatein the query is between 15 minutes and one hour.
- Type: picklist
- Properties: Filter, Group, Nillable, Restricted picklist, Sort
- Introduced: API version 58.0
- Description: This field is available when Enhanced Usage Metrics is enabled. The type of event usage metrics to query for, such as event publishing or event delivery. Use this field with the
EventNameorEventTypefields. - Possible values:
- PUBLISH — PUBLISH — Usage metrics for published events.
- DELIVERY — DELIVERY — Usage metrics for events that were delivered to subscribers.
- Type: long
- Properties: Filter, Group, Nillable, Sort
- Description: The usage value for the specified metric and date range.
For more information, see Monitor Platform Event Publishing and Delivery Usage in the Platform Events Developer Guide.