Composer and Cloud Scheduler

From cron to event-driven

Rules that start a job when its data lands, replayed in the Rule Lab before they replace a cron trigger.

  1. Operate
  2. Scheduler
  • Overview
  • Observe
  • Incidents3
  • Lineage
  • Data trust
  • Operate
  • Scheduler
  • Processing
  • Dashboards
  • Catalog
  • Contracts
SchedulerRunning now1010Overnight warehouse buildNothing running right nowMorning desk martsNothing running right now
  • Graphs and analytics
  • Scheduling rules
  • Refresh conflicts
  • Recovery

14 rulesFailing 3Late 0Paused 1No runs yet 6

NameHealthStatusScheduleNext run
Curtailed energy totalNo runs yetActiveEvery day at 08:00 · UTC08:00
Dispatch freshness lagNo runs yetActiveEvery day at 06:30 · UTC06:30
Forecast accuracy martHealthyActiveEvery day at 07:10 · UTC07:10
Grid notices stagingFailingActiveEvery day at 06:20 · UTC06:20
Maintenance backlog refreshPausedInactiveEvery day at 06:00 · UTC—
Morning desk martsHealthyFailingActiveEvery day at 05:45 · UTC05:45
Overnight warehouse buildHealthyActiveEvery day at 05:30 · UTC05:30
Settlement facts after market closeFailingActiveEvery day at 07:15 · UTC07:15
Settlements row volumeNo runs yetActiveEvery day at 07:40 · UTC07:40
Solar and battery stagingHealthyActiveEvery day at 05:15 · UTC05:15
Turbine output row volumeNo runs yetActiveEvery day at 06:00 · UTC06:00
Turbine telemetry stagingHealthyActiveEvery day at 05:05 · UTC05:05
Wind speed null shareNo runs yetActiveEvery day at 06:15 · UTC06:15
Work order duplicate shareNo runs yetActiveEvery day at 06:45 · UTC06:45
Desk marts failedHighjust now

Quota exceeded: the slot reservation was fully used by another job

Demo estateNistor opens an incident on the failed run.

Today

  • A cron trigger fires at its time, late load or not.
  • An early load waits for nothing.
  • Triggers live in different places, and nobody is sure what each starts.

With Nistor

  • Composer, Airflow and Cloud Scheduler jobs read as assets of the graph.
  • Rules that fire once every source has new data.
  • A failsafe and a freshness expectation for the morning a source is late.

Your first week. One step a day; the quickstart has the commands.

  1. Day 1

    Map the triggers

    Find each Cloud Scheduler job and Airflow task in the lineage.

  2. Day 2

    Write one rule

    On the tables the job reads, kept as a file.

  3. Day 3

    Validate it

    Check the file against the rule schema before syncing it.

  4. Day 4

    Keep a failsafe

    A deadline that runs the rule if its trigger never came.

The commands for each day are in the quickstart →

Details. How each part works, in more depth.

The example rule from the scheduling docs rebuilds a mart once its sources have settled:

- name: Refresh the daily sales mart after the warehouse loads
  code_id: marts/mart-sales-daily        # the rule's stable identity when it is kept as a file
  description: Rebuilds mart_sales_daily once its source tables have settled.
  priority: 5
  status: active
  status_by_env:                         # file-only: the status per environment
    dev: paused
  tags:
    - marts
    - sales
  applies_to:
    node_type: DataformAction
    node_ids:
      - DataformAction_acme-mart-{ENV}.marts.mart_sales_daily
  when:
    events:
      - origin: ancestors                # events on the nodes this one reads from
        ancestor_depth: direct_materialized
        types:                           # matched exactly; list every write type you care about
          - BIGQUERY_INSERT
          - BIGQUERY_MERGE
    wait_for_all_ancestors: true         # fire once every source has produced a new event
    wait_for_all_ancestors_timeout_seconds: 5400
    wait_for_all_ancestors_timeout_alert: true
  if:
    quiet_period_seconds: 600            # wait for 10 quiet minutes before running
    max_runtime_seconds: 7200
    run_limit:
      max: 3
      period: day
  then:
    target:
      same_as_applies_to: true
      scope: node
    do:
      kind: single
      action:
        type: dataform_run
        parameters:
          release: projects/acme-mart-{ENV}/locations/europe-west1/repositories/acme-marts/releaseConfigs/daily
          retry:
            mode: exponential
            max_retries: 3
  failsafe:                              # acts on machines: run the rule if no trigger came
    enabled: true
    deadline_cron: "30 7 * * *"
    time_zone: Europe/London
  freshness_expectation:                 # acts on people: open an incident if still late
    days: weekdays
    before: "08:00"
    time_zone: Europe/London
    incident_severity: high

The Rule Lab shows what a draft rule would do before you save it. Nothing is stored until you save. Its replay shows when the rule would have fired over past days, next to what ran. A rule in test status is evaluated, but its action is only simulated. Rules live as files: nistor rules validate checks them without an API, and nistor rules sync pushes them. Rules, events, cron, conditions, rules as code and the Rule Lab are open source.

Where the triggers live today

The Google Cloud tool reads Composer environments, Airflow DAGs and Cloud Scheduler jobs as nodes. Lineage links a Cloud Scheduler job to its target, and an Airflow task to the BigQuery tables its operator names. Events reach Nistor through Cloud Logging, BigQuery job completions and table data changes among them. A source that sends no audit-log events, such as a table in another organisation, can be polled for its last-modified time instead, every 900 seconds by default.

Before the rule replaces the cron

A rule can have events and a schedule at once. With wait_for_new_data, a cron rule fires only if new events arrived since its last run. In the Rule Lab, the blast radius lists the nodes a draft would match, and whether it wins, loses or shares each one with the rules already there. The replay covers the last 7 to 90 days, for up to three nodes. A failsafe runs the action and raises no alert. A freshness_expectation runs nothing and opens a delivery_slo incident, resolved once the target is fresh. A synced rule is locked: the API refuses to edit or delete it, so the file stays the one place to change it.

Rule Lab replaying a scheduling rule over the last 30 days: when it would have fired, run by run.Rule Lab replaying a scheduling rule over the last 30 days: when it would have fired, run by run.

See your platform as one graph, on your laptop. Explore the demo estate, or book a walkthrough on one like yours.