🦋
Butterfly 用户手册
  • Introduction
  • 一 前言
  • 二 开始
    • 安装部署
    • 五分钟体验指南
    • 单机使用手册
    • 应用规范
      • handler specs
      • middleware specs
      • xingqiao_plugin specs
      • yiqiu_program specs
  • 三 客户端功能
    • MySQL 原生协议
    • MySQL ORM
    • Redis 原生协议
      • redis_config
      • redis_tls
    • Redis ORM
    • Redis mcpack
    • Localcache
    • Kazoo
  • 四 应用(通用服务)
    • API JSON 规范
    • 异步任务 BaiChuan(百川)
    • 任务调度 RuQi(如期)
    • 任务编排 XingQiao(星桥)
    • 配置管理 WuXing(五行)
    • 运筹决策 BaiCe(百策)
  • 五 部署运维
    • 单机容器化部署
    • 监控
    • 异常排查
      • CPU Load spike every 7 hours
    • 升级
    • 安全
    • 其他
  • 六 前端
    • butterfly_template
    • butterfly_fe
    • butterfly-admin(json2web)
      • amis
      • sso
      • pangu
    • NoahV
    • PyWebIO
  • 七 潘多拉魔盒
    • 装饰器
      • localcache_decorator
      • retry_decorator
      • custom_decorator
      • command2http_decorator
    • 算法
      • 算法-分位数
      • 算法-变异系数
    • 实用工具
      • host_util
      • shell_util
      • http_util
      • time_util
      • random_util
      • concurrent
      • jsonschema
      • blinker
      • toml
      • command_util
      • config_util
      • picobox
      • 对称加密
        • des
        • aes
      • ascii_art
        • ttable
        • chart
      • business_rules
      • python-mysql-replication
      • dict_util
    • 中间件
      • middleware_status
      • middleware_whitelist
    • test_handler.py
  • 八 最佳实践
    • 分布式架构
    • Code practice
    • Log practice
    • Daemon process
  • 附录
Powered by GitBook
On this page
  • 1 简介
  • 1.1 特性
  • 1.1 名称说明
  • 2 部署
  • 2.1 建表
  • 3 接口文档
  • 3.1 section
  • 3.2 instance
  • 3.3 item
  • 3.4 item_history
  • 3.5 item_ratio
  1. 四 应用(通用服务)

配置管理 WuXing(五行)

1 简介

1.1 特性

五行 -- 统一存储巡检类 / 配置类 / 统计类等数据服务

  • 操作追溯

    • 操作轨迹可追踪

    • 历史配置可查询和回溯

  • 缓存加持

    • 重要接口缓存

  • 查询方便

    • 细粒度化到 key-value 配置项层级

    • 支持模糊匹配检索

1.1 名称说明

  • namespace: 名字空间

    • 在 section 中,同一个名字空间内的 section_name+section_version 是唯一的

    • 在 instance 中,同一个名字空间内的 instance_name 是唯一的

  • section: 相当于 MySQL 中的表名

  • instance: 相当于 MySQL 中的记录

  • item: 相当于 MySQL 中的字段

2 部署

2.1 建表

五行需要 8 张表,分别为

+-----------------------+
| wuxing_section        |
| wuxing_instance       |
| wuxing_instance_item  |
| wuxing_history_bool   |
| wuxing_history_float  |
| wuxing_history_int    |
| wuxing_history_string |
| wuxing_history_text   |
+-----------------------+

2.1.1 五行 8 张表之间关系

