ACS-ECS-ScheduleToExecuteDiagnosticReports.md
Run the blame command to query the fixed URL of a historical original file.
Modify
Template name
ACS-ECS-ScheduleToExecuteDiagnosticReports
Template description
Creates diagnostics reports for Elastic Compute Service (ECS) instances as scheduled.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
targets | The ECS instances to be diagnosed. | Json | Yes | ||
timerTrigger | The type of the scheduled task. | Json | No | {'expression': '0 0 1 ? * *', 'endDate': '2099-12-01T00:00:00Z', 'type': 'cron', 'timeZone': 'Asia/Shanghai'} | |
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
whetherNotify | Specifies whether to send notifications if exceptions are detected. | Boolean | No | False | |
notifyURI | The webhook URL to which notifications are sent. | String | No | "" | |
notifyAt | The users to which the notifications are sent. | String | No | "" | |
rateControl | The rate control settings. | Json | No | {'Mode': 'Concurrency', 'MaxErrors': '0', 'Concurrency': 10} | |
OOSAssumeRole | The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS). | String | No | "" |
Output parameters
Parameter | Description | Type |
metricResults | Json |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:CreateDiagnosticReport",
"ecs:DescribeDiagnosticReportAttributes",
"ecs:DescribeInstances"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
References
For more information, see ACS-ECS-ScheduleToExecuteDiagnosticReports.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Schedules to execute ECS diagnostic reports in bulk
zh-cn: the description in Chinese
name-en: ACS-ECS-ScheduleToExecuteDiagnosticReports
name-zh-cn: Perform health diagnostics on an ECS instance at regular intervals
categories:
- time_trigger
Parameters:
timerTrigger:
Type: Json
Label:
en: TimerTrigger
zh-cn: the description in Chinese
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: the description in Chinese
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
targets:
Type: Json
Description: the ECS instances to be diagnosed.
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: ALIYUN::ECS::Instance
RegionId: regionId
whetherNotify:
Type: Boolean
Description: specifies whether to send notifications if exceptions are detected.
Default: false
Label:
en: whether notify
zh-cn: the description in Chinese
notifyURI:
Type: String
Description: the webhook URL to which notifications are sent.
AssociationProperty: TextArea
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- ${whetherNotify}
- true
Label:
en: notify uri
zh-cn: the description in Chinese
Default: ''
notifyAt:
Type: String
Description: the users to which notifications are sent.
AssociationProperty: TextArea
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- ${whetherNotify}
- true
Label:
en: notify@
zh-cn: the description in Chinese
Default: ''
rateControl:
Description: the rate control settings.
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency,
MaxErrors: 0,
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: the description in Chinese
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: the description in Chinese
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: the description in Chinese
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: the description in Chinese
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: the description in Chinese
Properties:
DefaultTask: notify
Choices:
- When:
Fn::Equals:
- false
- '{{ whetherNotify }}'
NextTask: ACS::END
- Name: notify
Action: ACS::Notify
Description: the URL of the diagnostics report link that contains abnormal issues.
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: the description in Chinese
en: Configure Parameters
- Parameters:
- regionId
- targets
- rateControl
Label:
default:
zh-cn: the description in Chinese
en: Configure Parameters
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Configure Parameters
- Parameters:
- whetherNotify
- notifyURI
- notifyAt
Label:
default:
zh-cn: the description in Chinese
en: Configure Parameters