1 Star 0 Fork 13

algorithmofdish / gala-spider

forked from openEuler / gala-spider 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MulanPSL-2.0

gala-spider

gala-spider 提供 OS 级别的拓扑图绘制功能,它将定期获取 gala-gopher (一个 OS 层面的数据采集软件)在某个时间点采集的所有观测对象的数据,并计算它们之间的拓扑关系,最终将生成的拓扑图保存到图数据库 arangodb 中。

功能特性

gala-spider 项目提供了两个功能模块,它们分别是:

  • spider-storage:提供 OS 级别观测对象的拓扑图绘制功能,拓扑图结果会存入图数据库 arangodb 中,可通过 arangodb 提供的 UI 界面查询。
  • gala-inference:提供异常 KPI 的根因定位能力,它基于异常检测的结果和拓扑图作为输入,并将根因定位的结果输出到 kafka 中。

软件架构

image-20220704203722478

其中,虚线框内为 gala-spider 项目的 2 个功能组件,绿色部分为 gala-spider 项目直接依赖的外部组件,灰色部分为 gala-spider 项目间接依赖的外部组件。

  • spider-storage:gala-spider 核心组件,提供拓扑图存储功能。它从 kafka 获取观测对象的元数据信息,进一步从 Prometheus 获取所有的观测实例信息,最终将生成的拓扑图存储到图数据库 arangodb 中。
  • gala-inference:gala-spider 核心组件,提供根因定位功能。它通过订阅 kafka 的异常 KPI 事件触发异常 KPI 的根因定位流程,并基于 arangodb 获取的拓扑图来构建故障传播图,最终将根因定位的结果输出到 kafka 中。
  • Prometheus:时序数据库,gala-gopher 组件采集的观测指标数据会上报到 Prometheus,再由 gala-spider 做进一步处理。
  • kafka:消息中间件,用于存储 gala-gopher 上报的观测对象元数据信息,异常检测组件上报的异常事件,以及 cause-inference 组件上报的根因定位结果。
  • arangodb:图数据库,用于存储 spider-storage 生成的拓扑图。
  • gala-gopher:数据采集组件,详细内容参见 gala-gopher 项目
  • arangodb-ui:arangodb 提供的 UI 界面,可用于查询拓扑图。

快速开始

gala-spider 软件部署

spider-storage 软件部署

  1. 基于源码编译、安装、运行

    • 构建

      /usr/bin/python3 setup.py build
    • 安装

      /usr/bin/python3 setup.py install
    • 运行

      spider-storage
  2. 基于rpm包安装运行

    • 配置 yum 源

      [oe-2209]      # openEuler 2209 官方发布源
      name=oe2209
      baseurl=http://119.3.219.20:82/openEuler:/22.09/standard_x86_64
      enabled=1
      gpgcheck=0
      priority=1
      
      [oe-2209:Epol] # openEuler 2209:Epol 官方发布源
      name=oe2209_epol
      baseurl=http://119.3.219.20:82/openEuler:/22.09:/Epol/standard_x86_64/
      enabled=1
      gpgcheck=0
      priority=1
    • 安装

      yum install gala-spider
    • 运行

      systemctl start gala-spider
  3. 基于 docker 容器化部署

    • 生成容器镜像

      在 gala-spider 项目根目录下,执行:

      docker build -f ./ci/gala-spider/Dockerfile -t gala-spider:1.0.0 .

      需要注意的是,生成容器镜像的过程中需要从 pip 源中下载依赖包,如果默认的 pip 源不可用,可通过修改 ./ci/gala-spider/Dockerfile 配置可用的 pip源,修改示例如下:

      # config pip source
      RUN pip3 config set global.index-url https://mirrors.tools.huawei.com/pypi/simple \
          && pip3 config set install.trusted-host mirrors.tools.huawei.com
    • 运行容器

      在部署环境中,执行:

      docker run -e prometheus_server=192.168.122.251:9090 -e arangodb_server=192.168.122.103:8529 -e kafka_server=192.168.122.251:9092 -e log_level=DEBUG gala-spider:1.0.0

      环境变量说明:若不指定,则使用配置文件默认配置。

      • prometheus_server :指定 Prometheus 服务器地址
      • arangodb_server :指定 arangodb 服务器地址
      • kafka_server :指定 kafka 服务器地址
      • log_level :指定 gala-spider 日志打印级别

      此外,如果需要从宿主机的配置文件中启动容器,可通过挂载卷的方式执行:

      docker run -e prometheus_server=192.168.122.251:9090 -e arangodb_server=192.168.122.103:8529 -e kafka_server=192.168.122.251:9092 -e log_level=DEBUG -v /etc/gala-spider:/etc/gala-spider -v /var/log/gala-spider:/var/log/gala-spider gala-spider:1.0.0

      需要说明的是,

      • 如果宿主机目录 /etc/gala-spider 中不存在配置文件,则容器会在第一次启动时将默认的配置文件复制到宿主机目录 /etc/gala-spider 中。
      • 如果宿主机目录 /etc/gala-spider 中相关的配置文件已存在,它将会覆盖容器中默认的配置文件。此时,通过 -e 参数指定的配置项将会失效。

      此外,可以通过 -v /var/log/gala-spider:/var/log/gala-spider 将容器运行的日志文件映射到宿主机上,方便后续查看。