+namespace1-------------------------------------------------------+
|                   +section1-----------------+                   |
|                   |+section_template-------+|                   |
|                   ||+-----+ +-----+ +-----+||                   |
|                   |||item1| |item2| |item3||| version:1.0.1     |
|                   ||+-----+ +-----+ +-----+||                   |
|                   |+-----------------------+|                   |
|                   +------+---------+--------+                   |
|                          |         |                            |
|                          |         +---------+                  |
|                          |                   |                  |
|                          |                   |                  |
|   +instance1-------------V--+  +instance2----V-----------+      |
|   |+instance_template------+|  |+instance_template------+|      |
|   ||+id:1-+ +id:2-+ +id:3-+||  ||+id:4-+ +id:5-+ +id:6-+||      |
|   |||item1| |item2| |item3|||  |||item1| |item2| |item3|||      |
|   ||+----++ +---+-+ +---+-+||  ||+--+--+ +---+-+ +---+-+||      |
|   |+-----|------|-------|--+|  |+---|--------|-------|--+|      |
|   +------|------|-------|---+  +----|--------|-------|---+      |
|          |      |       |           |        |       |          |
|   +item--|------|-------|-----------|--------|-------+---+      |
|   | +id:1V--+   |       |           |        |       |   |      |
|   | +-------+   |       |           |        |       |   |      |
|   |        +id:2V--+    |           |        |       |   |      |
|   |        +-------+    |           |        |       |   |      |
|   |               +id:3-V-+         |        |       |   |      |
|   |               +-------+         |        |       |   |      |
|   |                           +id:4-V-+      |       |   |      |
|   |                           +-------+      |       |   |      |
|   |                                    +id:5-V-+     |   |      |
|   |                                    +-------+     |   |      |
|   |                                            +id:6-V-+ |      |
|   |                                            +-------+ |      |
|   +------------------------------------------------------+      |
+-----------------------------------------------------------------+

 (1) wuxing_section 表存储 section 记录
 (2) wuxing_instance 表存储 instance 记录
     [创建] 创建 instance 时会涉及如下行为:
         1> 关联 section 及对应版本,继承 section 模板
         2> 根据 item value 数据类型,在 item 表中以模板默认值创建记录
 (3) wuxing_instance_item 表存储 instance 的 item 具体 value 值

+history----------------------------------------------------------+
|+------------------------+           +-------------------------+ |
||wuxing_history_bool     |           |wuxing_history_float     | |
|+------------------------+           +-------------------------+ |
|+------------------------+           +-------------------------+ | 此五个表记录 instance item 的 value 变更历史
||wuxing_history_int      |           |wuxing_history_string    | |
|+------------------------+           +-------------------------+ |
|+------------------------+                                       |
||wuxing_history_text     |                                       |
|+------------------------+                                       |
+-----------------------------------------------------------------+

备注:
(1) namespace 表是命名空间,同一个 namespace 下 (section_name, section_version) 实例以及 instance 实例 是唯一的
(2) instance 只会关联一个 (section_name, section_version)
(3) item 的类型是固定的
(4) section-instance-instance_item 关系
    section 类似 Python 中的类
    instance 类似 Python 中类实例化后的对象,会继承 section 这个类的属性
    instance_item 类似 Python 中类实例化后对象的属性,会根据 item 的数据类型存储在不同的 value 字段中

2.1.2 建表 SQL

# 此处替换为自己的 database
use {database};


