Area: Ingestion Issues
Sub-Area: DataHub Actions / Entity Change Events
Applies to: Cloud
Issue
You build an incremental workflow with DataHub Actions, the datahub-cloud event source and EntityChangeEvent_v1 events. You hit one or more of these surprises:
- A filter that combines
entityType,operationandcategoryreturns no events, even though you know matching changes happened. - With
lookback_daysset, you receive events whoseauditStamp.timeis older than the window. On later runs,lookback_daysseems to do nothing. - You are not sure whether Entity Change Events are emitted during ingestion or only after it finishes.
You Might Be Asking
- Why does my multi-field filter return no events?
- Is filtering in DataHub Actions done on the server or in the Actions process?
- Why do I receive events with audit timestamps older than my
lookback_dayssetting? - Why does
lookback_dayshave no effect after the first run? - Should I run DataHub Actions before, during, or after my ingestion?
- How can I check that DataHub has processed all pending writes?
Cause
Filtering runs in the Actions process
The datahub-cloud source polls /openapi/v1/events/poll. That endpoint takes only topic, offsetId, limit, pollTimeoutSeconds and lookbackWindowDays. It has no filter parameters, so it returns every event on the topic. The Actions framework then drops events that don't match your filter, inside your Actions process.
A filter that combines entityType, operation and category works. All three fields are plain strings in an Entity Change Event. Inside one filter, every key must match (AND). A list value such as operation: ["ADD", "MODIFY"] matches any item in the list (OR). Matching is exact and case sensitive, so TECHNICAL_SCHEMA matches and technical_schema does not.
When such a filter returns nothing, the usual cause is where the source started reading, not the filter. See the next section.
Where the source starts reading
The datahub-cloud source stores its read position (offset) under the pipeline name. On each start it loads the stored offset for that name:
- If an offset is stored, the source resumes from it. The server ignores
lookback_dayswhen an offset is sent. - If no offset is stored (the first run of a pipeline name, or a run with
reset_offsets: true) andlookback_daysis set, the server starts from the first event written in the last N days. - If no offset is stored and
lookback_daysis not set, the source starts at the latest event. You only see changes made after the pipeline starts.
So a pipeline that already ran once under the same name keeps reading from where it stopped, whatever lookback_days says. A new pipeline with no lookback_days never sees changes that happened before it started.
lookback_days uses write time, not auditStamp.time
lookback_days finds the start position by the time each event was written to the event stream. It does not read the auditStamp.time field inside the event. An event written recently can carry an older auditStamp.time, for example after delayed ingestion or a backfill.
There is a second case. If a partition of the topic has no event written inside the window, the server starts that partition at its oldest retained event. You then receive events from that partition that are all older than the window.
Event timing
Entity Change Events are produced while ingestion runs, not after it ends:
- Ingestion sends
MetadataChangeProposal(MCP) messages. - The MCP consumer writes the aspects and emits
MetadataChangeLog(MCL) messages. - The
PlatformEventGeneratorHookin the MCL consumer turns MCL messages intoEntityChangeEvent_v1events on thePlatformEvent_v1topic. - Your Actions pipeline polls
PlatformEvent_v1and receives the events.
Each step runs asynchronously, so events arrive shortly after the change is written. There is no batch step that waits for the ingestion run to end.
Solution
1. Get the start position right
To read past events once, start the pipeline with reset_offsets: true and lookback_days. Set reset_offsets back to false (or remove it) for later runs, or each restart will skip the stored offset again. See the DataHub Cloud Event Source page for all source options.
name: "datahub-schema-change-action"
source:
type: "datahub-cloud"
config:
lookback_days: 1
reset_offsets: true # first run only
filters:
- type: "event_type"
config:
filter:
EntityChangeEvent_v1:
event:
- entityType: "dataset"
category: "TECHNICAL_SCHEMA"
operation: ["ADD", "MODIFY"]
action:
type: "hello_world"
datahub:
server: "https://<your-instance>.acryl.io"
token: "<your-datahub-access-token>"
The token's user or service account needs the Get Platform Events privilege.
2. Pick a filter format
The filters: list with type: event_type is the current format. Inside event, each list item is one predicate: keys in an item are ANDed, and the items are ORed. The older filter: section still works but is deprecated:
filter:
event_type: "EntityChangeEvent_v1"
event:
entityType: "dataset"
category: "TECHNICAL_SCHEMA"
operation: ["ADD", "MODIFY"]
Both formats match the same way. Switching formats does not change which Entity Change Events pass. See Filters in the Actions concepts page.
Check your values against a real event. The Entity Change Event page lists the categories and operations, for example TECHNICAL_SCHEMA with ADD and REMOVE.
3. Filter on auditStamp.time in your action
If you need events by the time the change happened, check auditStamp.time in your action's act method. This example skips events older than 24 hours. See Developing an Action for how to package and register a custom action.
import time
from datahub_actions.action.action import Action
from datahub_actions.event.event_envelope import EventEnvelope
from datahub_actions.event.event_registry import EntityChangeEvent
from datahub_actions.pipeline.pipeline_context import PipelineContext
class SchemaChangeAction(Action):
@classmethod
def create(cls, config_dict: dict, ctx: PipelineContext) -> "Action":
return cls()
def act(self, event: EventEnvelope) -> None:
if not isinstance(event.event, EntityChangeEvent):
return
change = event.event
cutoff_ms = int(time.time() * 1000) - 24 * 60 * 60 * 1000
if change.auditStamp.time < cutoff_ms:
return
# Process the event here.
print(change.entityUrn, change.category, change.operation)
def close(self) -> None:
pass
4. Run Actions continuously
Run your Actions pipeline as a long-running process, alongside your ingestion. Events arrive as ingestion writes changes, and the stored offset lets the pipeline pick up where it stopped after a restart.
5. Check processing lag
To check that DataHub has stored all pending writes, call the MCP consumer lag endpoint. To check the MCL consumer, which produces Entity Change Events, call the MCL lag endpoint:
curl -H 'Authorization: Bearer <your-datahub-access-token>' \
'https://<your-instance>.acryl.io/openapi/operations/messaging/mcp/consumer/lag?skipCache=true'
curl -H 'Authorization: Bearer <your-datahub-access-token>' \
'https://<your-instance>.acryl.io/openapi/operations/messaging/mcl/consumer/lag?skipCache=true'
A totalLag of 0 in the topic metrics means that consumer has caught up. These endpoints need the View System Status or Manage System Operations privilege. The older /openapi/operations/kafka/.../consumer/offsets endpoints are deprecated.