【问题标题】:How to expose Actuator endpoints with Zuul (no Eureka, Spring Cloud)?如何使用 Zuul(没有 Eureka、Spring Cloud)公开 Actuator 端点?
【发布时间】:2016-05-27 19:20:56
【问题描述】:

我有一个 Spring Cloud 应用程序,用作 Zuul Server(带有 @EnableZuulProxy)注释。在这个阶段,我将 /api/* 请求路由到适当的中间层服务,而所有其他请求都路由到演示服务,因此从配置 pov 来看,它如下所示:

zuul:
  ignoredServices: '*'
  routes:    
    reservation-owner:
      path: /api/service1
      url: http://service1.net
    --- here couple of other api mappings --   
    ui:
      path: /**
      url: http://presentation-service.net/

在我想检查 zuul 代理上的任何 Actuator 端点之前,这很有效。由于它们属于 /**,因此它们被路由到演示服务。

我已经尝试设置特定的端点路由回zuul服务器,但如果我是对的,我最终会出现zuul调用自身的无限循环。因此,如果我是对的,我正在寻找一种方法来定义演示服务的路径,该路径将包括除例如之外的所有内容。 /admin/* 端点。可能吗?还是应该采取其他方法?

【问题讨论】:

    标签: spring-cloud netflix-zuul


    【解决方案1】:

    一旦你设置了/** zuul 就会吞下所有的请求。此时唯一的方法是设置management port

    management.port=8081
    

    【讨论】:

    • 感谢您的想法。我假设当应用程序部署在 CF 环境中并且端口无论如何都由 CF 管理时它不会飞? :)
    • 当您使用path: /** 时不会。不要使用/**,它会起作用。
    • 嘿,但是我们应该如何配置 Zuul,以便所有非 api URL 最终都出现在特定的演示/ui 服务中?也许方法是错误的,但我想知道什么是正确的:)
    • 枚举用户界面路径
    • 那么如何将管理端点分配给不同的上下文路径(例如 management.contextPath=/admin),然后使用以下属性 zuul.ignoredPatterns=/**/admin/**
    【解决方案2】:

    pom.xml:

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
    

    application.yml:

    management:
      endpoints:
        web:
          exposure:
            include: "*"
    

    执行器端点here

    【讨论】:

    • 另外使用base-path 参数可能有助于自定义端点路径。
    【解决方案3】:

    修改application.yaml 对我有用以路由和过滤端点:

    management:
      endpoints:
        web:
          exposure:
            include: 'routes,filters'
    

    【讨论】:

      猜你喜欢
      • 2016-10-26
      • 2020-04-15
      • 2016-08-31
      • 1970-01-01
      • 2019-12-06
      • 2019-05-24
      • 1970-01-01
      • 2016-11-06
      • 1970-01-01
      相关资源
      最近更新 更多