dagu icon indicating copy to clipboard operation
dagu copied to clipboard

feat: support event-based DAG triggers

Open quenck opened this issue 3 months ago • 10 comments

Is your feature request related to a problem?

Dagu currently provides scheduled DAG execution and webhook-based triggering, but there is no generic mechanism to trigger a DAG only when an external event occurs.

A common use case is processing files delivered to remote systems such as SFTP.

For example, I have around 30 SFTP directories that need to be checked only once per hour or once per day. With the current scheduling approach, the DAG must run on every scheduled interval even when there is nothing to process.

This results in unnecessary DAG runs:

09:00 → DAG starts → no files → exit 10:00 → DAG starts → no files → exit 11:00 → DAG starts → file found → process file 12:00 → DAG starts → no files → exit

The polling itself is inexpensive, but these empty runs unnecessarily add entries to the DAG run history and make monitoring and operational reporting less meaningful.

Describe the solution you’d like

Add support for event-based DAG triggers that separate event detection from DAG execution.

An event source could monitor an external resource and only create a DAG run when the configured event occurs.

For example, an SFTP trigger could look conceptually like:

triggers:

  • type: sftp host: sftp.example.com path: /incoming/*.csv poll_interval: 1h

When a matching file is detected:

SFTP event ↓ trigger matches ↓ DAG run is created ↓ workflow processes the file

When no matching file exists, no DAG run should be created.

The trigger mechanism should ideally be generic enough to support multiple event sources in the future, rather than being limited to SFTP.

Potential event sources could include:

  • SFTP / FTP file arrival
  • local filesystem changes
  • S3/object storage events
  • message queues
  • external webhooks
  • other polling-based external resources

For file-based triggers, the event payload could expose information such as the file path, filename, size, modification time, and possibly other metadata as DAG parameters.

Describe alternatives you’ve considered

Scheduled DAG

A scheduled DAG can periodically check the SFTP directory and conditionally continue:

schedule: "0 * * * *" steps:

  • check-sftp
  • process-file

This works, but still creates a DAG run when no file is available.

External watcher

Another option is to run a separate service that monitors SFTP and invokes Dagu through its API or CLI when a file arrives.

This avoids empty DAG runs, but introduces another long-running service that has to be deployed, monitored, authenticated, and maintained.

It would be preferable if Dagu could provide this functionality as part of its existing scheduling/trigger infrastructure.

Use case

A concrete use case is an integration system with approximately 30 SFTP directories.

Some directories need to be checked hourly, others daily. When a new file arrives, a corresponding Dagu workflow should process it.

For example:

/incoming/customer-a/.csv → customer-a DAG /incoming/customer-b/.xml → customer-b DAG /incoming/customer-c/*.json → customer-c DAG

The desired behavior is:

                 SFTP
                   │
             event detected
                   │
                   ▼
            Dagu trigger
                   │
                   ▼
              DAG run
                   │
                   ▼
            process file

rather than:

              scheduler
                  │
          every hour/day
                  │
                  ▼
               DAG run
                  │
            ┌─────┴─────┐
            │           │
         file?         no file
            │             │
           yes            └── exit
            │
            ▼
         process

An important requirement would be avoiding duplicate processing if the trigger polls for events. Some form of event identity, persisted trigger state, or idempotency mechanism would therefore be useful.

Additional context

Dagu already has SFTP functionality as workflow actions, so this proposal is specifically about making external events capable of starting a DAG rather than only being consumed by an already-running DAG.

The existing webhook trigger model could potentially provide a useful conceptual basis for this feature.

The main goal is not necessarily real-time file watching. Even relatively slow polling intervals such as 1 hour or 1 day would be useful, provided that polling does not result in empty DAG runs.

quenck avatar Aug 11 '26 07:08 quenck

I second this feature request. We should have a provision for this kind of ingest.

We are doing this but not via dagu but custom ho code that uses fsnotify to detect landing of files and ingest dags remotely.

May be a generic component as proposed could be developed. Or we can think of client mode for dagu which could be installed on a remote system as well which connects to server and trigger dags on remote events. It may be helpful in such cases where we have a multihost machine that connects two networks which forwards events listened from one network to trigger events on dagu running in a different network.

ghansham avatar Aug 14 '26 00:08 ghansham

This feature woudl be really helpful for me as well.

LouisDeconinck avatar Sep 01 '26 16:09 LouisDeconinck

What kind of event trigger should we support?

  • SFTP
  • S3
  • File

Any other suggestions?

yohamta0 avatar Sep 01 '26 16:09 yohamta0

For my use case, one additional trigger type would be especially valuable: a generic HTTP/API polling trigger.

I use Dagu for data pipelines where many sources do not provide webhooks. A common pattern is:

  • poll an HTTP endpoint periodically
  • extract some value such as updated_at, an ETag, version, checksum, latest record ID, or response hash
  • compare it with the value from the previous poll
  • create a DAG run only when that value changes
  • pass the detected value / response metadata to the DAG as parameters

Conceptually:

triggers:
  - type: http
    url: https://example.com/data/latest
    poll_interval: 1h
    condition:
      changed: $.updated_at

This would cover a very large class of data-ingestion "sensors" without Dagu having to implement a dedicated trigger for every external system.

For example, in my data platform I might have:

  • SFTP → new source file
  • S3 → new object
  • HTTP/API → new source version or changed data
  • File → new/changed local file

I think the important abstraction is therefore less "SFTP/S3/File triggers" and more polling sensors with persisted state, where a sensor produces an event only when its observed state changes.

It would also be useful if the trigger exposed a stable event ID / observed value so the resulting DAG can be idempotent and duplicate events can be suppressed.

LouisDeconinck avatar Sep 01 '26 20:09 LouisDeconinck

We're looking into adding event triggers. If we offered production-ready SFTP, S3, file, and HTTP polling triggers for $50/month, would your team pay for that? Just doing some research right now to see if there's real interest, so honest feedback is welcome. Nothing is locked in yet.

yohamta0 avatar Sep 02 '26 07:09 yohamta0

For me, no. This would be a nice quality of life feature, but not something I would pay $50/month for.

LouisDeconinck avatar Sep 02 '26 07:09 LouisDeconinck

@yohamta0 can i make a draft with a plan?

kriyanshii avatar Sep 17 '26 09:09 kriyanshii

Thank you, but I feel like this feature should not be part of Dagu.

yohamta0 avatar Sep 17 '26 09:09 yohamta0

@yohamta0 this is a good first step: #3344 why no other triggers?

quenck avatar Nov 27 '26 10:11 quenck

@quenck watch only handles local folders. For SFTP, S3, HTTP and so on, I'm planning a generic poll instead of a trigger per source: you give a DAG a command, and each new line it prints starts a run. Checks that find nothing don't create runs. Feedback will be welcome!

RFC: https://github.com/dagucloud/dagu/blob/main/rfcs/004-triggers.md Tracking: #4277

yohamta0 avatar Nov 27 '26 11:11 yohamta0