Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加了sentinel-prometheus相关依赖,但是9092端口无法被监听,配置设置csp.sentinel.prometheus.fetch.port=9093也无效 #3433

Open
heqs opened this issue Jul 20, 2024 · 1 comment

Comments

@heqs
Copy link

heqs commented Jul 20, 2024

按照文档,在我的spring boot项目中增加3个依赖

<dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>sentinel-prometheus-metric-exporter</artifactId>
            <version>1.8.7</version>
        </dependency>
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient</artifactId>
            <version>0.3.0</version>
        </dependency>
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_httpserver</artifactId>
            <version>0.3.0</version>
        </dependency>

因为一个服务器下面会运行多个spring boot项目,且每个项目都需要暴露sentinel监控数据给 prometheus,于是涉及端口占用问题,需要自定义端口
bootstrap.yml增加自定义端口,这个端口不会被监听,还是会使用9092启动,于是只有第一个启动的应用可以暴露数据

csp:
  sentinel:
    prometheus:
      fetch:
        port: 9093

csp.sentinel.prometheus.fetch.port 这个配置应该如何配置呢?请教

@heqs
Copy link
Author

heqs commented Jul 21, 2024

按照文档,在我的spring boot项目中增加3个依赖

<dependency>
            <groupId>com.alibaba.csp</groupId>
            <artifactId>sentinel-prometheus-metric-exporter</artifactId>
            <version>1.8.7</version>
        </dependency>
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient</artifactId>
            <version>0.3.0</version>
        </dependency>
        <dependency>
            <groupId>io.prometheus</groupId>
            <artifactId>simpleclient_httpserver</artifactId>
            <version>0.3.0</version>
        </dependency>

因为一个服务器下面会运行多个spring boot项目,且每个项目都需要暴露sentinel监控数据给 prometheus,于是涉及端口占用问题,需要自定义端口 bootstrap.yml增加自定义端口,这个端口不会被监听,还是会使用9092启动,于是只有第一个启动的应用可以暴露数据

csp:
  sentinel:
    prometheus:
      fetch:
        port: 9093

csp.sentinel.prometheus.fetch.port 这个配置应该如何配置呢?请教

已解决,看了源代码https://github.com/alibaba/Sentinel/blob/1.8/sentinel-core/src/main/java/com/alibaba/csp/sentinel/config/SentinelConfigLoader.java#L82,原来需要单独写在下面这个配置文件当中:
private static final String DEFAULT_SENTINEL_CONFIG_FILE = "classpath:sentinel.properties";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant