代码之家  ›  专栏  ›  技术社区  ›  Artem

端点可能返回云配置

  •  0
  • Artem  · 技术社区  · 6 年前

    我有一个简单的控制器

    @RestController
    @RequestMapping("/metrics")
    public class MetricsController {
    
        @GetMapping
        @ApiOperation("Get metrics by source")
        public ResponseEntity<List<Metric>> getMetricBySource(@RequestParam String source) {
            if (source.equalsIgnoreCase("recordings")) {
                return new ResponseEntity<>(MetricsConstants.RECORDINGS_METRICS, HttpStatus.OK);
            } else if (source.equalsIgnoreCase("advertisers")) {
                return new ResponseEntity<>(MetricsConstants.ADVERTISERS_METRICS, HttpStatus.OK);
            } else if (source.equalsIgnoreCase("publishers")) {
                return new ResponseEntity<>(MetricsConstants.PUBLISHERS_METRICS, HttpStatus.OK);
            } else if (source.equalsIgnoreCase("partners")) {
                return new ResponseEntity<>(MetricsConstants.PARTNERS_METRICS, HttpStatus.OK);
            } else if (source.equalsIgnoreCase("products")) {
                return new ResponseEntity<>(MetricsConstants.PRODUCTS_METRICS, HttpStatus.OK);
            } else if (source.equalsIgnoreCase("regular-users")) {
                return new ResponseEntity<>(MetricsConstants.REGULAR_USERS_METRICS, HttpStatus.OK);
            }
    
            return null;
        }
    
    }
    

    现在,当我试图通过
    localhost:8099/metrics?source=advertisers

    我得到以下回应

    { “mem”:947258, “mem.free”:367038, “处理器”:4, “实例正常运行时间”:540532, “正常运行时间”:556754, “系统负载.平均值”:-1, “heap.committed”:854016, “heap.init”:260096, “使用的堆”:486977, “堆”:3699200, “nonheap.committed”:95312, “nonheap.init”:2496, “nonheap.used”:93242, “非堆”:0, “线程峰值”:61, “threads.daemon”:37, “threads.totalStarted”:128, “螺纹”:53, “类别”:13916, “加载的类”:13916, “已卸载的类”:0, “gc.ps\U清除计数”:13, “gc.ps\U清除时间”:150, “gc.ps\U marksweep.count”:3, “gc.ps\U标记扫描时间”:341, “计数器伺服eurekaclient传输请求”:0, “计数器、伺服、eurekaclient、传输、连接错误”:0, “计数器伺服超时”:0, “计数器伺服拒绝执行”:0, “计数器伺服可抛”:0, “使用的量规伺服螺纹池”:0, “仪表、伺服、响应、指标”:6, “标准化伺服静止总时间”:0, “标准化伺服静止计数”:0, “仪表伺服静止最小值”:0, “仪表伺服静止最大值”:0, “gauge.servo.eurekaclient.registration.lastheartbeatsec\u 00030”:0, “counter.servo.discoveryclient-httpclient\u重用”:10, “counter.servo.discoveryclient-httpclient\u createnew”:26, “计数器伺服发现客户端-httpclient\u请求”:36, “计数器伺服发现客户端-httpclient\u发布”:36, “counter.servo.discoveryclient-httpclient\u delete”:24, “normalized.servo.discoveryclient-httpclient\u requestconnectiontimer.totaltime”: 0.00504603333333333333, “normalized.servo.discoveryclient-httpclient\u requestconnectiontimer.count”: 0.066666666666667, “gauge.servo.discoveryclient-httpclient_requestconnectiontimer.min”: 0.017749, “gauge.servo.discoveryclient-httpclient\u requestconnectiontimer.max”: 0.1235629999999999, “normalized.servo.discoveryclient-httpclient\u createconnectiontimer.totaltime”: 0.0012743166666666665, “normalized.servo.discoveryclient-httpclient\u createconnectiontimer.count”: 0.05, “gauge.servo.discoveryclient-httpclient\u createconnectiontimer.min”: 0.012288, “gauge.servo.discoveryclient-httpclient\u createconnectiontimer.max”: 0.034475, “仪表伺服连接计数”:2, “normalized.servo.eurekaclient.transport.latency.totaltime”:0, “normalized.servo.eurekaclient.transport.latency.count”0, “gauge.servo.eurekaclient.transport.latency.min”0, “gauge.servo.eurekaclient.transport.latency.max”:0, “仪表、伺服、响应、星-星、favicon、ico”:42, “gauge.servo.eurekaclient.registry.lastupdatesec\u 00240”:0, “gauge.servo.eurekaclient.registration.lastheartbeatsec\u 00015”:1, “仪表、伺服、响应、webjars、star-star”:5, “gauge.servo.eurekaclient.resolver.endpointssize”:1, “gauge.servo.eurekaclient.resolver.lastloadtimestamp”:233376, “gauge.servo.eurekaclient.registration.lastheartbeatsec\u 00240”:0, “仪表、伺服、eurekaclient、传输、隔离”:0, “gauge.servo.eurekaclient.registry.lastupdatesec\u 00030”:0, “量规伺服响应v2 api文档”:126, “gauge.servo.eurekaclient.registration.lastheartbeatsec\u 00480”:0, “gauge.servo.eurekaclient.registry.lastupdatesec\u 00480”:0, “仪表.伺服.响应.星形”:13, “仪表.伺服.响应.招摇过市资源.配置.ui”:19, “标准化.伺服.尤里卡连接清理器时间.总时间”:0.00093866666666665, “标准化。伺服。eureka连接清理时间。计数”:0.03333333333333333333333, “仪表伺服eureka连接清洁时间min”:0.021162, “仪表伺服eureka连接清洁时间最大值”:0.035158, “计数器伺服eureka连接清洁器故障”:0, “仪表、伺服、eurekaclient、运输、当前会话时间”:533378, “gauge.servo.eurekaclient.registration.lastheartbeatsec\u 00120”:0, “gauge.servo.eurekaclient.registry.lastupdatesec\u 00015”:1, “仪表、伺服、响应、招摇资源、配置、安全”:4, “gauge.servo.eurekaclient.registry.lastupdatesec\u 00120”:0, “仪表伺服响应信息”:35, “gauge.servo.eurekaclient.registration.lastheartbeatsec\u 00060”:0, “gauge.servo.eurekaclient.registry.lastupdatesec\u 00060”:0, “counter.servo.discoveryclient\u reconcilehashcodemismatch”:0, “normalized.servo.discoveryclient\u fetchregistry.totaltime”:0.2970681500000003, “normalized.servo.discoveryclient\u fetchregistry.count”:0.03333333333333333333333, “gauge.servo.discoveryclient\u fetchregistry.min”:4.337664999999, “gauge.servo.discoveryclient\u fetchregistry.max”:13.486424, “计数器伺服发现客户端\u重新注册器”:0, “gauge.servo.eurekaclient.registry.localregistrysize”:5, “gauge.servo.eurekaclient.registry.lastsuccessfulregistryfetchtimeperiod”: 22920, “gauge.servo.eurekaclient.registration.lastsuccessfulheartbeattimeperiod”: 22926, “仪表、伺服、响应、招摇过市资源”:5, “integration.channel.errorChannel.errorRate.mean”0, “integration.channel.errorChannel.errorRate.max”0, “integration.channel.errorChannel.errorRate.min”0, “integration.channel.errorChannel.errorRate.stdev”:0, “integration.channel.errorChannel.errorRate.count”0, “integration.channel.errorChannel.sendCount”:0, “integration.channel.errorChannel.sendRate.mean”0, “integration.channel.errorChannel.sendRate.max”0, “integration.channel.errorChannel.sendRate.min”0, “integration.channel.errorChannel.sendRate.stdev”:0, “integration.channel.errorChannel.sendRate.count”0, “integration.channel.springCloudBusInput.errorRate.mean”:0, “integration.channel.springCloudBusInput.errorRate.max”:0, “integration.channel.springCloudBusInput.errorRate.min”0, “integration.channel.springCloudBusInput.errorRate.stdev”:0, “integration.channel.springCloudBusInput.errorRate.count”:0, “integration.channel.springCloudBusInput.sendCount”:0, “integration.channel.springCloudBusInput.sendRate.mean”:0, “integration.channel.springCloudBusInput.sendRate.max”:0, “integration.channel.springCloudBusInput.sendRate.min”:0, “integration.channel.springCloudBusInput.sendRate.stdev”:0, “integration.channel.springCloudBusInput.sendRate.count”:0, “integration.channel.hystrixStreamOutput.errorRate.mean”0, “integration.channel.hystrixStreamOutput.errorRate.max”:0, “integration.channel.hystrixStreamOutput.errorRate.min”:0, “integration.channel.hystrixStreamOutput.errorRate.stdev”:0, “integration.channel.hystrixStreamOutput.errorRate.count”:0, “integration.channel.hystrixStreamOutput.sendCount”:0, “integration.channel.hystrixStreamOutput.sendRate.mean”:0, “integration.channel.hystrixStreamOutput.sendRate.max”:0, “integration.channel.hystrixStreamOutput.sendRate.min”:0, “integration.channel.hystrixStreamOutput.sendRate.stdev”:0, “integration.channel.hystrixStreamOutput.sendRate.count”:0, “integration.channel.nullChannel.errorRate.mean”0, “integration.channel.nullChannel.errorRate.max”0, “integration.channel.nullChannel.errorRate.min”0, “integration.channel.nullChannel.errorRate.stdev”:0, “integration.channel.nullChannel.errorRate.count”0, “integration.channel.nullChannel.sendCount”:0, “integration.channel.nullChannel.sendRate.mean”0, “integration.channel.nullChannel.sendRate.max”:0, “integration.channel.nullChannel.sendRate.min”0, “integration.channel.nullChannel.sendRate.stdev”:0, “integration.channel.nullChannel.sendRate.count”:0, “integration.channel.springCloudBusOutput.errorRate.mean”0, “integration.channel.springCloudBusOutput.errorRate.max”0, “integration.channel.springCloudBusOutput.errorRate.min”0, “integration.channel.springCloudBusOutput.errorRate.stdev”:0, “integration.channel.springCloudBusOutput.errorRate.count”0, “integration.channel.springCloudBusOutput.sendCount”:0, “integration.channel.springCloudBusOutput.sendRate.mean”0, “integration.channel.springCloudBusOutput.sendRate.max”0, “integration.channel.springCloudBusOutput.sendRate.min”0, “integration.channel.springCloudBusOutput.sendRate.stdev”:0, “integration.channel.springCloudBusOutput.sendRate.count”:0, “integration.handler.org.springframework.integration.errorLogger.handler.duration.mean”: 0, “integration.handler.org.springframework.integration.errorLogger.handler.duration.max”: 0, “integration.handler.org.springframework.integration.errorLogger.handler.duration.min”: 0, “integration.handler.org.springframework.integration.errorLogger.handler.duration.stdev”: 0, “integration.handler.org.springframework.integration.errorLogger.handler.duration.count”: 0, “integration.handler.org.springframework.integration.errorLogger.handler.activeCount”: 0, “集成.handlerCount”:1, “集成.通道计数”:5, “integration.sourceCount”:0, “httpsessions.max”:-1, “httpsessions.active”:0, “datasource.primary.active”:0, “datasource.primary.usage”:0}

    代码流甚至不会转到该方法(尝试使用调试器)。 仅此新创建端点的问题。上次错误为

    访问此资源需要完全身份验证

    在我写下配置之前:

    management:
      security:
        enabled: false
    

    我使用

    springBootVersion = '1.5.3.RELEASE'
    springCloudVersion = 'Dalston.RELEASE'
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   Artem    6 年前

    问题在于Spring Cloud MetricsInterceptorConfiguration

    据我所知,在每个端点上,您可以添加后缀路径/指标,以查看Spring Cloud提供的该端点的指标。所以它截获了我的映射:)

    我通过将以下配置添加到 独自创立yml公司 :

    endpoints:
      metrics:
        enabled: false