CREATE TABLE `wuxing_section` (
  `namespace` varchar(16) NOT NULL COMMENT "section 所在的 namespace",
  `section_name` varchar(64) NOT NULL COMMENT "section 名称",
  `section_version` varchar(16) NOT NULL COMMENT "section version",
  `section_template` varchar(4096) NOT NULL COMMENT "section 模板,是个 json",
  `section_md5` varchar(64) NOT NULL COMMENT "section 模板 md5 值",
  `is_enabled` tinyint(1) NOT NULL COMMENT "section 是否是启用状态",
  `user` varchar(32) NOT NULL COMMENT "操作用户",
  `u_time` datetime NOT NULL COMMENT "更新时间",
  `c_time` datetime NOT NULL COMMENT "创建时间",
  PRIMARY KEY (`namespace`,`section_name`,`section_version`),
  KEY `wuxingsection_section_md5` (`section_md5`),
  KEY `wuxingsection_is_enabled` (`is_enabled`),
  KEY `wuxingsection_user` (`user`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT "五行 section, 相当于 Python 中的类";

CREATE TABLE `wuxing_instance` (
  `namespace` varchar(16) NOT NULL COMMENT "实例所在的 namespace",
  `instance_name` varchar(64) NOT NULL COMMENT "instance 名称",
  `instance_template` varchar(4096) NOT NULL COMMENT "instance 模板,在 section 模板基础上加了 item_id",
  `section_name` varchar(64) NOT NULL COMMENT "instance 所绑定的 section",
  `section_version` varchar(64) NOT NULL COMMENT "instance 所绑定的 section 版本",
  `section_md5` varchar(64) NOT NULL COMMENT "section 模板 md5 值",
  `is_valid` tinyint(1) NOT NULL COMMENT "是否有效,预留字段",
  `c_time` datetime NOT NULL COMMENT "创建时间",
  `u_time` datetime NOT NULL COMMENT "更新时间",
  PRIMARY KEY (`namespace`,`instance_name`),
  KEY `wuxinginstance_section_name` (`section_name`),
  KEY `wuxinginstance_section_version` (`section_version`),
  KEY `wuxinginstance_section_md5` (`section_md5`),
  KEY `wuxinginstance_c_time` (`c_time`),
  KEY `wuxinginstance_u_time` (`u_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT "五行 instance, 相当于 Python 中的类实例化后的对象";

CREATE TABLE `wuxing_instance_item` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT "主键,自增 id, 也就是 item_id",
  `namespace` varchar(16) NOT NULL COMMENT "item 所在的 namespace",
  `section_name` varchar(64) NOT NULL COMMENT "item 所在的 section_name",
  `instance_name` varchar(64) NOT NULL COMMENT "item 所在的 instance_name",
  `item_name` varchar(64) NOT NULL COMMENT "item 名称",
  `item_type` varchar(64) NOT NULL COMMENT "item value 类型",
  `item_value_bool` tinyint(1) DEFAULT NULL COMMENT "item 为 bool 时,此字段有值",
  `item_value_float` double DEFAULT NULL COMMENT "item 为 float 时,此字段有值",
  `item_value_int` int(11) DEFAULT NULL COMMENT "item 为 int 时,此字段有值",
  `item_value_string` varchar(128) DEFAULT NULL COMMENT "item 为 string 时,此字段有值",
  `item_value_text` varchar(20000) DEFAULT NULL COMMENT "item 为 text 时,此字段有值",
  `user` varchar(32) NOT NULL COMMENT "操作用户",
  `c_time` datetime NOT NULL COMMENT "创建时间",
  `u_time` datetime NOT NULL COMMENT "更新时间",
  PRIMARY KEY (`id`),
  KEY `wuxinginstanceitem_namespace` (`namespace`),
  KEY `wuxinginstanceitem_section_name` (`section_name`),
  KEY `wuxinginstanceitem_instance_name` (`instance_name`),
  KEY `wuxinginstanceitem_item_name` (`item_name`),
  KEY `wuxinginstanceitem_item_type` (`item_type`),
  KEY `wuxinginstanceitem_item_value_bool` (`item_value_bool`),
  KEY `wuxinginstanceitem_item_value_float` (`item_value_float`),
  KEY `wuxinginstanceitem_item_value_int` (`item_value_int`),
  KEY `wuxinginstanceitem_item_value_string` (`item_value_string`),
  KEY `wuxinginstanceitem_c_time` (`c_time`),
  KEY `wuxinginstanceitem_u_time` (`u_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8  COMMENT "五行 instance item, 相当于 Python 中实例的属性";

CREATE TABLE `wuxing_history_bool` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT "主键,自增 id",
  `item_id` int(11) NOT NULL COMMENT "item_id",
  `item_value` tinyint(1) NOT NULL COMMENT "item value",
  `cmd` varchar(8) NOT NULL COMMENT "变更操作命令/create/update",
  `user` varchar(32) NOT NULL COMMENT "操作用户",
  `c_time` datetime NOT NULL COMMENT "创建时间",
  PRIMARY KEY (`id`),
  KEY `wuxinghistorybool_item_id` (`item_id`)
  KEY `wuxinghistorybool_c_time` (`c_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT "五行 bool 类型 item 数据变更历史";

CREATE TABLE `wuxing_history_float` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT "主键,自增 id",
  `item_id` int(11) NOT NULL COMMENT "item_id",
  `item_value` double NOT NULL COMMENT "item value",
  `cmd` varchar(8) NOT NULL COMMENT "变更操作命令/create/update",
  `user` varchar(32) NOT NULL COMMENT "操作用户",
  `c_time` datetime NOT NULL COMMENT "创建时间",
  PRIMARY KEY (`id`),
  KEY `wuxinghistoryfloat_item_id` (`item_id`),
  KEY `wuxinghistoryfloat_c_time` (`c_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT "五行 float 类型 item 数据变更历史";

CREATE TABLE `wuxing_history_int` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT "主键,自增 id",
  `item_id` int(11) NOT NULL COMMENT "item_id",
  `item_value` int(11) NOT NULL COMMENT "item value",
  `cmd` varchar(8) NOT NULL COMMENT "变更操作命令/create/update",
  `user` varchar(32) NOT NULL COMMENT "操作用户",
  `c_time` datetime NOT NULL COMMENT "创建时间",
  PRIMARY KEY (`id`),
  KEY `wuxinghistoryint_item_id` (`item_id`),
  KEY `wuxinghistoryint_c_time` (`c_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT "五行 int 类型 item 数据变更历史";

CREATE TABLE `wuxing_history_string` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT "主键,自增 id",
  `item_id` int(11) NOT NULL COMMENT "item_id",
  `item_value` varchar(128) NOT NULL COMMENT "item value",
  `cmd` varchar(8) NOT NULL COMMENT "变更操作命令/create/update",
  `user` varchar(32) NOT NULL COMMENT "操作用户",
  `c_time` datetime NOT NULL COMMENT "创建时间",
  PRIMARY KEY (`id`),
  KEY `wuxinghistorystring_item_id` (`item_id`),
  KEY `wuxinghistorystring_c_time` (`c_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT "五行 string 类型 item 数据变更历史";

CREATE TABLE `wuxing_history_text` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT "主键,自增 id",
  `item_id` int(11) NOT NULL COMMENT "item_id",
  `item_value` varchar(20000) NOT NULL COMMENT "item value",
  `cmd` varchar(8) NOT NULL COMMENT "变更操作命令/create/update",
  `user` varchar(32) NOT NULL COMMENT "操作用户",
  `c_time` datetime NOT NULL COMMENT "创建时间",
  PRIMARY KEY (`id`),
  KEY `wuxinghistorytext_item_id` (`item_id`),
  KEY `wuxinghistorytext_c_time` (`c_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT "五行 text 类型 item 数据变更历史";

3 接口文档

3.1 section

3.1.1 section 增

/wuxing/section_create

说明:创建 section

方法:POST

参数:
    namespace      : (string) 名字空间(最长 16 个字节)
    section_name   : (string) section 名字
    section_version: (string) section 版本

约束:
同一个 namespace 下的 (section_name+section_version) 是唯一的

例子:
$ curl -v -d '{"namespace":"zh_host", "section_name":"ip", "section_version":"1.0.1"}' "http://127.0.0.1:8501/wuxing/section_create"
{"stat": "OK"}

3.1.2 section 删

/wuxing/section_delete

说明:创建 section

方法:POST

参数:
    namespace      : (string) 名字空间
    section_name   : (string) section 名字
    section_version: (string) section 版本

约束:
同一个 namespace 下的 (section_name+section_version) 是唯一的

例子:
$ curl -v -d '{"namespace":"zh_host", "section_name":"ip", "section_version":"1.0.1"}' "http://127.0.0.1:8501/wuxing/section_delete"
{"stat": "OK"}

3.1.3 section 改

3.1.3.1 section 改之添加 item

/wuxing/section_item_add

说明:给 section 模板中增加 item, section 需要是未启用状态,已启用状态的 section 则无法进行变更

方法:POST

参数:
    namespace           : (string) 名字空间
    section_name        : (string) section 名字
    section_version     : (string) section 版本
    item_name           : (string) item 名称
    item_default        :(string) item 默认值
    item_description    : (string) item 说明

例子:
$ data_json='{"namespace":"zh_host", "section_name":"ip", "section_version":"1.0.1", "item_name":"s|machine_status", "item_default": "OK", "item_description":"status"}'
$ curl -v -d "${data_json}" "http://127.0.0.1:8501/wuxing/section_item_add"
{"stat": "OK"}

3.1.3.2 section 改之删除 item

/wuxing/section_item_delete

说明: section 模板中删除 item
参数: 
    namespace           : (string) 名字空间
    section_name        : (string) section 名字
    section_version     : (string) section 版本
    item_name           : (string) item 名称

3.1.3.3 section 改之 enable

/wuxing/section_enable

说明:启用 section

方法:POST

参数:
    namespace           : (string) 名字空间
    section_name        : (string) section 名字
    section_version     : (string) section 版本

例子:
$ curl -v -d '{"namespace":"zh_host", "section_name":"ip", "section_version":"1.0.1"}' "http://127.0.0.1:8501/wuxing/section_enable"
{"stat": "OK"}

3.1.4 section 查

3.1.4.1 section 查之 list

/wuxing/section_list

说明:获取 section 列表

方法:GET

参数:
    namespace  : (string) 『可选』名字空间
    page_index : (int)    『可选』页码,默认为 1
    page_size  : (int)    『可选』单页记录条数,默认是 10

例子:
$ curl  "http://127.0.0.1:8501/wuxing/section_list"
-------
{
   "data" : {
      "total" : 5,
      "list" : [
         {
            "section_md5" : "be31d9a7",
            "is_enabled" : true,
            "section_name" : "group_appid",
            "namespace" : "group_qingnang",
            "section_version" : "1.0.1",
            "u_time" : "2021-01-25 07:54:33"
         },
         {
            "section_md5" : "af91d160",
            "is_enabled" : true,
            "section_name" : "group_appid",
            "namespace" : "group_qingnang",
            "section_version" : "1.0.2",
            "u_time" : "2021-01-25 07:54:33"
         },
         {
            "section_md5" : "43e7521f",
            "is_enabled" : true,
            "section_name" : "group_appid",
            "namespace" : "group_qingnang",
            "section_version" : "1.0.3",
            "u_time" : "2021-01-25 07:54:33"
         },
         {
            "section_md5" : "99914b93",
            "is_enabled" : false,
            "section_name" : "group_appid",
            "namespace" : "group_qingnang",
            "section_version" : "1.0.4",
            "u_time" : "2021-01-25 07:54:33"
         },
         {
            "section_md5" : "101d7795",
            "is_enabled" : true,
            "section_name" : "ip",
            "namespace" : "zh_host",
            "section_version" : "1.0.1",
            "u_time" : "2021-02-01 11:25:47"
         }
      ]
   },
   "stat" : "OK"
}

3.1.4.2 section 查之 get

/wuxing/sectin_get

说明:获取 section 详情

方法:GET

参数:
    namespace           : (string) 名字空间
    section_name        : (string) section 名字
    section_version     : (string) section 版本

例子:
$ curl "http://127.0.0.1:8501/wuxing/section_get?namespace=zh_host&section_name=ip&section_version=1.0.1"
----
{
   "data" : {
      "is_enabled" : true,
      "section_template" : {
         "s|niepan_status" : {
            "item_type" : "string",
            "item_default" : "OK",
            "item_description" : "status"
         },
         "s|machine_status" : {
            "item_type" : "string",
            "item_default" : "OK",
            "item_description" : "status"
         }
      }
   },
   "stat" : "OK"
}

3.2 instance

3.2.1 instance 增

/wuxing/instance_create

说明:创建 instance

方法:POST

参数:
    namespace       : (str) 必传,命名空间
    instance_name   : (str) 必传,instance name
    section_name    : (str) 必传,section name
    section_version : (str) 必传,section 版本
    items_data      : (dict) 选传,item 的 value 值
                    : {"item_value": "item_value"}

约束:
同一个 namespace 下的 instance_name 是唯一的

例子 1:创建 instance 时,使用 section 模板默认值进行创建
$ data_json='{"namespace":"zh_host", "instance_name":"127.0.0.5", "section_name":"ip", "section_version":"1.0.1"}'
$ curl -v -d "${data_json}" "http://127.0.0.1:8501/wuxing/instance_create"
{"stat": "OK"}

例子 2:创建 instance 时,使用指定 item_value 进行创建
data_json='{"namespace":"zh_host", "instance_name":"127.0.0.6", "section_name":"ip", "section_version":"1.0.1", "items_data": {"s|machine_status": "ERROR"}}'
curl -v -d "${data_json}" "http://127.0.0.1:8501/wuxing/instance_create"
{"stat": "OK"}

3.2.2 instance 删

/wuxing/instance_delete

说明:删除 instance

方法:POST

参数:
    namespace       : (str) 必传,命名空间
    instance_name   : (str) 必传,instance name

例子:
data_json='{"namespace":"zh_host", "instance_name":"127.0.0.6"}'
curl -v -d "${data_json}" "http://127.0.0.1:8501/wuxing/instance_delete"
{"stat": "OK"}

3.2.3 instance 改

3.2.3.1 更新 instance 的 section 版本

/wuxing/instance_update_section

说明: 更新 instance 的 section 的版本
场景: 有新的需求接入,需要对 instance 增加些 item, 则需要发布新的 section 版本,然后更新对应的 instance 版本
参数:
    namespace       : (str) 必传,命名空间
    instance_name   : (str) 必传,instance name
    section_version : (str) 必传,section 版本

3.2.3.2 更新 instance 的 item value

/wuxing/instance_update_item

说明: 更新 instance 的 item value
参数:
    namespace       : (str) 必传,命名空间
    instance_name   : (str) 必传, instance name
    item_name       : (str) 必传, item name
    item_value      : (str/int/float/bool) 必传,值 

3.2.4 instance 查

3.2.4.1 instance 查询之 instance 列表

/wuxing/instance_list

说明:获取 instance 列表
参数:
    namespace       : (str) 必传,命名空间,匹配时进行完全匹配
    section_name    : (str) 必传,section name, 匹配时进行完全匹配
    instance_name   : (str) 选传,instance name, 匹配时进行模糊匹配
    section_version : (str) 选传,section 版本,匹配时进行完全匹配
    section_md5     : (str) 选传,section md5, 匹配时进行完全匹配
    extra_items     : (str) 选传,此参数用于获取额外 item 进行列表展示,多个 item 使用冒号 ":" 进行分割
    sort            : (str) {item_name}/-{item_name}  或者 instance_name, u_time
                    :       如果是 {item_name}/-{item_name} ,应该转换为 item_value_bool/item_value_int/
                            item_value_string/item_value_float
                            如果 sort 值是 "-" 开头,则是以降序进行排序
    item_conditions : (str) 选传,值为 item_conditions=key=value
                            多个值可以使用逗号分割,如 item_conditions=i|unit_appid=5526,s|unit_version=-
    item_name       : (str) 选传
    item_value      : (str) 选传
    page_index      : (int) 页数
    page_size       : (int) 每页显示条数,默认为 10

例子 1:
$ curl "http://127.0.0.1:8501/wuxing/instance_list?namespace=group_qingnang&section_name=group_appid"
------
{
   "data" : {
      "total" : 3,
      "list" : [
         {
            "section_md5" : "be31d9a7",
            "section_name" : "group_appid",
            "namespace" : "group_qingnang",
            "instance_name" : "3001",
            "section_version" : "1.0.1",
            "u_time" : "2021-02-07 14:07:56"
         },
         {
            "section_md5" : "be31d9a7",
            "section_name" : "group_appid",
            "namespace" : "group_qingnang",
            "instance_name" : "3002",
            "section_version" : "1.0.1",
            "u_time" : "2021-02-07 14:07:56"
         },
         {
            "section_md5" : "be31d9a7",
            "section_name" : "group_appid",
            "namespace" : "group_qingnang",
            "instance_name" : "3003",
            "section_version" : "1.0.1",
            "u_time" : "2021-02-07 14:07:56"
         }
      ]
   },
   "stat" : "OK"
}
例子 2:根据 instance_name 排序
$ curl "http://127.0.0.1:8501/wuxing/instance_list?namespace=group_qingnang&section_name=group_appid&sort=-instance_name"
------
{
   "data" : {
      "total" : 3,
      "list" : [
         {
            "section_md5" : "be31d9a7",
            "section_name" : "group_appid",
            "namespace" : "group_qingnang",
            "instance_name" : "3003",
            "section_version" : "1.0.1",
            "u_time" : "2021-02-07 14:07:56"
         },
         {
            "section_md5" : "be31d9a7",
            "section_name" : "group_appid",
            "namespace" : "group_qingnang",
            "instance_name" : "3002",
            "section_version" : "1.0.1",
            "u_time" : "2021-02-07 14:07:56"
         },
         {
            "section_md5" : "be31d9a7",
            "section_name" : "group_appid",
            "namespace" : "group_qingnang",
            "instance_name" : "3001",
            "section_version" : "1.0.1",
            "u_time" : "2021-02-07 14:07:56"
         }
      ]
   },
   "stat" : "OK"
}

3.2.4.1 instance 查询之 instance 详情

/wuxing/instance_get

说明: instance 详情
参数:
    namespace       : (string) 必须,namespace
    instance_name   : (string) 必须,instance_name
    items           : (string) item name, 多个 item 使用 `,` 分割
    value_format    : (String) detail/simple(default)

eg:
$ curl  "http://127.0.0.1:8501/wuxing/instance_get?namespace=zh_host&instance_name=127.0.0.5"
{
   "data" : {
      "s|machine_status" : {
         "item_type" : "string",
         "item_value" : "OK",
         "item_description" : "status",
         "u_time" : "2021-02-28 17:27:31",
         "item_name" : "s|machine_status",
         "item_id" : 29
      }
   },
   "stat" : "OK"
}

3.3 item

3.3.1 item 查

/wuxing/item_list

说明: 通过 item 反查 instance 列表
参数:
    namespace           : (str) 选传,命名空间
    section_name        : (str) 选传,section name
    instance_name       : (str) 选传,instance name
    item_name           : (str) 选传,item name
    item_value_operator : (str) 选传,item value operator(=/</<=/>/>=/!=)
    item_value          : (str) 选传,item_value
    start_time          : (str) 选传,example: 20210124194805
    end_time            : (str) 选传,example: 20210124195005
    sort                : (str) 选传,{item_name}/-{item_name}  或者 instance_name, u_time
                        :       如果是 {item_name}/-{item_name} ,应该转换为 item_value_bool/item_value_int/
                                item_value_string/item_value_float
                                如果 sort 值是 "-" 开头,则是以降序进行排序
    page_index          : (int) 选传,页数
    page_size           : (int) 选传,每页显示条数

eg:
$ curl "http://127.0.0.1:8501/wuxing/item_list?namespace=zh_host&section_name=ip&item_name=s|machine_status"
{
   "data" : {
      "total" : 1,
      "list" : [
         {
            "namespace" : "zh_host",
            "instance_name" : "127.0.0.5",
            "item_value" : "OK",
            "item_name" : "s|machine_status",
            "u_time" : "2021-02-28 19:08:39",
            "item_id" : 29,
            "section_name" : "ip",
            "user" : "-",
            "c_time" : "2021-02-28 19:08:39"
         }
      ]
   },
   "stat" : "OK"
}

3.4 item_history

3.4.1 查

/wuxing/item_history_list

说明:获取 item 变更历史
参数:
    item_type: item 类型
    item_id:item id
    page_index=1
    page_size=10

3.5 item_ratio

3.5.1 获取 item 比例

/wuxing/get_item_ratio

说明:获取 item 比例情况
参数:
    'namespace':命名空间
    'section_name':section 名字
    'item_name':item 名字
    'condition1=None':条件1,格式:condition1=item_key1=item_value2
    'condition2=None': 条件2
    'report_type=None': pie
    'item_value=None': item value keywords
例子:
curl "http://127.0.0.1:8501/wuxing/get_item_ratio?namespace=bq_m_state&section_name=unit_redis&item_name=s|service_bns"
Previous任务编排 XingQiao(星桥)Next运筹决策 BaiCe(百策)

Last updated 1 year ago