zoukankan      html  css  js  c++  java
  • 【转载】Spring Cloud Gateway监控

    http://www.imooc.com/article/290822

    欢迎加入Spring Cloud Gateway监控豪华套餐——

    只要为Spring Cloud Gateway添加Spring Boot Actuator( spring-boot-starter-actuator )的依赖,并将 gateway 端点暴露,即可获得若干监控端点,监控 & 操作Spring Cloud Gateway的方方面面。

    management:
      endpoints:
        web:
          exposure:
            # 当然暴露'*' 更好啦..
            include: gateway
    

    监控端点一览表:

    TIPS
    以下所有端点都挂在/actuator/gateway/ 下面。
    例如:routes 的全路径是 /actuator/gateway/routes ,以此类推。

    IDHTTP MethodDescription
    globalfilters GET 展示所有的全局过滤器
    routefilters GET 展示所有的过滤器工厂(GatewayFilter factories)
    refresh POST【无消息体】 清空路由缓存
    routes GET 展示路由列表
    routes/{id} GET 展示指定id的路由的信息
    routes/{id} POST【消息体如下】 新增一个路由
    routes/{id} DELETE【无消息体】 删除一个路由

    其中,要想动态添加路由配置,只需发送POST请求,消息体如下:

    {
      "predicates": [
        {
          "name": "Path",
          "args": {
            "_genkey_0": "/test"
          }
        }
      ],
      "filters": [
        {
          "name": "AddRequestHeader",
          "args": {
            "_genkey_0": "X-Request-Foo",
            "_genkey_1": "Bar"
          }
        },
        {
          "name": "PreLog",
          "args": {
            "_genkey_0": "a",
            "_genkey_1": "b"
          }
        }
      ],
      "uri": "https://www.itmuch.com",
      "order": 0
    }
    

    TIPS

    技巧:消息体其实是有规律的,你可以先在配置文件中配置一个路由规则,然后访问${GATEWAY_URL}/actuator/gateway/routes 端点,每个路由id的对应段落,就是你的消息体啦。

    如使用 POSTMAN 测试,可配置如下:

    Postman

    操作完成后,可再次访问 ${GATEWAY_URL}/actuator/gateway/routes 端点,可以看到,新的路由已被动态添加了。

    TIPS

    如果没有实时生效,使用refresh端点刷新一下路由信息即可。

    本文首发

     
     
  • 相关阅读:
    css--display属性中inline-block与inline的区别
    css基础--常用css属性01
    css基础--简单介绍css
    html常用标签的使用方法
    html概括
    python基础之socket与socketserver
    linux基础命令之sed
    asp.net文件流下载的代码摘要
    window下golang生成静态库给C语言调用
    golang生成c-shared so供c语言或者golang调用到例子
  • 原文地址:https://www.cnblogs.com/exmyth/p/13563643.html
Copyright © 2011-2022 走看看