{"id":37010156,"url":"https://github.com/buexplain/alarm","last_synced_at":"2026-01-14T00:58:59.433Z","repository":{"id":45223248,"uuid":"271773280","full_name":"buexplain/alarm","owner":"buexplain","description":"这个是一个基于hyperf的告警组件","archived":false,"fork":false,"pushed_at":"2024-08-28T14:02:38.000Z","size":82,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-24T03:25:29.042Z","etag":null,"topics":["alarm","dingtalk","hyperf","wechat"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/buexplain.png","metadata":{"files":{"readme":"README.feishu.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-12T10:38:54.000Z","updated_at":"2024-08-28T14:02:41.000Z","dependencies_parsed_at":"2024-08-28T15:09:51.294Z","dependency_job_id":null,"html_url":"https://github.com/buexplain/alarm","commit_stats":{"total_commits":39,"total_committers":3,"mean_commits":13.0,"dds":"0.46153846153846156","last_synced_commit":"15567911a5f195607d3a4ee702c4143bc2f0f4e9"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/buexplain/alarm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buexplain%2Falarm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buexplain%2Falarm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buexplain%2Falarm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buexplain%2Falarm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buexplain","download_url":"https://codeload.github.com/buexplain/alarm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buexplain%2Falarm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"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":["alarm","dingtalk","hyperf","wechat"],"created_at":"2026-01-14T00:58:58.488Z","updated_at":"2026-01-14T00:58:59.402Z","avatar_url":"https://github.com/buexplain.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 飞书告警\n\n### logger.php的配置\n\n```php\n# logger.php\nreturn [    \n    // 这里配置一个飞书文字告警\n    'alarm' =\u003e [\n        'handlers' =\u003e [\n            //告警日志处理器\n            [\n                'class' =\u003e \\Alarm\\Handler::class,\n                'constructor' =\u003e [\n                    //此处的handler对应的正是config/autoload/alarm.php配置的key值\n                    'handlers'=\u003e[\n                        'feiShu', // 这里对应alarm.php配置的key\n                    ],\n                    //接收的日志级别\n                    'level'=\u003e\\Monolog\\Level::Error,\n                ],\n            ],\n        ],\n        'formatter' =\u003e [\n            'class'       =\u003e Monolog\\Formatter\\LineFormatter::class,\n            'constructor' =\u003e [\n                'format'                =\u003e null,\n                'dateFormat'            =\u003e 'Y-m-d H:i:s.u',\n                'allowInlineLineBreaks' =\u003e true,\n            ],\n        ],\n    ],\n    // 这里配置一个飞书富文本告警\n    'alarm_post' =\u003e [\n        'handlers' =\u003e [\n            //告警日志处理器\n            [\n                'class'       =\u003e \\Alarm\\Handler::class,\n                'constructor' =\u003e [\n                    //此处的handler对应的正是config/autoload/alarm.php配置的key值\n                    'handlers' =\u003e [\n                        'feiShuPost', // 这里对应alarm.php配置的key\n                    ],\n                    //接收的日志级别\n                    'level' =\u003e \\Monolog\\Level::Error,\n                ],\n            ],\n        ],\n        'formatter' =\u003e [\n            'class'       =\u003e Monolog\\Formatter\\LineFormatter::class,\n            'constructor' =\u003e [\n                'format'                =\u003e null,\n                'dateFormat'            =\u003e 'Y-m-d H:i:s.u',\n                'allowInlineLineBreaks' =\u003e true,\n            ],\n        ],\n    ],\n];\n\n```\n\n## alarm.php\n```php\nreturn [\n    //飞书群机器人配置 , 普通文字\n    'feiShu' =\u003e [\n        'class'       =\u003e \\Alarm\\Handler\\FeiShu\\FeiShu::class,\n        'constructor' =\u003e [\n            'formatter' =\u003e [\n                'class'       =\u003e \\Alarm\\Handler\\FeiShu\\TextFormatter::class,\n                'constructor' =\u003e [],\n            ],\n            'robots' =\u003e [\n                ['url' =\u003e 'https://open.feishu.cn/open-apis/bot/v2/hook/xxx-xxxxxx', 'secret' =\u003e ''],\n            ],\n        ],\n    ],\n    // 富文本\n    'feiShuPost' =\u003e [\n        'class'       =\u003e \\Alarm\\Handler\\FeiShu\\FeiShu::class,\n        'constructor' =\u003e [\n            'formatter' =\u003e [\n                'class'       =\u003e \\Alarm\\Handler\\FeiShu\\PostFormatter::class,\n                'constructor' =\u003e [],\n            ],\n            'robots' =\u003e [\n                ['url' =\u003e 'https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxx', 'secret' =\u003e ''],\n            ],\n        ],\n    ],\n];\n```\n\n\n### 调用例子\n\n```php\n$logger = \\Hyperf\\Utils\\ApplicationContext::getContainer()-\u003eget(\\Hyperf\\Logger\\LoggerFactory::class);\n$logger-\u003eget($name = '管理后台测试', $group = 'alarm')-\u003eerror('22333');  // 普通文本告警\n\n// 看飞书文档  https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/create_json?lang=zh-CN#45e0953e , 格式根据文档对应一下即可\n$title = '标题';\n$text = '内容';\n$content = [];\n$content['zh_cn']['title'] = $title; // 标题\n$content['zh_cn']['content'][] = [\n    ['tag' =\u003e 'text', 'text' =\u003e $text],  // 第一个内容\n    ['tag' =\u003e 'a', 'text' =\u003e '第一个链接', 'href' =\u003e 'https://open.feishu.cn/'], // 第二个内容 , 这是一个链接\n];\n\n$logger-\u003eget($name = '管理后台测试1', $group = 'alarm_post')-\u003eerror(json_encode($content)); // 富文本告警 (建议只用标题 + 内容 + 链接的方式) , 图片类需要先接入飞书的上传接口上传完图片后才能发图片类的日志 , 不适合告警业务.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuexplain%2Falarm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuexplain%2Falarm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuexplain%2Falarm/lists"}