From d427537b2cfc98c46aa4d9bbe57529ed25ff1677 Mon Sep 17 00:00:00 2001 From: Marco Pfatschbacher Date: Thu, 22 Jul 2021 18:48:43 +0200 Subject: [PATCH] Add cluster wide Loggers endpoint (#10882) We currently only support changing entire subsystems on the entire cluster. For debugging specific problems it might help to change the loglevel of classes under a certain package name. E.g.: http --auth admin:admin put :9000/api/cluster/system/loggers/org.graylog.plugins.events/level/DEBUG X-Requested-By:httpie --- .../resources/cluster/ClusterLoggersResource.java | 12 ++++++++++++ .../resources/system/logs/RemoteLoggersResource.java | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/graylog2-server/src/main/java/org/graylog2/rest/resources/cluster/ClusterLoggersResource.java b/graylog2-server/src/main/java/org/graylog2/rest/resources/cluster/ClusterLoggersResource.java index 6636d6a7f6bd..45a1a053efee 100644 --- a/graylog2-server/src/main/java/org/graylog2/rest/resources/cluster/ClusterLoggersResource.java +++ b/graylog2-server/src/main/java/org/graylog2/rest/resources/cluster/ClusterLoggersResource.java @@ -96,4 +96,16 @@ public void setSubsystemLoggerLevel( remoteLoggersResource.setSubsystemLoggerLevel(subsystemTitle, level).execute(); } + + @PUT + @Timed + @Path("/{loggerName}/level/{level}") + @ApiOperation(value = "Set the loglevel of a single logger", + notes = "Provided level is falling back to DEBUG if it does not exist") + @NoAuditEvent("proxy resource, audit event will be emitted on target nodes") + public Map> setClusterSingleLoggerLevel( + @ApiParam(name = "loggerName", required = true) @PathParam("loggerName") @NotEmpty String loggerName, + @ApiParam(name = "level", required = true) @PathParam("level") @NotEmpty String level) throws NodeNotFoundException, IOException { + return requestOnAllNodes(createRemoteInterfaceProvider(RemoteLoggersResource.class), client -> client.setSingleLoggerLevel(loggerName, level)); + } } diff --git a/graylog2-server/src/main/java/org/graylog2/rest/resources/system/logs/RemoteLoggersResource.java b/graylog2-server/src/main/java/org/graylog2/rest/resources/system/logs/RemoteLoggersResource.java index 188e4cfe87ef..18709d43e33a 100644 --- a/graylog2-server/src/main/java/org/graylog2/rest/resources/system/logs/RemoteLoggersResource.java +++ b/graylog2-server/src/main/java/org/graylog2/rest/resources/system/logs/RemoteLoggersResource.java @@ -35,7 +35,7 @@ public interface RemoteLoggersResource { Call setSubsystemLoggerLevel(@Path("subsystem") String subsystemTitle, @Path("level") String level); @PUT("system/loggers/{loggerName}/level/{level}") - Call setSingleLoggerLevel(String loggerName, String level); + Call setSingleLoggerLevel(@Path("loggerName") String loggerName, @Path("level") String level); @GET("system/loggers/messages/recent") Call messages(int limit, String level);