Monitor Platform Event Publishing and Delivery Usage

Monitor Platform Event Publishing and Delivery Usage

Last Updated on March 30, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

  • How to monitor Platform Events consumption?

Objectives:

After reading this blog, you’ll be able to:

  • Understand the platform events
  • Different apps to monitor platform event usages
  • Query platform event usages for a given time-frame

Business Use case

Jestilla Zetkin is working as a System administrator at Gurukul On Cloud (GoC). She has received a requirement from her project manager to give the day-wise consumption of platform events published and delivered for the last 90 days. 

What is Platform Events?

Event-driven architectures have become very popular in recent years, and for a good reason. It is based on the fire-and-forget pattern. Firing an event and letting each system handle business logic allows you to keep unrelated systems decoupled and can help simplify the architecture.

Platform events enable you to deliver secure, scalable, and customizable event notifications within Salesforce or from external sources. Apps can publish and subscribe to Platform Events on the Salesforce platform using Apex, Flow, or in an external system using CometD. If you want to learn more about Platform Event, check out the Trailhead Module.

Understand PlatformEventUsageMetric Object

Let’s take a pause here, familiarize yourself with the PlatformEventUsageMetric object in Salesforce. It contains useful data for event publishing and CometD-client delivery.

Usage data is available for the last 24 hours, ending at the last hour, and for historical daily usage. PlatformEventUsageMetric contains separate usage metrics for platform events and change data capture events.

Field Name
Details
Name The name of the metric to get usage for.

  • CHANGE_EVENTS_DELIVERED:- Number of change data capture events delivered to CometD clients
  • CHANGE_EVENTS_PUBLISHED:- Number of change data capture events published
  • PLATFORM_EVENTS_DELIVERED:- Number of platform events delivered to CometD clients
  • PLATFORM_EVENTS_PUBLISHED:- Number of platform events published
StartDate The start date and time in UTC used for querying usage metrics. The date granularity is hourly.
EndDate The end date and time in UTC used for querying usage metrics. The date granularity is hourly.
Value The usage value for the specified metric and date range.

We will use PlatformEventUsageMetric to get visibility into our event usage and usage trends. The usage data gives us an idea of how close we are to our allocations and when it requires more allocations.

Route to AppExchange

We often encounter the requirement to find out daily or monthly platform event consumption with analytics. There are various apps on AppExchange to achieve it. Some of them are listed below:

  1. Platform Event Usage MonitorUnderstand the platform event usage in your org.
  2. Streaming Monitor Monitor streaming events (PushTopic, Generic, Standard/Custom Platform Events, CDC, etc.).

Guided Practice (We-do):

To find Platform Events published and delivered consumption for the last 90 days, we will use Developer Console to Query PlatformEventUsageMetric object.

Today is March 20, 2022 so that means that 90 days before today would be December 20, 2021.

  1. Click Setup | Developer Console 
  2. In the Query Editor, run the following SOQL query 
    1. SELECT Name, StartDate, EndDate, Value
      FROM PlatformEventUsageMetric

      WHERE Name IN (‘PLATFORM_EVENTS_DELIVERED’, ‘PLATFORM_EVENTS_PUBLISHED’)
      AND StartDate>=2021-12-20T00:00:00.000Z ORDER BY StartDate
  3. If you want to download the data to share with the project manager or executive team, then consider using Visual Studio Code or Workbench.

Formative Assessment:

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

One thought on “Monitor Platform Event Publishing and Delivery Usage

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.