ACS-ECS-ScheduleToExecuteDiagnosticReports.md
Blame歷史原始檔案固定地址
編輯
模板名稱
ACS-ECS-ScheduleToExecuteDiagnosticReports 定時執行ECS健康診斷
模板描述
定時運行ECS健康診斷
模板類型
自動化
所有者
Alibaba Cloud
輸入參數
參數名稱 | 描述 | 類型 | 是否必填 | 預設值 | 約束 |
targets | ECS執行個體 | Json | 是 | ||
timerTrigger | 定時類型 | Json | 否 | {‘expression’: ‘0 0 1 ? * *’, ‘endDate’: ‘2099-12-01T00:00:00Z’, ‘type’: ‘cron’, ‘timeZone’: ‘Asia/Shanghai’} | |
regionId | 地區ID | String | 否 | {{ ACS::RegionId }} | |
whetherNotify | 是否通知異常結果 | Boolean | 否 | False | |
notifyURI | 通知地址 | String | 否 | “” | |
notifyAt | 通知@ | String | 否 | “” | |
rateControl | 任務執行的並發比率 | Json | 否 | {‘Mode’: ‘Concurrency,’, ‘MaxErrors’: ‘0,’, ‘Concurrency’: 10} | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | “” |
輸出參數
參數名稱 | 描述 | 類型 |
metricResults | Json |
執行此模板需要的權限原則
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:CreateDiagnosticReport",
"ecs:DescribeDiagnosticReportAttributes",
"ecs:DescribeInstances"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳情
ACS-ECS-ScheduleToExecuteDiagnosticReports詳情
模板內容
FormatVersion: OOS-2019-06-01
Description:
en: Schedules to execute ECS diagnostic reports in bulk
zh-cn: 定時運行ECS健康診斷
name-en: ACS-ECS-ScheduleToExecuteDiagnosticReports
name-zh-cn: 定時執行ECS健康診斷
categories:
- time_trigger
Parameters:
timerTrigger:
Type: Json
Label:
en: TimerTrigger
zh-cn: 定時類型
AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
AssociationPropertyMetadata:
MinuteInterval: 30
Default:
expression: 0 0 1 ? * *
endDate: '2099-12-01T00:00:00Z'
type: cron
timeZone: Asia/Shanghai
regionId:
Type: String
Label:
en: RegionId
zh-cn: 地區ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Type: Json
Description: ECS執行個體
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: ALIYUN::ECS::Instance
RegionId: regionId
whetherNotify:
Type: Boolean
Description: 是否通知
Default: false
Label:
en: whether notify
zh-cn: 是否通知異常結果
notifyURI:
Type: String
Description: 通知WebHook
AssociationProperty: TextArea
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- ${whetherNotify}
- true
Label:
en: notify uri
zh-cn: 通知地址
Default: ''
notifyAt:
Type: String
Description: 通知@人員
AssociationProperty: TextArea
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- ${whetherNotify}
- true
Label:
en: notify@
zh-cn: 通知@
Default: ''
rateControl:
Description: 任務執行的並發比率
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency,
MaxErrors: 0,
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS扮演的RAM角色
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
Action: ACS::TimerTrigger
Description:
en: Triggers a task as scheduled by specifying type and expression
zh-cn: 通過指定觸發類型和運算式按計劃觸發任務
Properties:
Type:
Fn::Select:
- type
- '{{timerTrigger}}'
Expression:
Fn::Select:
- expression
- '{{timerTrigger}}'
EndDate:
Fn::Select:
- endDate
- '{{ timerTrigger }}'
TimeZone: Asia/Shanghai
Outputs: {}
- Name: getInstances
Description:
en: Views the ECS instances
zh-cn: 擷取ECS執行個體
Action: ACS::SelectTargets
Properties:
ResourceType: ALIYUN::ECS::Instance
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
- Name: createDiagnosticReports
Action: ACS::ECS::CreateDiagnoseReport
Description:
en: Create diagnostic report for ECS instance
zh-cn: 建立ECS執行個體診斷報告
Properties:
regionId: '{{ regionId }}'
resourceId: '{{ ACS::TaskLoopItem }}'
metricSetId: dms-instancedefault
Loop:
Items: '{{ getInstances.instanceIds }}'
Outputs:
metricResults:
AggregateType: Fn::ListJoin
AggregateField: metricResult
RateControl:
MaxErrors: 0
Mode: Concurrency
Concurrency: 1
Outputs:
metricResult:
Type: Json
ValueSelector: .metricResults | .MetricResult = (.MetricResult[] | select(.Issues.Issue | length > 0))
- Name: wheatherNotify
Action: ACS::Choice
Description:
en: wheather notify
zh-cn: 通知選擇
Properties:
DefaultTask: notify
Choices:
- When:
Fn::Equals:
- false
- '{{ whetherNotify }}'
NextTask: ACS::END
- Name: notify
Action: ACS::Notify
Description: 通知有異常Issue的診斷報告連結
Properties:
NotifyType: WebHook
WebHook:
URI: '{{ notifyURI }}'
Headers:
Content-Type: application/json
Content:
msgtype: text
text:
type: Json
content: '{{ createDiagnosticReports.metricResults }}'
At: '{{ notifyAt }}'
Outputs: {}
Outputs:
metricResults:
Type: Json
Value: '{{ createDiagnosticReports.metricResults }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- timerTrigger
Label:
default:
zh-cn: 設定周期參數(必填)
en: Configure Parameters
- Parameters:
- regionId
- targets
- rateControl
Label:
default:
zh-cn: 設定地區、所選執行個體、並發個數(必填)
en: Configure Parameters
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: 設定執行的RAM角色(必填)
en: Configure Parameters
- Parameters:
- whetherNotify
- notifyURI
- notifyAt
Label:
default:
zh-cn: 設定類DingTalk的參數(選填)
en: Configure Parameters