我想使用Spring Boot Admin中的通知过滤功能(请参阅http://codecentric.github.io/spring-boot-admin/current/#filtering-notifications ),但是我不知道文档中提到的过滤规则是如何配置的,也不知道使用什么HTTP请求可以添加/删除它们。有人有这样一个配置的例子吗?(例如,从通知中排除具有特定名称模式的应用程序或禁用所有通知;对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中,我也看不到任何配置特定过滤器的代码。
这足够了吗?还是需要额外的配置代码?
发布于 2019-10-05 23:19:30
我做了进一步的调查,找出了它是如何工作的--也许这对某人有帮助。通知过滤的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即可。
https://stackoverflow.com/questions/57892340
复制相似问题