准备配置
提示
配置文件中,env
为当前环境,dependHouYi
和 dependRabbit
为是否依赖后羿和月兔组件,server.name
为当前组件名称,server.httpEndpoint
和 server.grpcEndpoint
为当前组件的 http 和 grpc 地址,server.network
为当前组件的网络类型,server.metadata
为当前组件的描述和背景,http
和 grpc
为当前组件的 http 和 grpc 配置,cache
为当前组件的缓存配置,database
为当前组件的数据库配置,bizDatabase
为当前组件的业务数据库配置,alarmDatabase
为当前组件的告警数据库配置,log
为当前组件的日志配置,oauth2
为当前组件的 oauth2 配置,email_config
为当前组件的邮件配置,oss
为当前组件的 oss 配置
- Palace
- HouYi
- Rabbit
palace 配置文件
env: dev
dependHouYi: true
dependRabbit: true
server:
name: 'Palace'
metadata:
description: palace是moon监控系列的监控平台,用于管理告警、监控、配置、日志、数据源等
background: 寓意为月宫,表示moon系列的统一管理平台
http:
addr: 0.0.0.0:8000
timeout: 50s
grpc:
addr: 0.0.0.0:9000
timeout: 50s
jwt:
sign_key: 'moon-sign_key'
issuer: 'moon-palace'
expire: 3600s
allow_list:
- /api.admin.authorization.Authorization/Login
- /api.admin.authorization.Authorization/Captcha
- /api.admin.authorization.Authorization/CreatePassword
- /api.Health/Check
- /api.Alert/Hook
- /api.admin.authorization.Authorization/VerifyEmail
- /api.admin.authorization.Authorization/SetEmailWithLogin
cache:
driver: 'redis'
redis:
network: 'tcp'
addr: redis.middleware.svc.cluster.local:6379
db: 0
password: 'lQz8OMgje7UyoD'
read_timeout: 0.2s
write_timeout: 0.2s
dial_timeout: 0.2s
database:
driver: 'mysql'
debug: false
dsn: 'root:FfVodQL2BLo02H@tcp(mysql.middleware.svc.cluster.local:3306)/moon?charset=utf8mb4&parseTime=True&loc=Local'
bizDatabase:
driver: 'mysql'
debug: false
dsn: 'root:FfVodQL2BLo02H@tcp(mysql.middleware.svc.cluster.local:3306)/'
alarmDatabase:
driver: 'mysql'
debug: false
dsn: 'root:FfVodQL2BLo02H@tcp(mysql.middleware.svc.cluster.local:3306)/'
log:
type: 'slog'
level: 'debug'
slog:
json: true
oauth2:
redirect_uri: 'https://moon.aide-cloud.cn'
github:
client_id: ''
client_secret: ''
callback_uri: 'https://moon.aide-cloud.cn/api/auth/github/callback'
scopes:
- 'user'
- 'email'
gitee:
client_id: ''
client_secret: ''
callback_uri: 'https://moon.aide-cloud.cn/api/auth/gitee/callback'
scopes:
- 'user_info'
- 'emails'
email_config:
host: smtp.163.com
port: 25
user:
pass:
oss:
type: 'local'
limitSize:
yml:
max: 524228
yaml:
max: 524228
local:
path: './data/moon_oss'
url: https://moon.aide-cloud.cn/api
downloadPre: '/file/download'
houyi 配置文件
env: dev
dependPalace: true
server:
name: moon_houyi
httpEndpoint: 'houyi.application.svc.cluster.local:8001'
grpcEndpoint: 'houyi.application.svc.cluster.local:9001'
network: 'rpc'
metadata:
description: 是moon监控系列的告警组件,可以独立部署,接受prom类型规则,也可以接受alertmanager类型组件的告警推送
background: 寓意为天神后羿,专门用于监控规则告警事件
http:
addr: 0.0.0.0:8001
timeout: 50s
grpc:
addr: 0.0.0.0:9001
timeout: 50s
cache:
driver: 'redis'
redis:
network: 'tcp'
addr: redis.middleware.svc.cluster.local:6379
db: 0
password: 'lQz8OMgje7UyoD'
read_timeout: 0.2s
write_timeout: 0.2s
dial_timeout: 0.2s
watch:
strategy:
timeout: 10s
interval: '@every 10s'
alertEvent:
timeout: 10s
interval: 10s
palace_server:
network: 'rpc'
nodeVersion: ''
endpoint: 'palace.application.svc.cluster.local:9000'
timeout: 50s
secret: ''
rabbit 配置文件
env: dev
dependPalace: true
server:
name: moon_rabbit
httpEndpoint: 'rabbit.application.svc.cluster.local:8002'
grpcEndpoint: 'rabbit.application.svc.cluster.local:9002'
network: 'rpc'
secret: ''
metadata:
description: 是moon监控系列的消息组件,可以独立部署,接受任意的hook消息,并支持邮件、钉钉、企业微信、飞书等告警
background: 寓意为月宫中的玉兔,专门用于消息通知
http:
addr: 0.0.0.0:8002
timeout: 2s
grpc:
addr: 0.0.0.0:9002
timeout: 2s
log:
type: 'slog'
level: 'debug'
slog:
json: true
cache:
driver: 'redis'
redis:
network: 'tcp'
addr: redis.middleware.svc.cluster.local:6379
db: 0
password: 'lQz8OMgje7UyoD'
read_timeout: 0.2s
write_timeout: 0.2s
dial_timeout: 0.2s
global_email_config:
host: smtp.163.com
port: 25
user:
pass:
palace_server:
network: 'rpc'
nodeVersion: ''
endpoint: 'palace.application.svc.cluster.local:9000'
timeout: 50s
secret: ''
# TODO 调整模板结构, 支持多租户
templates:
email: |
<h1>监控告警</h1>
<p>{{ .annotations.summary }}</p>
<p>{{ .annotations.description }}</p>
<p>时间: {{ .startsAt }} 至 {{ .endsAt }}</p>
dingtalk: |
{{- $status := .status -}}
{{- $labels := .labels -}}
{{- $annotations := .annotations -}}
{
"msgtype": "markdown",
"markdown": {
"title": "平台状态通知",
"text": "### {{if eq $status `resolved`}}✅ 告警已恢复{{else}}������ 紧急告警通知{{end}}\n\n \n**时间**: `{{ .startsAt }}` 至 `{{ .endsAt }}` \n\n<hr/>\n\n**摘要**: \n`{{ $annotations.summary }}` \n\n**描述**: \n`{{ $annotations.description }}` \n\n<hr/>\n\n**标签**: \n- **数据源 ID**: {{ index $labels "__moon__datasource_id__" }} \n- **数据源 URL**: [链接]({{ index $labels "__moon__datasource_url__" }}) \n- **级别 ID**: {{ index $labels "__moon__level_id__" }} \n- **策略 ID**: {{ index $labels "__moon__strategy_id__" }} \n- **团队 ID**: {{ index $labels "__moon__team_id__" }} \n- **实例**: `{{ index $labels "instance" }}` \n- **IP**: `{{ index $labels "ip" }}` \n- **作业**: `{{ index $labels "job" }}` \n\n<hr/>\n\n请根据以上信息进行后续处理!"
}
}
feishu: |
{
"msg_type": "interactive",
"card": {
"config": {
"wide_screen_mode": true
},
"header": {
"title": {
"tag": "plain_text",
"content": "{{if eq .status `resolved`}}✅ 告警已恢复{{else}}🚨 紧急告警通知{{end}}"
},
"template": "{{if eq .status `resolved`}}green{{else}}red{{end}}"
},
"elements": [
{
"tag": "div",
"fields": [
{
"is_short": false,
"text": {
"tag": "lark_md",
"content": "**🔍 告警摘要**\n{{.annotations.summary}}"
}
},
{
"is_short": false,
"text": {
"tag": "lark_md",
"content": "**🔍 告警描述**\n{{.annotations.description}}"
}
},
{
"is_short": false,
"text": {
"tag": "lark_md",
"content": "**🔍 开始时间**\n{{.startsAt}}"
}
},
{
"is_short": false,
"text": {
"tag": "lark_md",
"content": "{{if eq .status `resolved`}}**🔍 恢复时间**\n{{.endsAt}}{{end}}"
}
}
]
},
{
"tag": "hr"
},
{
"tag": "div",
"fields": [
{
"is_short": true,
"text": {
"tag": "lark_md",
"content": "**❗ 状态**\n<font color=\"warning\">{{.status}}</font>"
}
},
{
"is_short": true,
"text": {
"tag": "lark_md",
"content": "**🌐 数据源**\n[点击查看]({{.labels.__moon__datasource_url__}})"
}
},
{
"is_short": true,
"text": {
"tag": "lark_md",
"content": "**📛 告警名称**\n<font color=\"info\">{{.labels.__name__}}</font>"
}
},
{
"is_short": true,
"text": {
"tag": "lark_md",
"content": "**🔗 策略 ID**\n{{.labels.__moon__strategy_id__}}"
}
},
{
"is_short": true,
"text": {
"tag": "lark_md",
"content": "**🆔 团队 ID**\n{{.labels.__moon__team_id__}}"
}
},
{
"is_short": true,
"text": {
"tag": "lark_md",
"content": "**💻 IP 地址**\n{{.labels.ip}}"
}
}
]
},
{
"tag": "hr"
},
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": {
"tag": "lark_md",
"content": "📄 查看详情"
},
"url": "{{.labels.__moon__datasource_url__}}",
"type": "primary"
}
]
}
]
}
}
wechat: |
{
"msgtype": "markdown",
"markdown": {
"content": "### {{if eq .status `resolved`}}✅ 告警已恢复{{else}}🚨 紧急告警通知{{end}}\n\n {{ .annotations }}"
}
}