From c2743784cbe9c1fd9af42ebf4f56b122ba538713 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Tue, 23 May 2023 22:22:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=A6=BBchassis=20agent=EF=BC=9B?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 48 +++--- chassis_agent/.dockerignore | 7 - chassis_agent/Admin Service.json | 261 ------------------------------- chassis_agent/docker-compose.yml | 32 ---- chassis_agent/statsd_config.js | 8 - chassis_agent/statsd_mapping.yml | 41 ----- 6 files changed, 30 insertions(+), 367 deletions(-) delete mode 100644 chassis_agent/.dockerignore delete mode 100644 chassis_agent/Admin Service.json delete mode 100644 chassis_agent/docker-compose.yml delete mode 100644 chassis_agent/statsd_config.js delete mode 100644 chassis_agent/statsd_mapping.yml diff --git a/README.md b/README.md index 6f658d2..2d7357b 100644 --- a/README.md +++ b/README.md @@ -2,29 +2,41 @@ chassis <ˈʃæsi> n. 底盘,底架 -仓库名寓意服务基座,基础库。 +仓库名寓意服务的底盘,基础库。搭建微服务底盘是为了简化服务的创建过程,同时确保开发者遵循这套开发标准。 + +## 包含的特性 + +1. 微服务模板代码 +2. 可观测 Observability + 1. Metrics (Statsd + Prometheus + Grafana) + 2. Logging (ELK) + 3. Tracing (TODO, Maybe OpenTelemetry) + 4. Error Reporting(Sentry) +3. 数据存储相关 utils + 1. Sqlalchemy + - 连接池 + - 读写分离 + 2. Redis + - 连接池 + 3. ElasticSearch +4. 服务注册和发现 (RabbitMQ) +5. 健康检查 (TODO) +6. 配置获取 (TODO) -微服务底座的目的是简化服务的创建过程,同时确保开发者拥有一套所有服务都要遵循的标准。 +## 实现的功能 -包含的特性 -1. 错误报告 -2. 日志收集 -3. Metrics 数据收集 -4. 配置获取 -5. 数据存储设置(ORM) -6. 健康检查 -7. 服务注册和发现 -8. 模板代码 - - -实现的功能 -- 服务发现 +- 服务注册和发现 - 可观测 -- 传输 +- 同步/异步传输 - 负载均衡 - 限流降级(消息确认+熔断) -安装方法: -`python3 -m pip install -U https://gitea.bearcatlog.com/BryantStudio/chassis.git` +## 安装方法 + +基础代码库: +`python3 -m pip install --trusted-host=gitea.bearcatlog.com git+https://gitea.bearcatlog.com/BryantStudio/chassis.git@main` + +基础代码库依赖的服务: +`python3 -m pip install --trusted-host=gitea.bearcatlog.com git+https://gitea.bearcatlog.com/BryantStudio/chassis-agent.git@main` diff --git a/chassis_agent/.dockerignore b/chassis_agent/.dockerignore deleted file mode 100644 index 36880ba..0000000 --- a/chassis_agent/.dockerignore +++ /dev/null @@ -1,7 +0,0 @@ -.venv -.git -.gitignore -.dockerignore -/log/* -/tmp/* -/test/reports/* \ No newline at end of file diff --git a/chassis_agent/Admin Service.json b/chassis_agent/Admin Service.json deleted file mode 100644 index 3a99fcb..0000000 --- a/chassis_agent/Admin Service.json +++ /dev/null @@ -1,261 +0,0 @@ -{ - "__inputs": [ - { - "name": "Prometheus", - "label": "Prometheus", - "description": "", - "type": "datasource", - "pluginId": "prometheus", - "pluginName": "Prometheus" - } - ], - "__requires": [ - { - "type": "grafana", - "id": "grafana", - "name": "Grafana", - "version": "4.6.2" - }, - { - "type": "panel", - "id": "graph", - "name": "Graph", - "version": "" - }, - { - "type": "datasource", - "id": "prometheus", - "name": "Prometheus", - "version": "1.0.0" - } - ], - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "editable": true, - "gnetId": null, - "graphTooltip": 0, - "hideControls": false, - "id": null, - "links": [], - "refresh": false, - "rows": [ - { - "collapse": false, - "height": "250px", - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "${Prometheus}", - "fill": 1, - "id": 5, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "hideEmpty": false, - "hideZero": false, - "max": true, - "min": true, - "rightSide": false, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "admin_service_hello", - "format": "time_series", - "hide": false, - "intervalFactor": 2, - "legendFormat": "admin_service_hello {{quantile}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Admin Service | Hello", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "transparent": false, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "${Prometheus}", - "fill": 1, - "id": 10, - "legend": { - "alignAsTable": true, - "avg": true, - "current": true, - "max": true, - "min": true, - "show": true, - "total": false, - "values": true - }, - "lines": true, - "linewidth": 1, - "links": [], - "nullPointMode": "null", - "percentage": false, - "pointradius": 5, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "span": 6, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "admin_service_error", - "format": "time_series", - "intervalFactor": 2, - "legendFormat": "admin_service_error {{quantile}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeShift": null, - "title": "Admin Service | Error", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ] - } - ], - "repeat": null, - "repeatIteration": null, - "repeatRowId": null, - "showTitle": false, - "title": "Dashboard Row", - "titleSize": "h6" - } - ], - "schemaVersion": 14, - "style": "dark", - "tags": [], - "templating": { - "list": [] - }, - "time": { - "from": "now-1h", - "to": "now" - }, - "timepicker": { - "refresh_intervals": [ - "5s", - "10s", - "30s", - "1m", - "5m", - "15m", - "30m", - "1h", - "2h", - "1d" - ], - "time_options": [ - "5m", - "15m", - "1h", - "6h", - "12h", - "24h", - "2d", - "7d", - "30d" - ] - }, - "timezone": "", - "title": "Admin Service", - "version": 5 -} \ No newline at end of file diff --git a/chassis_agent/docker-compose.yml b/chassis_agent/docker-compose.yml deleted file mode 100644 index 21f752e..0000000 --- a/chassis_agent/docker-compose.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: "3" - -services: - statsd-agent: - image: statsd/statsd:latest - restart: always - ports: - - "8125:8125/udp" - - "8126:8126" - volumes: - - "./statsd_config.js:/usr/src/app/config.js" - networks: - chassis_agent: - statsd-exporter: - image: prom/statsd-exporter:latest - hostname: "statsd-exporter" - command: "--statsd.mapping-config=/tmp/statsd_mapping.yml" - ports: - - "9102:9102" - - "9125:9125/udp" - volumes: - - "./statsd_mapping.yml:/tmp/statsd_mapping.yml" - networks: - chassis_agent: - -networks: - chassis_agent: - driver: bridge - -#volumes: -# chassis_agent_data: -# driver: local diff --git a/chassis_agent/statsd_config.js b/chassis_agent/statsd_config.js deleted file mode 100644 index 7a974e0..0000000 --- a/chassis_agent/statsd_config.js +++ /dev/null @@ -1,8 +0,0 @@ -(function () { - return { - "port": 8125, - "backends": ["./backends/repeater"], - "repeater": [{host: 'statsd-exporter', port: 9125}], - }; -})(); - diff --git a/chassis_agent/statsd_mapping.yml b/chassis_agent/statsd_mapping.yml deleted file mode 100644 index 9b4947d..0000000 --- a/chassis_agent/statsd_mapping.yml +++ /dev/null @@ -1,41 +0,0 @@ -mappings: -- match: "admin-service.admin-service.hello" - observer_type: summary - name: "hello" - labels: - provider: "$2" - outcome: "$3" - job: "admin-service" - summary_options: - quantiles: - - quantile: 0.99 - error: 0.001 - - quantile: 0.95 - error: 0.01 - - quantile: 0.9 - error: 0.05 - - quantile: 0.5 - error: 0.005 - max_summary_age: 30s - summary_age_buckets: 3 - stream_buffer_size: 1000 -- match: "admin-service.admin-service.error" - observer_type: summary - name: "error" - labels: - provider: "$2" - outcome: "$3" - job: "admin-service" - summary_options: - quantiles: - - quantile: 0.99 - error: 0.001 - - quantile: 0.95 - error: 0.01 - - quantile: 0.9 - error: 0.05 - - quantile: 0.5 - error: 0.005 - max_summary_age: 30s - summary_age_buckets: 3 - stream_buffer_size: 1000 \ No newline at end of file