Spring Boot Admin:过滤通知的示例

Spring Boot Admin: example for filtering notifications

我想使用 Spring Boot Admin 中的通知过滤功能(参见 http://codecentric.github.io/spring-boot-admin/current/#filtering-notifications )但是不知道如何配置文档中提到的过滤规则或使用什么 HTTP 请求确切地说,它们可以是 added/removed。有人有这种配置的例子吗? (例如,从通知中排除具有特定名称模式的应用程序或禁用所有通知;激活此类规则的 HTTP 请求的 curl 命令?)

文档中的示例代码:

@Bean
    public FilteringNotifier filteringNotifier() { 
        CompositeNotifier delegate = new CompositeNotifier(this.otherNotifiers.getIfAvailable(Collections::emptyList));
        return new FilteringNotifier(delegate, this.repository);
    }

这似乎没有配置任何特定规则。 在 https://github.com/codecentric/spring-boot-admin/tree/master/spring-boot-admin-samples/spring-boot-admin-sample-servlet 中,我也没有看到任何配置特定过滤器的代码。

这是否足够或是否需要额外的配置代码?

我做了一些进一步的调查,发现了它是如何工作的——也许这对某人有帮助。通知过滤的 REST 请求由以下代码处理:NotificationController.java

从代码中可以看出可以实现以下请求:

# filter notifications for application xxx for the next 10000 milliseconds
# (ttl is optional)
curl -d "applicationName=xxx&ttl=10000" -X POST http(s)://.../notifications/filters

# filter notifications for instanceId yyy for the next 10000 milliseconds
# (ttl is optional)
curl -d "instanceId=yyy&ttl=10000" -X POST http(s)://.../notifications/filters

# Get all added notification filters with their ids
curl http(s)://.../notifications/filters

# Delete notification filter with id <id>
curl -X DELETE http(s)://.../notifications/filters/<id>

如有必要,必须添加身份验证。无需对 Spring Boot Admin 应用程序进行其他更改即可使其正常工作,注册 FilteringNotifier 就足够了。