sentinel 报fetch metric解决方法

微生俊名
2023-12-01

1.今天在本地搭建sentinel,发现发送请求后,在sentinel控制台监控不到发送的请求,查看sentinel控制后发现报如下错误:
 

2021-02-25 14:31:58.024 ERROR 26384 --- [pool-2-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : fetch metric http://10.11.13.82:8720/metric?startTime=1614234702000&endTime=1614234708000&refetch=false error

java.net.SocketException: Permission denied: no further information
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_281]
        at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source) ~[na:1.8.0_281]
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:171) [httpcore-nio-4.4.6.jar!/:4.4.6]
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:145) [httpcore-nio-4.4.6.jar!/:4.4.6]
        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348) [httpcore-nio-4.4.6.jar!/:4.4.6]
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:194) [httpasyncclient-4.1.3.jar!/:4.1.3]
        at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64) [httpasyncclient-4.1.3.jar!/:4.1.3]
        at java.lang.Thread.run(Unknown Source) [na:1.8.0_281]

2021-02-25 14:31:58.964 ERROR 26384 --- [pool-2-thread-1] c.a.c.s.dashboard.metric.MetricFetcher   : fetch metric http://10.11.13.82:8720/metric?startTime=1614234709000&endTime=1614234715000&refetch=false error

java.net.SocketException: Permission denied: no further information
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_281]
        at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source) ~[na:1.8.0_281]
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:171) [httpcore-nio-4.4.6.jar!/:4.4.6]
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:145) [httpcore-nio-4.4.6.jar!/:4.4.6]
        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348) [httpcore-nio-4.4.6.jar!/:4.4.6]
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:194) [httpasyncclient-4.1.3.jar!/:4.1.3]
        at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64) [httpasyncclient-4.1.3.jar!/:4.1.3]
        at java.lang.Thread.run(Unknown Source) [na:1.8.0_281]

2021-02-25 14:31:59.504 ERROR 26384 --- [pool-1-thread-1] c.a.c.s.d.client.SentinelApiClient       : HTTP request failed: http://10.11.13.82:8720/jsonTree?type=root

java.net.SocketException: Permission denied: no further information
        at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.8.0_281]
        at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source) ~[na:1.8.0_281]
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvent(DefaultConnectingIOReactor.java:171) [httpcore-nio-4.4.6.jar!/:4.4.6]
        at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:145) [httpcore-nio-4.4.6.jar!/:4.4.6]
        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:348) [httpcore-nio-4.4.6.jar!/:4.4.6]
        at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:194) [httpasyncclient-4.1.3.jar!/:4.1.3]
        at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64) [httpasyncclient-4.1.3.jar!/:4.1.3]
        at java.lang.Thread.run(Unknown Source) [na:1.8.0_281]

2021-02-25 14:31:59.505 ERROR 26384 --- [nio-8080-exec-7] c.a.c.s.d.client.SentinelApiClient       : Error when fetching items from api: jsonTree -> root

java.util.concurrent.ExecutionException: java.net.SocketException: Permission denied: no further information
        at java.util.concurrent.CompletableFuture.reportGet(Unknown Source) ~[na:1.8.0_281]
        at java.util.concurrent.CompletableFuture.get(Unknown Source) ~[na:1.8.0_281]
        at com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient.fetchItems(SentinelApiClient.java:374) [classes!/:na]
        at com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient.fetchResourceOfMachine(SentinelApiClient.java:441) [classes!/:na]
        at com.alibaba.csp.sentinel.dashboard.controller.ResourceController.fetchResourceChainListOfMachine(ResourceController.java:70) [classes!/:na]

2.这个是因为sentinel发送客户端心跳失败了,查看了我的本地ip地址发现sentinel获取的ip地址不对,所以在配置文件中指点一下clientIp,我的配置如下:

server:
  port: 8401
spring:
  application:
    name: cloudalibab-sentinel-service
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
    sentinel:
      transport:
        dashboard: localhost:8080
        port: 8719
        clientIp: localhost
management:
  endpoints:
    web:
      exposure:
        include: '*'

3.在次重启sentinel控制台和微服务,发现不会报错了,服务接口也成功监控到了

 类似资料: