Repository: kestra-io/kestra
Issue: Remove the log ID display to save space in the Logs view
Labels: enhancement

### Feature description

Side-by-side comparison of before and after

(the more compact view on the left is preferrable)

![image](https://github.com/kestra-io/kestra/assets/86264395/e2c927ea-a0f3-4bae-9305-1cde43ae7db2)


Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/core/src/main/java/io/kestra/core/models/executions/LogEntry.java b/core/src/main/java/io/kestra/core/models/executions/LogEntry.java
index 4131b54bef..64e803a0ff 100644
--- a/core/src/main/java/io/kestra/core/models/executions/LogEntry.java
+++ b/core/src/main/java/io/kestra/core/models/executions/LogEntry.java
@@ -1,13 +1,11 @@
 package io.kestra.core.models.executions;
 
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import io.kestra.core.models.DeletedInterface;
 import io.kestra.core.models.TenantInterface;
 import io.kestra.core.models.flows.Flow;
 import io.kestra.core.models.triggers.AbstractTrigger;
 import io.kestra.core.models.triggers.TriggerContext;
-import io.kestra.core.utils.IdUtils;
 import io.micronaut.core.annotation.Nullable;
 import io.swagger.v3.oas.annotations.Hidden;
 import lombok.Builder;
@@ -24,9 +22,6 @@
 @Value
 @Builder(toBuilder = true)
 public class LogEntry implements DeletedInterface, TenantInterface {
-    @NotNull
-    String id;
-
     @Hidden
     @Pattern(regexp = "^[a-z0-9][a-z0-9_-]*")
     String tenantId;
@@ -78,7 +73,6 @@ public static List<String> findLevelsByMin(Level minLevel) {
 
     public static LogEntry of(Execution execution) {
         return LogEntry.builder()
-            .id(IdUtils.create())
             .tenantId(execution.getTenantId())
             .namespace(execution.getNamespace())
             .flowId(execution.getFlowId())
@@ -88,7 +82,6 @@ public static LogEntry of(Execution execution) {
 
     public static LogEntry of(TaskRun taskRun) {
         return LogEntry.builder()
-            .id(IdUtils.create())
             .tenantId(taskRun.getTenantId())
             .namespace(taskRun.getNamespace())
             .flowId(taskRun.getFlowId())
@@ -101,7 +94,6 @@ public static LogEntry of(TaskRun taskRun) {
 
     public static LogEntry of(Flow flow, AbstractTrigger abstractTrigger) {
         return LogEntry.builder()
-            .id(IdUtils.create())
             .tenantId(flow.getTenantId())
             .namespace(flow.getNamespace())
             .flowId(flow.getId())
@@ -111,7 +103,6 @@ public static LogEntry of(Flow flow, AbstractTrigger abstractTrigger) {
 
     public static LogEntry of(TriggerContext triggerContext, AbstractTrigger abstractTrigger) {
         return LogEntry.builder()
-            .id(IdUtils.create())
             .tenantId(triggerContext.getTenantId())
             .namespace(triggerContext.getNamespace())
             .flowId(triggerContext.getFlowId())
diff --git a/core/src/main/java/io/kestra/core/queues/QueueService.java b/core/src/main/java/io/kestra/core/queues/QueueService.java
index 281365c5ca..dc44d6fc4e 100644
--- a/core/src/main/java/io/kestra/core/queues/QueueService.java
+++ b/core/src/main/java/io/kestra/core/queues/QueueService.java
@@ -24,7 +24,7 @@ public String key(Object object) {
         } else if (object.getClass() == WorkerTaskResult.class) {
             return ((WorkerTaskResult) object).getTaskRun().getId();
         } else if (object.getClass() == LogEntry.class) {
-            return ((LogEntry) object).getId();
+            return null;
         } else if (object.getClass() == Flow.class) {
             return ((Flow) object).uid();
         } else if (object.getClass() == Template.class) {
diff --git a/core/src/main/java/io/kestra/core/repositories/LogRepositoryInterface.java b/core/src/main/java/io/kestra/core/repositories/LogRepositoryInterface.java
index 3b144d8cfe..085de2cb38 100644
--- a/core/src/main/java/io/kestra/core/repositories/LogRepositoryInterface.java
+++ b/core/src/main/java/io/kestra/core/repositories/LogRepositoryInterface.java
@@ -42,5 +42,5 @@ ArrayListTotal<LogEntry> find(
 
     Integer purge(Execution execution);
 
-    void delete(LogEntry logEntry);
+    void deleteByQuery(String tenantId, String executionId, String taskId, String taskRunId, Level minLevel, Integer attempt);
 }
diff --git a/core/src/main/java/io/kestra/core/runners/RunContextLogger.java b/core/src/main/java/io/kestra/core/runners/RunContextLogger.java
index 3947d108e5..5f219e2749 100644
--- a/core/src/main/java/io/kestra/core/runners/RunContextLogger.java
+++ b/core/src/main/java/io/kestra/core/runners/RunContextLogger.java
@@ -66,7 +66,6 @@ private static List<LogEntry> logEntry(ILoggingEvent event, String message, org.
         long i = 0;
         for (String s : split) {
             result.add(LogEntry.builder()
-                .id(IdUtils.create())
                 .namespace(logEntry.getNamespace())
                 .tenantId(logEntry.getTenantId())
                 .flowId(logEntry.getFlowId())
diff --git a/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcLogRepository.java b/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcLogRepository.java
index 2966b93e26..c03de4077e 100644
--- a/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcLogRepository.java
+++ b/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcLogRepository.java
@@ -188,8 +188,35 @@ public LogEntry save(DSLContext dslContext, LogEntry logEntry) {
     }
 
     @Override
-    public void delete(LogEntry logEntry) {
-        this.jdbcRepository.delete(logEntry);
+    public void deleteByQuery(String tenantId, String executionId, String taskId, String taskRunId, Level minLevel, Integer attempt) {
+        this.jdbcRepository
+            .getDslContextWrapper()
+            .transaction(configuration -> {
+                DSLContext context = DSL.using(configuration);
+
+                var delete = context
+                    .delete(this.jdbcRepository.getTable())
+                    .where(this.defaultFilter(tenantId))
+                    .and(field("execution_id").eq(executionId));
+
+                if (taskId != null) {
+                    delete.and(field("task_id").eq(taskId));
+                }
+
+                if (taskRunId != null) {
+                    delete.and(field("taskrun_id").eq(taskRunId));
+                }
+
+                if (minLevel != null) {
+                    delete.and(minLevel(minLevel));
+                }
+
+                if (attempt != null) {
+                    delete.and(field("attempt_number").eq(attempt));
+                }
+
+                delete.execute();
+            });
     }
 
     private ArrayListTotal<LogEntry> query(String tenantId, Condition condition, Level minLevel, Pageable pageable) {
diff --git a/repository-memory/src/main/java/io/kestra/repository/memory/MemoryLogRepository.java b/repository-memory/src/main/java/io/kestra/repository/memory/MemoryLogRepository.java
index fc4223951f..52aa9646df 100644
--- a/repository-memory/src/main/java/io/kestra/repository/memory/MemoryLogRepository.java
+++ b/repository-memory/src/main/java/io/kestra/repository/memory/MemoryLogRepository.java
@@ -94,7 +94,7 @@ public Integer purge(Execution execution) {
     }
 
     @Override
-    public void delete(LogEntry logEntry) {
+    public void deleteByQuery(String tenantId, String executionId, String taskId, String taskRunId, Level minLevel, Integer attempt) {
         throw new UnsupportedOperationException();
     }
 }
diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/LogController.java b/webserver/src/main/java/io/kestra/webserver/controllers/LogController.java
index 8ac03fc203..6a7b08b88a 100644
--- a/webserver/src/main/java/io/kestra/webserver/controllers/LogController.java
+++ b/webserver/src/main/java/io/kestra/webserver/controllers/LogController.java
@@ -169,19 +169,6 @@ public void delete(
         @Parameter(description = "The task id") @Nullable @QueryValue String taskId,
         @Parameter(description = "The attempt number") @Nullable @QueryValue Integer attempt
     ) {
-        List<LogEntry> logEntries;
-        if (taskId != null) {
-            logEntries = logRepository.findByExecutionIdAndTaskId(tenantService.resolveTenant(), executionId, taskId, minLevel);
-        } else if (taskRunId != null) {
-            if (attempt != null) {
-                logEntries = logRepository.findByExecutionIdAndTaskRunIdAndAttempt(tenantService.resolveTenant(), executionId, taskRunId, minLevel, attempt);
-            } else {
-                logEntries = logRepository.findByExecutionIdAndTaskRunId(tenantService.resolveTenant(), executionId, taskRunId, minLevel);
-            }
-        } else {
-            logEntries = logRepository.findByExecutionId(tenantService.resolveTenant(), executionId, minLevel);
-        }
-
-        logEntries.forEach(log -> logRepository.delete(log));
+        logRepository.deleteByQuery(tenantService.resolveTenant(), executionId, taskId, taskRunId, minLevel, attempt);
     }
 }


Test patch:
diff --git a/core/src/test/java/io/kestra/core/repositories/AbstractLogRepositoryTest.java b/core/src/test/java/io/kestra/core/repositories/AbstractLogRepositoryTest.java
index de8f22705e..ab8d7f887b 100644
--- a/core/src/test/java/io/kestra/core/repositories/AbstractLogRepositoryTest.java
+++ b/core/src/test/java/io/kestra/core/repositories/AbstractLogRepositoryTest.java
@@ -22,7 +22,6 @@ public abstract class AbstractLogRepositoryTest {
 
     private static LogEntry.LogEntryBuilder logEntry(Level level) {
         return LogEntry.builder()
-            .id(IdUtils.create())
             .flowId(IdUtils.create())
             .namespace("io.kestra.unittest")
             .taskId("taskId")
@@ -89,13 +88,13 @@ void Pageable() {
         builder.executionId(executionId);
 
         for (int i = 0; i < 80; i++) {
-            logRepository.save(builder.id(IdUtils.create()).build());
+            logRepository.save(builder.build());
         }
 
         builder = logEntry(Level.INFO).executionId(executionId).taskId("taskId2").taskRunId("taskRunId2");
         LogEntry logEntry2 = logRepository.save(builder.build());
         for (int i = 0; i < 20; i++) {
-            logRepository.save(builder.id(IdUtils.create()).build());
+            logRepository.save(builder.build());
         }
 
         ArrayListTotal<LogEntry> find = logRepository.findByExecutionId(null, executionId, null, Pageable.from(1, 50));
@@ -133,7 +132,7 @@ void delete() {
         LogEntry log1 = logEntry(Level.INFO).build();
         logRepository.save(log1);
 
-        logRepository.delete(log1);
+        logRepository.deleteByQuery(null, log1.getExecutionId(), null, null, null, null);
 
         ArrayListTotal<LogEntry> find = logRepository.findByExecutionId(null, log1.getExecutionId(), null, Pageable.from(1, 50));
         assertThat(find.size(), is(0));
diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/LogControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/LogControllerTest.java
index a746181576..74e2c8f527 100644
--- a/webserver/src/test/java/io/kestra/webserver/controllers/LogControllerTest.java
+++ b/webserver/src/test/java/io/kestra/webserver/controllers/LogControllerTest.java
@@ -62,7 +62,7 @@ void find() {
     @Test
     void findByExecution() {
         LogEntry log1 = logEntry(Level.INFO);
-        LogEntry log2 = log1.toBuilder().message("another message").id(IdUtils.create()).build();
+        LogEntry log2 = log1.toBuilder().message("another message").build();
         LogEntry log3 = logEntry(Level.DEBUG);
         logRepository.save(log1);
         logRepository.save(log2);
@@ -80,7 +80,7 @@ void findByExecution() {
     @Test
     void download() {
         LogEntry log1 = logEntry(Level.INFO);
-        LogEntry log2 = log1.toBuilder().message("another message").id(IdUtils.create()).build();
+        LogEntry log2 = log1.toBuilder().message("another message").build();
         LogEntry log3 = logEntry(Level.DEBUG);
         logRepository.save(log1);
         logRepository.save(log2);
@@ -97,7 +97,7 @@ void download() {
     @Test
     void delete() {
         LogEntry log1 = logEntry(Level.INFO);
-        LogEntry log2 = log1.toBuilder().message("another message").id(IdUtils.create()).build();
+        LogEntry log2 = log1.toBuilder().message("another message").build();
         LogEntry log3 = logEntry(Level.DEBUG);
         logRepository.save(log1);
         logRepository.save(log2);
@@ -117,7 +117,6 @@ void delete() {
 
     private static LogEntry logEntry(Level level) {
         return LogEntry.builder()
-            .id(IdUtils.create())
             .flowId(IdUtils.create())
             .namespace("io.kestra.unittest")
             .taskId("taskId")