首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring Boot Admin:过滤通知的示例

Spring Boot Admin:过滤通知的示例
EN

Stack Overflow用户
提问于 2019-09-11 23:24:22
回答 1查看 568关注 0票数 0

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

文档中的示例代码:

代码语言:javascript
复制
@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中,我也看不到任何配置特定过滤器的代码。

这足够了吗?还是需要额外的配置代码?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-05 23:19:30

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

从代码中可以看到,以下请求是可能的:

代码语言:javascript
复制
# 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即可。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57892340

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档