Skip to content

[DSIP-107] Add separate workflow instance logs for UI viewing, similar to task logs.#18130

Open
njnu-seafish wants to merge 21 commits into
apache:devfrom
njnu-seafish:DSIP-107
Open

[DSIP-107] Add separate workflow instance logs for UI viewing, similar to task logs.#18130
njnu-seafish wants to merge 21 commits into
apache:devfrom
njnu-seafish:DSIP-107

Conversation

@njnu-seafish
Copy link
Copy Markdown
Contributor

@njnu-seafish njnu-seafish commented Apr 2, 2026

Was this PR generated or assisted by AI?

NO

Purpose of the pull request

This is an implementation scheme for separating workflow logs. close #18129

Brief change log

Add separate workflow instance logs for UI viewing, similar to task logs.

Verify this pull request

I have already tested and verified this solution in my local environment.

The log_path field in the t_ds_workflow_instance table:
企业微信截图_17750360711830

Dedicated log files for workflow instances on the Master service:
企业微信截图_17750363662591

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

@SbloodyS SbloodyS changed the title [Dsip-107]Add separate workflow instance logs for UI viewing, similar to task logs. [DSIP-107] Add separate workflow instance logs for UI viewing, similar to task logs. Apr 3, 2026
@SbloodyS SbloodyS added the DSIP label Apr 3, 2026
SbloodyS and others added 4 commits April 3, 2026 15:52
# Conflicts:
#	dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/WorkflowEventBusFireWorker.java
#	dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/dispatcher/WorkerGroupDispatcher.java
#	dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/statemachine/AbstractWorkflowStateAction.java
#	dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/failover/TaskFailover.java
#	dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/TaskExecutorEventListenerImpl.java
#	dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/rpc/TaskInstanceControllerImpl.java
Comment on lines +99 to +104
workflowInstance.setLogPath(WorkflowLogUtils.getWorkflowInstanceLogFullPath(
workflowInstance.getStartTime(),
workflowInstance.getWorkflowDefinitionCode(),
workflowInstance.getWorkflowDefinitionVersion(),
workflowInstance.getId()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best to inject the log path at runtime. You can write the code at CommandEngine, can add a new field at WorkflowStartLifecycleEvent.

Copy link
Copy Markdown
Contributor Author

@njnu-seafish njnu-seafish May 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best to inject the log path at runtime. You can write the code at CommandEngine, can add a new field at WorkflowStartLifecycleEvent.

That's a great idea! With your guidance, I found an even better way to implement it: we can uniformly set the logPath value in the abstract parent class AbstractCommandHandler.

protected void assembleWorkflowInstanceLogPath(final WorkflowExecuteContextBuilder workflowExecuteContextBuilder) {
final WorkflowInstance workflowInstance = workflowExecuteContextBuilder.getWorkflowInstance();
final Date logTime = workflowInstance.getRestartTime() != null
? workflowInstance.getRestartTime()
: workflowInstance.getStartTime();
final String logPath = WorkflowLogUtils.getWorkflowInstanceLogFullPath(
logTime,
workflowInstance.getWorkflowDefinitionCode(),
workflowInstance.getWorkflowDefinitionVersion(),
workflowInstance.getId());
workflowInstance.setLogPath(logPath);
workflowInstanceDao.updateById(workflowInstance);
workflowExecuteContextBuilder.setWorkflowInstance(workflowInstance);
}

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 60%)

See analysis details on SonarQube Cloud

@Setter
public class WorkflowLogDiscriminator extends AbstractDiscriminator<ILoggingEvent> {

private String key;
*/

ALTER TABLE `t_ds_workflow_instance`
ADD COLUMN `log_path` longtext NULL COMMENT 'workflow instance log path'; No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ADD COLUMN `log_path` longtext NULL COMMENT 'workflow instance log path';
ADD COLUMN `log_path` longtext NULL COMMENT 'workflow instance log path';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ADD COLUMN log_path longtext NULL COMMENT 'workflow instance log path';

ok,thanks

</sift>
</appender>

<appender name="WORKFLOWLOGFILE" class="ch.qos.logback.classic.sift.SiftingAppender">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rollingPolicy should be added here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rollingPolicy should be added here.

Since the logs for a single task don't use the rolling policy, does that mean the logs for a single workflow don't need it either?

Later, we'll need to add an entry point in the UI to view logs for a single workflow. If we use the rolling policy, would that be inappropriate?

@njnu-seafish
Copy link
Copy Markdown
Contributor Author

@ruanwenjun @SbloodyS Could you please help review the solution and the code?

I sincerely apologize for the delay on this PR. I've been caught up with some urgent company matters recently and haven't had the time to work on it.
I spent some time optimizing it tonight, and I've verified through actual testing that it works as expected.

企业微信截图_17787572661562 企业微信截图_17787573849626

@github-actions github-actions Bot added UI ui and front end related test labels May 21, 2026
@njnu-seafish
Copy link
Copy Markdown
Contributor Author

@ruanwenjun @SbloodyS Could you please help review the solution and the code? Thanks.
Here are the main updates I've implemented:

  1. Master: Added a standalone log file specifically for workflow instances.
  2. ApiServer: Implemented both the backend endpoints and the frontend UI to support querying and downloading workflow logs."
  3. Added logic to delete workflow instance logs when deleting a workflow instance.

This has been tested and verified in a real-world environment. Please see the UI below:
screenshot_1779361671483

screenshot_1779361763966

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend DSIP test UI ui and front end related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DSIP-107][Master] Add separate workflow instance logs for UI viewing similar to task logs.

4 participants