Netflix / maestro

Maestro: Netflix’s Workflow Orchestrator
Apache License 2.0
3.33k stars 201 forks source link

How do I subscribe to events? #75

Open agardnerIT opened 3 months ago

agardnerIT commented 3 months ago

I'm new to maestro and it looks great. I'm following the example workflow and can see the workflow executing in the logs with logs like this:

RunResponse(workflowId=sample-dag-test-1, workflowVersionId=1, workflowInstanceId=1, workflowRunId=1, workflowUuid=f5fd3577-a6b7-4ba5-9bdc-c80b36a02dcc,
status=WORKFLOW_RUN_CREATED,
timelineEvent=TimelineLogEvent(timestamp=1723858281027, level=INFO, message=Manually run a new workflow instance by a user [tester]), stepId=null, stepAttemptId=null

I want to "hook into" the "workflow finished" event then get the step + timing summary to reconstruct the run and perform my own logic.

For example:

  1. Workflow finished event received
  2. Use API to get all steps, execution status and timing

Then I can recreate something like this:

2024-08-17 10:00:00 INFO Workflow started
2024-08-17 10:02:00 INFO Step 1 started
2024-08-17 10:05:00 INFO Step 1 finished. Success.
2024-08-17 10:05:01 INFO Step 2 started
2024-08-17 10:05:01 INFO Step 3 started
2024-08-17 10:08:00 INFO Step 2 finished. Success.
2024-08-17 10:09:00 INFO Step 3 finished. Fail
2024-08-17 10:00:00 INFO Workflow finished

Any docs on how to achieve this? I can't see an OpenAPI URL so don't know the API endpoints.

Metrics / Prometheus

Digging deeper, I see lots of metrics are available in Cockroach and MaestroMetrics but there's no docs on how to access any of these: http://localhost:8080/_status/vars (as suggested by Cockroach) doesn't lead me anywhere.

jun-he commented 3 months ago

@agardnerIT Yep, maestro is capable of publishing events for external systems. It depends on which mechanism your downstream service uses. Then you can implement MaestroNotificationPublisher interface. The current implementation is NoOpMaestroNotificationPublisher, which just prints out the events.

If you use Kafka or SNS, you can add a producer to send out the events. If you have a webservice, you can simply add a rest API call to pass the events to your service over a REST API.