gala-inference 软件部署

  1. 基于源码编译、安装、运行

    • 构建

      /usr/bin/python3 setup.py build
    • 安装

      /usr/bin/python3 setup.py install
    • 运行

      gala-inference
  2. 基于rpm包安装

    • 配置 yum 源

      同 spider-storage 软件部署中 yum 源配置。

    • 安装

      yum install gala-inference
    • 运行

      systemctl start gala-inference
  3. 基于 docker 容器化部署

    • 生成容器镜像

      在 gala-spider 项目根目录下,执行:

      docker build -f ./ci/gala-inference/Dockerfile -t gala-inference:1.0.0 .

      需要注意的是,生成容器镜像的过程中需要从 pip 源中下载依赖包,如果默认的 pip 源不可用,可通过修改 ./ci/gala-inference/Dockerfile 配置可用的 pip源,修改示例如下:

      # config pip source
      RUN pip3 config set global.index-url https://mirrors.tools.huawei.com/pypi/simple \
          && pip3 config set install.trusted-host mirrors.tools.huawei.com
    • 运行容器

      在部署环境中,执行:

      docker run -e prometheus_server=192.168.122.251:9090 -e arangodb_server=192.168.122.103:8529 -e kafka_server=192.168.122.251:9092 -e log_level=DEBUG gala-inference:1.0.0

      环境变量说明:若不指定,则使用配置文件默认配置。

      • prometheus_server :指定 Prometheus 服务器地址
      • arangodb_server :指定 arangodb 服务器地址
      • kafka_server :指定 kafka 服务器地址
      • log_level :指定 gala-inference 日志打印级别

      此外,如果需要从宿主机的配置文件中启动容器,可通过挂载卷的方式执行:

      docker run -e prometheus_server=192.168.122.251:9090 -e arangodb_server=192.168.122.103:8529 -e kafka_server=192.168.122.251:9092 -e log_level=DEBUG -v /etc/gala-inference:/etc/gala-inference -v /var/log/gala-inference:/var/log/gala-inference gala-inference:1.0.0

      需要说明的是,

      • 如果宿主机目录 /etc/gala-inference 中不存在配置文件,则容器会在第一次启动时将默认的配置文件复制到宿主机目录 /etc/gala-inference 中。
      • 如果宿主机目录 /etc/gala-inference 中相关的配置文件已存在,它将会覆盖容器中默认的配置文件。此时,通过 -e 参数指定的配置项将会失效。

      此外,可以通过 -v /var/log/gala-inference:/var/log/gala-inference 将容器运行的日志文件映射到宿主机上,方便后续查看。

gala-spider 外部依赖软件部署

  • prometheus 部署
  • kafka 部署
  • arangodb 部署

arangodb 部署

arangodb运行环境要求:

  • x86 系统
  • gcc10 以上

我们使用的 arangodb 版本是 3.8.7 ,arangodb 官方部署文档参见:arangodb部署

  1. 通过 rpm 部署

    首先,从 openEuler22.09:Epol 源安装 arangodb3 ,

    yum install arangodb3

    启动 arangodb3 服务器,

    systemctl start arangodb3

    启动之前,可通过配置文件 /etc/arangodb3/arangod.conf 修改配置,如修改 authentication = false 关闭身份认证。

  2. 通过 docker 部署

    docker run -e ARANGO_NO_AUTH=1 -p 192.168.0.1:10000:8529 arangodb/arangodb arangod \
      --server.endpoint tcp://0.0.0.0:8529\

    选项说明:

    • arangod --server.endpoint tcp://0.0.0.0:8529:在容器中启动 arangod 服务,--server.endpoint 指定了服务器地址。

    • -e ARANGO_NO_AUTH=1:配置 arangodb 的身份认证的环境变量,ARANGO_NO_AUTH=1 表示不启动身份认证,即无需用户名/密码即可访问 arangodb 数据库,该配置值用于测试环境。

    • -p 192.168.0.1:10000:8529:建立本地 IP 地址(如 192.168.0.1 的 1000 端口)到 arangodb 容器的 8529 端口的端口转发。

    详细的部署文档参见:通过docker部署arangodb

使用指南

配置文件介绍

配置文件介绍

