云监控
函数 | 说明 |
函数 | 说明 |
Go Template 内置函数 | |
translate | 将变量值转换为自然语言。 translate(type string, lang string, val string) string
|
通用整形数字计算函数 |
|
集合操作函数 | 切片
map
|
字符串函数 |
|
时间函数 |
|
JSON 操作 |
|
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
MaxCount | Int | 配置告警模板在当前发送渠道的最大渲染资源数量。 | 5 | {{ .MaxCount }} |
Type | String | 告警类型,取值:
| Metric |
|
SiteName | String | 站点名称。 | 云监控 | {{ .SiteName }} |
AccountName | String | 账号名称。 | user-demo | {{ .AccountName }} |
AccountId | String | 账号 ID。 | 21000***** | {{ .AccountId }} |
RuleName | String | 告警策略名称。 | alarm-demo | {{ .RuleName }} |
RuleId | String | 告警策略 ID。 | 19251***** | {{ .RuleId }} |
RuleURL | String | 告警策略详情链接。 | https://console.volcengine.com/observe/cloud-monitor/alert/strategy?id=19251*****4565***** | {{ .RuleURL }} |
RuleType | String | 告警策略类型,取值:
| static | {{ .RuleType }} |
Namespace | String | 告警策略所属命名空间。 | VCM_ECS |
|
SubNamespace | String | 监控指标所属维度。 | Instance | {{ .SubNamespace }} |
Region | String | 告警策略所属地域。 | cn-beijing |
|
HappenedAt | time.Time | 告警发生时间。 | 2025-01-02 00:00:00(UTC+08:00) | 格式化时间:{{ .HappenedAt.Format "2006-01-02 15:04:05(UTCZ07:00)" }} |
RuleCondition | String | 告警触发条件。 | QPS 平均值环比上周期上涨或下降 0%, 持续 10 个周期(1 周期=1 分钟) | {{ .RuleCondition }} |
Level | String | 告警级别,取值:
| critical |
|
ProjectName | String | 告警策略所属项目名称。 | default | {{ .Project }} |
TagSet | Array of Tag | 告警策略标签,每个标签包含Key和Value。 | - | 遍历标签: {{ range $idx, $tag := .Tags }} {{ $tag.Key }}: {{ $tag.Value }} {{ end }} |
Resources | Array of ResourceMetric | 触发告警的云产品资源列表。 | - | 遍历资源: {{ range $idx, $resource := .Resources }} {{ $resource.Name }} ({{ $resource.Id}}) {{ end }} |
HistoryURL | String | 告警历史页面链接。 | https://console.volcengine.com/observe/cloud-monitor/alert/history | {{ .HistoryURL }} |
CreateSilenceURL | String | 创建告警屏蔽策略的链接。 | https://console.volcengine.com/observe/cloud-monitor/notice/silencePolicy/create?ruleId=19251***** | {{ .CreateSilenceURL }} |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
Key | String | 标签键。 | test | {{ $tag.Key }} |
Value | String | 标签值。 | test | {{ $tag.Value }} |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
AlertGroupId | String | 告警历史 ID。 | 67fd19****** | {{ $resource.AlertGroupId }} |
AlertGroupURL | String | 云产品资源告警详情链接。 | https://console.volcengine.com/observe/cloud-monitor/alert/history/detail?id=67fd19***** | {{ $resource.AlertGroupURL }} |
Id | String | 云产品资源 ID。 | i-yd9j***** | {{ $resource.Id }} |
Name | String | 云产品资源名称。 | ecs-demo | {{ $resource.Name }} |
DetailURL | String | 云产品资源监控链接。 | https://console.volcengine.com/observe/cloud-monitor/product/******* | {{ $resource.DetailURL }} |
Region | String | 云产品资源所属地域。 | cn-beijing |
|
FirstAlertTime | time.Time | 告警首次发生时间。 | 2025-01-01 00:00:00(UTC+08:00) | 格式化时间:{{ $resource.FirstAlertTime.Format "2006-01-02 15:04:05(UTCZ07:00)" }} |
LastAlertTime | time.Time | 告警最后发生时间。 | 2025-01-02 00:00:00(UTC+08:00) | 格式化时间:{{ $resource.LastAlertTime.Format "2006-01-02 15:04:05(UTCZ07:00)" }} |
LastSendLevel | String | 上一次发送告警级别,取值:
告警首次发送时,该值为空。 | warning |
|
Metrics | Array of MetricValue | 告警策略配置的指标列表。 当值为 NaN时,表示无数据。 | - | 遍历指标: {{ range $idx, $metric := $resource.Metrics }} {{ $metric.Name }}: {{ $metric.CurrentValue }}{{ $metric.Unit }} {{ end }} |
Dimensions | Array of MetricDimension | 云产品资源的维度列表。 | - | 遍历维度: {{ range $idx, $dimension := $resource.Dimensions }} {{ $dimension.Name }}: {{ $dimension.Value }} {{ end }} |
ProjectName | String | 云产品资源所属的项目名称。 | default | {{ $resource.ProjectName }} |
TagSet | Array of Tag | 云产品资源标签。 | - | 遍历标签: {{ range $key, $val := $resource.Tags }} {{ $key }}: {{ $val }} {{ end }} |
Metadatas | Array of Metadata | 云产品资源用于告警的元数据。 | - | 遍历元数据: {{ range $idx, $meta := $resource.Metadatas }} {{ $meta.Name }}: {{ $meta.Value }} {{ end }} |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
Name | String | 指标名称。 | CpuTotal | {{ $metric.Name }} |
Unit | String | 阈值单位。 | % | {{ $metric.Unit }} |
Threshold | String | 指标阈值。 | 80 | {{ $metric.Threshold }} |
CurrentValue | String | 当前指标值。 | 90 | {{ $metric.CurrentValue }} |
Description | String | 指标描述。 | CPU 使用率 | {{ $metric.Description }} |
Warn | Bool | 指标是否满足阈值条件。取值:
| true | {{ $metric.Warn }} |
IsTimeCompare | Bool | 是否同比、环比。取值:
| true | {{ $metric.IsTimeCompare }} |
InherentUnit | String | 指标单位。 | % | {{ $metric.IsTimeCompare }} |
LastValue | String | 上次指标值。 | 85 | {{ $metric.LastValue }} |
LastDescription | String | 上次指标描述,格式为{上周期}/{昨天同一时刻}/{上周同一时刻}{指标名}。 | 上周期 CPU 使用率 | {{ $metric.LastDescription }} |
CurrentValue | String | 当前指标值。 | 91 | {{ $metric.CurrentValue }} |
CurrentDescription | String | 当前指标描述,格式为{当前}{指标名}。 | 当前 CPU 使用率 | {{ $metric.CurrentDescription }} |
变量名 | 类型 | 说明 | 示例 | 用法示例 |
变量名 | 类型 | 说明 | 示例 | 用法示例 |
Name | String | 云产品维度名称。 | ResourceID | {{ $dimension.Name }} |
Value | String | 云产品维度值。 | i-yd9j*****ajrd7***** | {{ $dimension.Value }} |
Description | String | 云产品维度描述。 | 实例 ID | {{ $dimension.Description }} |
变量名 | 类型 | 说明 | 示例 | 用法示例 |
变量名 | 类型 | 说明 | 示例 | 用法示例 |
Name | String | 元数据名称。 | IP.Inside | {{ $meta.Name }} |
Value | String | 元数据值。 | 192.168.0.1 | {{ $meta.Value }} |
Description | String | 维度描述。 | 私网 IP 地址 | {{ $meta.Description }} |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
Type | String | 告警类型,取值固定为Event。 | Event |
|
SiteName | String | 站点名称。 | 云监控 | {{ .SiteName }} |
AccountName | String | 账号名称。 | user-demo | {{ .AccountName }} |
AccountId | String | 账号 ID。 | 21000***** | {{ .AccountId }} |
Source | String | 事件来源。 | ecs |
|
Level | String | 事件级别,取值:
说明 若匹配多个规则,取最高级别。 | critical |
|
Id | String | 事件 ID。 | 1803****** | {{ .Id }} |
Event | String | 事件类型。 | ecs:Instance:RebootInstance.Executing |
|
HappenedAt | time.Time | 事件发生时间。 | 2025-01-01 00:00:00(UTC+08:00) | 格式化时间:{{ .HappenedAt.Format "2006-01-02 15:04:05(UTCZ07:00)" }} |
Region | String | 云产品资源所属地域。 | cn-beijing |
|
ResourceId | String | 云产品资源 ID。 | i-yd9j***** | {{ .ResourceId }} |
ResourceName | String | 云产品资源名称。 | ecs-demo | {{ .ResourceName }} |
ProjectName | String | 云产品资源所属项目名称。 | default | {{ .Project }} |
TagSet | Array of Tag | 云产品资源标签,每个标签包含Key和Value。 | - | 遍历标签: {{ range $idx, $tag := .Tags }} {{ $tag.Key }}: {{ $tag.Value }} {{ end }} |
Details | map[string]interface{} | 事件详情。 说明 不同云产品的事件格式不同。 | - | 遍历详情: {{ range $key, $val := .Details }} {{ $key }}: {{ $val }} {{ end }} |
Rules | Array of EventRule | 匹配的事件规则列表。 | - | 遍历规则: {{ range $idx, $rule := .Rules }} {{ $rule.RuleName }} ({{ $rule.Level }}) {{ end }} |
HistoryURL | String | 事件中心链接。 | https://console.volcengine.com/observe/cloud-monitor/alert/history | {{ .HistoryURL }} |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
变量名 | 类型 | 说明 | 示例值 | 用法示例 |
RuleId | String | 事件规则 ID。 | 19251**** | {{ $rule.RuleId }} |
RuleName | String | 事件规则名称。 | event-demo | {{ $rule.RuleName }} |
Level | String | 事件规则级别,取值:
| critical |
|
RuleURL | String | 事件规则链接。 | https://console.volcengine.com/observe/cloud-monitor/event/rules/detail?id=1790**** | {{ $rule.RuleURL }} |