{"id":19614779,"url":"https://github.com/leancloud/satori","last_synced_at":"2026-03-05T01:31:11.248Z","repository":{"id":38361437,"uuid":"67022336","full_name":"leancloud/satori","owner":"leancloud","description":"Satori 是一个 LeanCloud 维护的监控系统，inspired by Open-Falcon","archived":false,"fork":false,"pushed_at":"2022-12-08T02:11:59.000Z","size":9849,"stargazers_count":233,"open_issues_count":25,"forks_count":74,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-05-20T04:03:49.958Z","etag":null,"topics":["monitoring","open-falcon","riemann"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leancloud.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-31T09:13:02.000Z","updated_at":"2025-05-13T03:47:23.000Z","dependencies_parsed_at":"2023-01-25T03:15:20.805Z","dependency_job_id":null,"html_url":"https://github.com/leancloud/satori","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leancloud/satori","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancloud%2Fsatori","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancloud%2Fsatori/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancloud%2Fsatori/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancloud%2Fsatori/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leancloud","download_url":"https://codeload.github.com/leancloud/satori/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leancloud%2Fsatori/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30104273,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T01:06:53.091Z","status":"ssl_error","status_checked_at":"2026-03-05T01:02:35.679Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["monitoring","open-falcon","riemann"],"created_at":"2024-11-11T10:53:43.569Z","updated_at":"2026-03-05T01:31:11.187Z","avatar_url":"https://github.com/leancloud.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 介绍\n\nSatori 是一个由 LeanCloud 维护的监控系统。\n\n起初在 LeanCloud 内部是直接使用了 [Open-Falcon](http://open-falcon.org/) 。\n后续的使用过程中因为自己的需求开始做修改，形成的现在的这样的结构。\n\n# 截图\n![Nodes](https://raw.githubusercontent.com/leancloud/satori/master/doc/images/nodes.png)\n![Events](https://raw.githubusercontent.com/leancloud/satori/master/doc/images/events.png)\n![BitBar](https://raw.githubusercontent.com/leancloud/satori/master/doc/images/bitbar.png)\n\n# 文档\n完整文档麻烦看[这里](http://satori-monitoring.rtfd.io)。\n\n# 交流\n如果你有什么建议，欢迎在 issue 里面说一下。\n也有 QQ 群可以参与讨论：554765935\n\n# 怎么安装？\n\n请找一个干净的虚拟机，内存大一点，要有 SSD，不要部署其他的服务。\nLeanCloud 用了一个 2 cores, 8GB 的内存的 VM，目测这个配置可以撑住大概 2000 个左右的节点（InfluxDB 查询不多的情况下）。\n\n执行下面的命令：\n\n```bash\n$ git clone https://github.com/leancloud/satori\n$ cd satori/satori\n$ ./install\n```\nsatori 子目录中有一个 install 脚本，以一个可以 ssh 并且 sudo 的用户执行它就可以了。\n不要用 root，因为安装后会以当前用户的身份配置规则仓库。\n\ninstall 时会问你几个问题，填好以后会自动的生成配置，build 出 docker image 并启动。这之后设置好DNS和防火墙就可以用了。\n在仓库的第一层会有编译好的 `satori-agent` 和 `agent-cfg.json` 可以用来部署，命令行如下：\n\n`/usr/bin/satori-agent -c /etc/satori-agent/agent-cfg.json`\n\nagent 不会自己 daemonize，如果用了传统的 `/etc/init.d` 脚本的方式部署，需要注意这个问题。\n\n如果需要无人工干预安装，请创建一个配置文件：\n\n```bash\nUSE_MIRROR=1  # 或者留空，是否使用国内的镜像\nDOMAIN=\"www.example.com\"  # 外网可以访问的域名\nINTERNAL_DOMAIN=\"satori01\"  # 内网可以访问的域名\nRULES_REPO=\"/home/app/satori-conf\"  # 规则仓库的地址\nRULES_REPO_SSH=\"app@www.example.com:/home/app/satori-conf\"  # 外网可以访问的 git 仓库地址\n```\n\n保存为 `/tmp/install.conf`。\n\n然后执行：\n```bash\n$ git clone https://github.com/leancloud/satori\n$ cd satori/satori\n$ ./install -f /tmp/install.conf\n```\n\n# 设计思路\n- Satori 希望最大程度的减少监控系统的部署维护难度。如果在任何的部署、增删维护报警的时候觉得好麻烦，那么这是个 bug。\n- 监控时的需求很多样，Satori 希望做到『让简单的事情简单，让复杂的事情可能』。常用的监控项都会有模板，可以用 Copy \u0026 Paste 解决。略复杂的监控需求可以阅读 [riemann 的文档](http://riemann.io/)，来得知怎么编写复杂的监控规则。\n- 因为 LeanCloud 的机器规模不大，另外再加上现在机器的性能也足够强劲了，所以放弃了 Open-Falcon 中横向扩展目标。如果你的机器数量或者指标数目确实很大，可以将 transfer、 InfluxDB、 riemann 分开部署。这样的结构支撑 5k 左右的节点应该是没问题的。\n- 在考察了原有的 Open-Falcon 的架构后，发现实质上高可用只有 transfer 实现了，graph、judge 任何一个实例挂掉都会影响可用性。对于 graph，如果一个实例挂掉的话，还必须要将那个节点恢复，不能通过新加节点改配置的方式来恢复；judge 尽管可以起新节点，但是还是要依赖外部的工具来实现 failover，否则是需要修改 transfer 的配置的。因此 Satori 中坚持用单点的方式来部署，然后通过配合公网提供的 APM 服务保证可用性。真的希望有高可用的话，riemann 和 alarm 可以部署两份，通过 keepalived 的方式来实现，InfluxDB 可以官方的 Relay 来实现。\n\n# 1 minute taste\n\n## 简单需求（通用模板，Copy \u0026 Paste 改参数可以实现）\n\n\u003e 完整版请看 `satori-rules/rules/infra/mongodb.clj`\n\n```clojure\n(def infra-mongodb-rules\n  ; 在 mongo1 mongo2 mongo3 ... 上做监控\n  (where (host #\"^mongo\\d+\")\n\n    ; 执行 mongodb 目录里的插件（里面有收集 mongodb 指标的脚本）\n    (plugin-dir \"mongodb\")\n\n    ; 每 30s 收集 27018 端口是不是在监听\n    (plugin \"net.port.listen\" 30 {:port 27018})\n\n    ; 过滤一下 mongodb 可用连接数的 metric（上面插件收集的）\n    (where (service \"mongodb.connections.available\")\n      ; 按照 host（插件中是 endpoint）分离监控项，并分别判定\n      (by :host\n        ; 报警在监控值 \u003c 10000 时触发，在 \u003e 50000 时恢复\n        (set-state-gapped (\u003c 10000) (\u003e 50000)\n          ; 600 秒内只报告一次\n          (should-alarm-every 600\n            ; 报告的标题、级别（影响报警方式）、报告给 operation 组和 api 组\n            (! {:note \"mongod 可用连接数 \u003c 10000 ！\"\n                :level 1\n                :groups [:operation :api]})))))\n\n    ; 另一个监控项\n    (where (service \"mongodb.globalLock.currentQueue.total\")\n      (by :host\n        (set-state-gapped (\u003e 250) (\u003c 50)\n          (should-alarm-every 600\n            (! {:note \"MongoDB 队列长度 \u003e 250\"\n                :level 1\n                :groups [:operation :api]})))))))\n```\n\n```bash\ncd /path/to/rules/repo  # 规则是放在 git 仓库中的\ngit commit -a -m 'Add mongodb rules'\ngit push  # 然后就生效了\n```\n\n## 复杂需求\n\n这是一个监控队列堆积的规则。\n队列做过 sharding，分布在多个机器上。\n但是有好几个数据中心，要分别报告每个数据中心队列情况。\n堆积的定义是：在一定时间内，队列非空，而且队列元素数量没有下降。\n\n\u003e 提示：这是一个简化了的版本，完整版可以看 `satori-rules/rules/infra/kestrel.clj`\n\n```clojure\n(def infra-kestrel-rules\n ; 在所有的队列机器上做监控\n (where (host #\"kestrel\\d+$\")\n  ; 执行队列相关的监控脚本（插件）\n  (plugin-dir \"kestrel\")\n\n  ; 过滤『队列项目数量』的 metric\n  (where (service \"kestrel_queue.items\")\n   ; 按照队列名和数据中心分离监控项，并分别判定\n   (by [:queue :region]\n    ; 将传递下来的监控项暂存 60 秒，然后打包（变成监控项的数组）再向下传递\n    (fixed-time-window 60\n     ; 将打包传递下来的监控项做聚集：将所有的 metric 值都加起来。\n     ; 因为队列监控的插件是每 60 秒报告一次，并且之前已经按照队列名和数据中心分成子流了，\n     ; 所以这里将所有 metric 都加起来以后，获得的是单个数据中心单个队列的项目数量。\n     ; 聚集后会由监控项数组变成单个的监控项。\n     (aggregate +\n      ; 将传递下来的聚集后的监控项放到滑动窗口里，打包向下传递。\n      ; 这样传递下去的，就是一个过去 600 秒单个数据中心单个队列的项目数量的监控项数组。\n      (moving-event-window 10\n       ; 如果已经集满了 10 个，而且这 10 个监控项中都不为 0 （队列非空）\n       (where (and (\u003e= (count event) 10)\n                   (every? pos? (map :metric event)))\n        ; 再次做聚集：比较一下是不是全部 10 个数量都是先来的小于等于后来的（是不是堆积）\n        (aggregate \u003c=\n         ; 如果结果是 true，那么认为现在是有问题的\n         (set-state (= true)\n          ; 每 1800 秒告警一次\n          (should-alarm-every 1800\n           ; 这里 outstanding-tags 是用来区分报警的，\n           ; 即如果 region 的值不一样，那么就会被当做不同的报警\n           (! {:note #(str \"队列 \" (:queue %) \" 正在堆积！\")\n               :level 2\n               :outstanding-tags [:region]\n               :groups [:operation]}))))))))))))\n```\n\n# 架构\n![Architecture](https://raw.githubusercontent.com/leancloud/satori/master/doc/images/arch.png)\n\n# 与 Open-Falcon 的区别\n\n## agent\n- 支持按照正则表达式排除 metric（用例：排除 docker 引入的奇怪的挂载，netns 什么的）\n- 支持从 agent 上附加固定的 tag（用例：region=cn-west）\n- 支持自主的插件更新\n- 支持带参数的插件\n- 支持持续执行(long running)的插件\n- 去除了 push 和 plugin 以外的所有 http 接口\n- 去掉了单机部署的功能，现在强制要求指定一个 transfer 组件\n- 不兼容 open-falcon 的 heartbeat\n- 因为修改了 metric 的数据结构，与 open-falcon 的 transfer 不兼容\n\n## transfer：\n- 支持发送到 influxdb（使用了 hitripod 的补丁）\n- 支持发送到 riemann\n- 支持发送到 transfer（gateway 功能集成）\n- 不再支持发送到 graph 和 judge\n- 重构了发送端的代码，现在代码比之前容易维护了\n\n## alarm：\n- 弃用了 open-falcon 的 alarm，完全重写\n- 不支持报警合并\n- 支持 EVENT 类型（只报警不记录状态）\n- 支持多种报警后端（电话、短信、BearyChat、OneAlert、PagerDuty、邮件、微信企业号），并且易于扩展\n- Mac 下有好用的 BitBar 插件\n\n## sender\n集成进了 alarm 中。\n\n## links\n在 Satori 中移除了。推荐直接使用低优先级的通道（如 BearyChat/其他IM，或者 BitBar），不做报警合并。\n\n## graph \u0026 query \u0026 dashboard\n被 Grafana 和 InfluxDB 代替\n\n## judge：\n- 被 riemann 代替\n- riemann 较 judge 相比，可以节省 60% 以上的内存，CPU占用要低 50%。\n\n## task\n在 Satori 中移除了。InfluxDB 自带 task 的功能。\n\n## aggregator\n在 Satori 中移除了。riemann 中可以轻松的实现 aggregator 的功能。\n\n## nodata\n在 Satori 中移除了。可以参见规则中的 feed-dog 和 watchdog，实现了相同的功能。\n\n## portal\n在 Satori 中移除了。报警规则通过 git 仓库管理。\n\n## gateway:\n合并进了 transfer\n\n## hbs\n- 在 Satori 中叫做 master\n- 与 hbs 不兼容\n- 不再将节点数据记录到数据库中，没有数据库的依赖。\n\n## uic\nSatori 中去除，直接在规则仓库中编辑用户信息。\n\n## fe\n完全重写，采用了纯前端的方案（frontend 文件夹）。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleancloud%2Fsatori","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleancloud%2Fsatori","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleancloud%2Fsatori/lists"}