3D 拓扑图分层架构

hier_arch

观测对象说明:

  1. Host:主机/虚拟机节点

    • machine_id:主机ID,用于标识网络中的一台主机/虚拟机。
  2. Container:容器节点

    • container_id:容器ID,用于标识主机/虚拟机上的容器。
    • machine_id:主机ID,用于关联容器所属的主机/虚拟机。
    • netns:容器所在的 net namespace 。
    • mntns:容器所在的 mount namespace 。
    • netcgrp:容器关联的 net cgroup 。
    • memcgrp:容器关联的 memory cgroup 。
    • cpucgrp:容器关联的 cpu cgroup 。
  3. Task:进程节点

    • pid:进程ID,用于标识主机/虚拟机或容器上运行的一个进程。
    • machine_id:主机ID,用于关联进程所属的主机/虚拟机。
    • container_id:容器ID,用于关联进程所属的容器。
    • tgid:进程组ID。
    • pidns:进程所在的 pid namespace 。
  4. Endpoint:进程的通信端点

    • type:端点类型,如 TCP 、UDP 等。
    • ip:端点绑定的 ip 地址,可选项。
    • port:端点绑定的端口号,可选项。
    • pid:进程ID,用于关联端点所属的进程ID。
    • netns:端点所在的 net namespace 。
  5. Jvm:Java程序运行时

  6. Python:Python程序运行时

  7. Golang:Go程序运行时

  8. AppInstance: 应用实例节点

    • pgid:进程组ID,用于标识一个应用实例。
    • machine_id:主机ID,用于关联应用实例所属的主机/虚拟机。
    • container_id:容器ID,用于关联应用实例所属的容器。
    • exe_file: 应用可执行文件,用于标识一个应用。
    • exec_file:应用被执行文件,用于标识一个应用。

接口文档

拓扑图查询Restful API

根因定位结果API

如何新增观测对象

如何新增观测对象

项目路线图

特性 发布时间 发布版本
基于TCP会话构建应用实时业务拓扑(包括Nginx、Haproxy等会话) 22.12 openEuler 22.03 SP1
构建主机内应用资源依赖拓扑(包括QEMU的拓扑关系) 22.12 openEuler 22.03 SP1
基于L7层会话构建K8S POD实时拓扑(包括HTTP1.X/MySQL/PGSQL/Redis/Kafka/MongoDB/DNS/RocketMQ) 23.09 openEuler 22.03 SP1
构建分布式存储实时拓扑(Ceph) 24.03 openEuler 24.03
木兰宽松许可证, 第2版 木兰宽松许可证, 第2版 2020年1月 http://license.coscl.org.cn/MulanPSL2 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束: 0. 定义 “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 “法人实体”是指提交贡献的机构及其“关联实体”。 “关联实体”是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 1. 授予版权许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 2. 授予专利许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 3. 无商标许可 “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 4. 分发限制 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 5. 免责声明与责任限制 “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 6. 语言 “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文版为准。 条款结束 如何将木兰宽松许可证,第2版,应用到您的软件 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; 3, 请将如下声明文本放入每个源文件的头部注释中。 Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details. Mulan Permissive Software License,Version 2 Mulan Permissive Software License,Version 2 (Mulan PSL v2) January 2020 http://license.coscl.org.cn/MulanPSL2 Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v2 (this License) with the following terms and conditions: 0. Definition Software means the program and related documents which are licensed under this License and comprise all Contribution(s). Contribution means the copyrightable work licensed by a particular Contributor under this License. Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. Legal Entity means the entity making a Contribution and all its Affiliates. Affiliates means entities that control, are controlled by, or are under common control with the acting entity under this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. 1. Grant of Copyright License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. 2. Grant of Patent License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution, where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed. The patent license shall not apply to any modification of the Contribution, and any other combination which includes the Contribution. If you or your Affiliates directly or indirectly institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. 3. No Trademark License No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in Section 4. 4. Distribution Restriction You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. 5. Disclaimer of Warranty and Limitation of Liability THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 6. Language THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION SHALL PREVAIL. END OF THE TERMS AND CONDITIONS How to Apply the Mulan Permissive Software License,Version 2 (Mulan PSL v2) to Your Software To apply the Mulan PSL v2 to your work, for easy identification by recipients, you are suggested to complete following three steps: i Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; ii Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; iii Attach the statement to the appropriate annotated syntax at the beginning of each source file. Copyright (c) [Year] [name of copyright holder] [Software Name] is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2 THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v2 for more details.

简介

An OS-level topology awareness service and a cause inference service. 展开 收起
MulanPSL-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/algorithmofdish/gala-spider.git
git@gitee.com:algorithmofdish/gala-spider.git
algorithmofdish
gala-spider
gala-spider
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891