Tencent / spring-cloud-tencent

Spring Cloud Tencent is a Spring Cloud based Service Governance Framework provided by Tencent.
Other
3.14k stars 492 forks source link

自定义Prometheus拉取客户端的端口号失效 #1303

Closed wchappygood closed 4 weeks ago

wchappygood commented 1 month ago

版本: 1.12.4-2021.0.8

spring.cloud.polaris.stat.port设置成28085

image

### Tasks
wchappygood commented 1 month ago

image 这个对象初始化的时候, image 这个对象还没初始化导致,配置没有修改到

wchappygood commented 1 month ago

找到原因了 image

SkyeBeFreeman commented 1 month ago

如果使用bootstrap.yml做配置,需指定spring.cloud.polaris.enabled为true。

wchappygood commented 1 month ago

如果使用bootstrap.yml做配置,需指定spring.cloud.polaris.enabled为true。

我说下我的理解不知道对不对: 配置PolarisConfigBootstrapAutoConfiguration在bootstrap阶段就会创建PolarisContext,并把PolarisConfigModifier处理了, 而StatConfigModifier并非是bootstrap阶段,所以就无法修改配置了。

所以现在有没什么其他方法方法可以用配置中心的配置去修改配置,达到自定义端口的效果

SkyeBeFreeman commented 1 month ago

有PolarisStatPropertiesBootstrapConfiguration,那么bootstrap阶段,StatConfigModifier应该会生效才对

SkyeBeFreeman commented 1 month ago

在你的bootstrap.yml下加一个这个配置试试呢?

spring:
  config:
    import: optional:polaris
wchappygood commented 1 month ago

PolarisStatPropertiesBootstrapConfiguration

image 需要手动设置这个值才能生效 但是还是不能读取配置中心的配置来设置端口

wchappygood commented 1 month ago

在你的bootstrap.yml下加一个这个配置试试呢?

spring:
  config:
    import: optional:polaris

不得行,还是无法读取配置中心的配置设置端口

SkyeBeFreeman commented 1 month ago

@wchappygood 如下配置无法设置远端配置的端口吗?我这里尝试是可以的。

spring:
  config:
    import: optional:polaris
  cloud:
    polaris:
      enbaled: true
wchappygood commented 1 month ago

@wchappygood 如下配置无法设置远端配置的端口吗?我这里尝试是可以的。

spring:
  config:
    import: optional:polaris
  cloud:
    polaris:
      enbaled: true

可以改变。但是只能通过配置在bootstrap.yml才能生效。

SkyeBeFreeman commented 1 month ago

@wchappygood 你的诉求是,这个配置也只通过远程配置吗?

spring:
  cloud:
    polaris:
      enbaled: true

bootstrap.yml只留?

spring:
  config:
    import: optional:polaris
wchappygood commented 1 month ago

@wchappygood 你的诉求是,这个配置也只通过远程配置吗?

spring:
  cloud:
    polaris:
      enbaled: true

bootstrap.yml只留?

spring:
  config:
    import: optional:polaris

我们的诉求是spring.cloud.polaris.stat.port这个可以配置在配置中心,我们用bootstrap.yml启动的

SkyeBeFreeman commented 1 month ago

@wchappygood 我用这个配置,是可以支持你的需求的。 应用内bootstrap.yml:

spring:
  config:
    import: optional:polaris
  cloud:
    polaris:
      enbaled: true

配置中心:

image
wchappygood commented 4 weeks ago

spring.cloud.polaris.stat.port

谢谢成功了