alibaba / Sentinel

A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
https://sentinelguard.io/
Apache License 2.0
22.41k stars 8.03k forks source link

sentinel-dashboard 的监控数据持久化扩展方式希望可以更优雅一些 #408

Open techzealot opened 5 years ago

techzealot commented 5 years ago

Issue Description

Type: feature request

Describe what happened (or what feature you want)

sentinel-dashboard的监控数据持久化扩展方式必须通过修改源码的替换 MetricsRepository 的实现

// Sentinel-dashboard's monitoring data persistence extension must be implemented by modifying the source code to replace MetricsRepository

Describe what you expected to happen

可以实现类似 Spring Boot 条件bean,只在不存在用户自定义的 MetricsRepository 实现时采用 InMemoryMetricsRepository 实现。

好处有:

  1. 自定义实现时用户可以在 sentinel-dashboard 中添加一个自定义实现的jar(META-INF/spring.factories 中实现自动注入其他持久化实现)即可实现数据持久化的切换。
  2. 这样 sentinel-dashboard 升级后,只需要引入jar,重新打包即可,无需修改sentinel-dashboard源码,更进一步,用户可以不用重新打包,在启动命令中将该自定义jar加入类路径这样可以实现sentinel-dashboard与自定义jar分离,升级无任何依赖。

// English translation:

Mechanism like Spring Boot conditional bean can be implemented, using the InMemoryMetricsRepository implementation only when there is no user-defined MetricsRepository implementation.

The benefits are:

  1. In the custom implementation, users can add a custom implementation jar in the sentinel-dashboard (automatically inject other persistence implementations in META-INF/spring.factories) to achieve data persistence switching.
  2. After the upgrade of the sentinel-dashboard, you only need to introduce the jar and repackage it. You don't need to modify the sentinel-dashboard source code. Further, the user can repackage the custom jar in the startup command. Sentinel-dashboard is separated from the custom jar, the upgrade has no dependencies.
sczyh30 commented 5 years ago

Hi, thanks for your suggestion. It's a good idea for more flexible dashboard extension. We can have a try for it in later versions. And PRs are welcomed if you're going to implement this :)

finefuture commented 5 years ago

我已经在本地的sentinel-dashboard扩展了接入Apollo配置中心,允许在dashboard和Apollo portal之间双向修改流控等规则,采用的是spring的@ConditionalOnProperty注解实现了你说的切换DataSource的功能,只需要在启动时加入-DruleDataSource = apollo 或者inMemory即可确定使用哪种实现

ghost commented 5 years ago

监控数据一般持久化到哪里?有Es的实现方式吗?