preprio/opsgenie
Composer 安装命令:
composer require preprio/opsgenie
包简介
Laravel integration for Opsgenie alerts, incidents, and heartbeats.
README 文档
README
This SDK is used by the Prepr team to monitor Laravel projects in Atlassian Opsgenie.
Installation
Composer
composer require preprio/opsgenie
Config
Publish opsgenie.php config
php artisan vendor:publish --provider="Prepr\OpsGenie\OpsGenieServiceProvider"
Configuration
Update .env file with the api access token (API_ACCESS_TOKEN) and service id (SERVICE_ID).
Example:
OPSGENIE_KEY=API_ACCESS_TOKEN
OPSGENIE_SERVICE=SERVICE_ID
Optional configuration
Prefix
It's optional to add a prefix to the message that's send to Opsgenie, to clearify what service/repo. You can add a prefix by configuring the following line in your .env file.
OPSGENIE_PREFIX=preprio/mutation.prepr.io
Examples:
| config | result |
|---|---|
| PREFIX | [PREFIX] Message |
| preprio/mutation.prepr.io | [preprio/mutation.prepr.io] MESSAGE |
| mutation-api | [mutation-api] MESSAGE |
Default tags
It's optional to add default tags to the message that's send to Opsgenie. You can add a default tags by configuring the following line in your .env file. (comma-separated list)
OPSGENIE_TAGS=tagOne,tagTwo,etc.
Docs OpsGenie
Usage
Base
For an incident
Ops()->incident()
For an alert
Ops()->alert()
Priority functions (required)
Set incident priority.
| Priority | Function |
|---|---|
| Critical | ->P1() or ->critical() |
| High | ->P2() or ->high() |
| Moderate | ->P3() or ->moderate() |
| Low | ->P4() or ->low() |
| Informational | ->P5() or ->informational() |
Message (required)
Set incident title.
->message('Import failed')
Description (optional)
Set incident description.
->description('Import failed')
Details (optional)
Set incident details. (Key-Value list)
->description([ 'environment' => 'xxx-xxx-xxx', 'file' => 'xxx_x_xxxx_xxxx_xx.csv' 'example' => true ])
Tags (optional)
Set incident tags. (Simple list)
->tags(['critical', 'import', 'micro-service'])
Send (required)
Send incident to Opsgenie.
->send();
Full example:
Function above combined.
Ops() ->incident() ->critical() ->message('Import failed') ->description('The import script failed to import data from customer X.') ->details([ 'environment' => 'xxx-xxx-xxx', 'file' => 'xxx_x_xxxx_xxxx_xx.csv' 'example' => true ]) ->tags(['critical', 'import', 'micro-service']) ->send();
Alert attachments
Attach Resource/Blob (optional)
You can add attachments to alerts like log files, exception files, renders, json, etc.
By adding the following function(s) after ->send().
Ops() ... ->send() ->attachBlob('RESOURCE/BLOB', 'filename_with.extension');
You can also attach multiple files
Ops() ... ->send() ->attachBlob('RESOURCE/BLOB', 'filename_with.extension') ->attachBlob('<html><body><h1>Hello World!</h1></body></html', 'index.html'); ->attachBlob('{"Hello":"World"}', 'export.json');
Attach files (optional) ⚠️ NOT TESTED
Ops() ... ->send() ->attachFile('/path/to/file');
Attach example/combined
You can use attach-function multiple times, and mix them in random order.
For example 2x ->attachBlob(), 1x ->attachFile().
Ops() ... ->send() ->attachBlob('{"Hello":"World"}', 'export.json') ->attachFile('/path/to/file') ->attachBlob('<html><body><h1>Hello World!</h1></body></html', 'index.html');
preprio/opsgenie 适用场景与选型建议
preprio/opsgenie 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.79k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 11 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 preprio/opsgenie 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 preprio/opsgenie 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 10.79k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-22