【问题标题】:Spring Boot Admin: example for filtering notificationsSpring Boot Admin:过滤通知的示例
【发布时间】:2020-01-13 11:35:42
【问题描述】:

我想在 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 我也没有看到任何配置特定过滤器的代码。

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

【问题讨论】:

    标签: spring-boot-admin


    【解决方案1】:

    我做了一些进一步的调查,发现它是如何工作的——也许这对某人有帮助。通知过滤的 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 就足够了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多