All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::CMS2::AggTaskGroup

Last Updated:Oct 10, 2026

The ALIYUN::CMS2::AggTaskGroup type is used to create aggregation task groups.

Syntax

{
  "Type": "ALIYUN::CMS2::AggTaskGroup",
  "Properties": {
    "AggTaskGroupName": String,
    "AggTaskGroupConfig": String,
    "InstanceId": String,
    "TargetPrometheusId": String,
    "AggTaskGroupConfigType": String,
    "CronExpr": String,
    "Description": String,
    "Delay": Integer,
    "FromTime": Integer,
    "MaxRetries": Integer,
    "MaxRunTimeInSeconds": Integer,
    "OverrideIfExists": Boolean,
    "PrecheckString": Map,
    "Status": String,
    "ScheduleTimeExpr": String,
    "ScheduleMode": String,
    "ToTime": Integer,
    "Tags": List
  }
}

Properties

Property

Type

Required

Editable

Description

Constraints

AggTaskGroupConfig

String

Yes

Yes

The configuration of the aggregation task group.

Only the RecordingRuleYaml format is supported. The configuration must meet the format requirements for the open source Prometheus RecordingRule. For example,

groups:
  - name: node.rules
    interval: 60s
    rules:
      - record: node_namespace_pod:kube_pod_info:
        expr: "max(label_replace(kube_pod_info{job=\"kubernetes-pods-kube-state-metrics\"}, \"pod\", \"$1\", \"pod\", \"(.*)\")) by (node, namespace, pod, cluster)"

AggTaskGroupName

String

Yes

Yes

The name of the aggregation task group.

None

InstanceId

String

Yes

No

The ID of the source Prometheus instance from which the aggregation task group reads data.

None

TargetPrometheusId

String

Yes

Yes

The ID of the target Prometheus instance for the aggregation task group.

None

AggTaskGroupConfigType

String

No

Yes

The configuration type of the aggregation task group.

Defalut:

  • RecordingRuleYaml

CronExpr

String

No

Yes

The cron expression.

For example, 0/1 * * * * indicates that the task is scheduled every minute starting from minute 0.

Delay

Integer

No

Yes

The fixed delay for scheduling.

Unit: seconds.

Default value: 30.

Description

String

No

Yes

The description of the aggregation task group.

None

FromTime

Integer

No

Yes

The timestamp in seconds that corresponds to the scheduling start time.

None

MaxRetries

Integer

No

Yes

The maximum number of retries for an aggregation task.

Default value: 20.

MaxRunTimeInSeconds

Integer

No

Yes

The maximum run time for an aggregation task.

Unit: seconds.

Default value: 600.

OverrideIfExists

Boolean

No

No

Specifies whether to overwrite and update an existing aggregation task group with the same name when the task group is created.

None

PrecheckString

Map

No

Yes

The precheck configuration.

No configuration is specified by default. The input string must be correctly parsed as JSON. For example,

{
  "policy": "skip",
  "prometheusId": "xxx",
  "query": "scalar(sum(count_over_time(up{job=\"_arms/kubelet/cadvisor\"}[15s])) / 21)",
  "threshold": 0.5,
  "timeout": 15,
  "type": "promql"
}

ScheduleMode

String

No

Yes

The scheduling mode.

Valid values:

  • Cron

  • FixedRate

ScheduleTimeExpr

String

No

Yes

The scheduling time expression.

(Recommended) Use @s or @m to specify the rounding granularity of the scheduling time window. Default value: @m.

Status

String

No

Yes

The status of the aggregation task group.

Valid values:

  • Running

  • Stopped

Tags

List

No

Yes

The tags of the aggregation task group.

For more information, see Tags properties.

ToTime

Integer

No

Yes

The timestamp in seconds that corresponds to the scheduling end time.

A value of 0 indicates that scheduling never stops.

Tags syntax

"Tags": [
  {
    "Value": String,
    "Key": String
  }
]

Tags properties

Property

Type

Required

Editable

Description

Constraints

Key

String

Yes

No

The key of the tag.

None

Value

String

No

No

The value of the tag.

None

Return values

Fn::GetAtt

  • AggTaskGroupName: The name of the aggregation task group.

  • Status: The current status of the aggregation task group.

  • AggTaskGroupConfigHash: The configuration hash of the aggregation task group.

  • AggTaskGroupId: The ID of the aggregation task group.

  • SourcePrometheusId: The ID of the source Prometheus instance of the aggregation task group.

Examples

Scenario 1: Create an aggregation task group for an existing Prometheus instance

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create a simple aggregation task group for an existing Prometheus instance by using the default scheduling configuration and basic recording rules.
  en: Create a simple aggregation task group for an existing Prometheus instance with default schedule configuration and basic recording rules.
Parameters:
  SourcePrometheusId:
    Type: String
    Label:
      zh-cn: Source Prometheus Instance ID
      en: Source Prometheus Instance ID
    Description:
      zh-cn: The ID of the source Prometheus instance from which the aggregation task group reads data.
      en: The ID of the source Prometheus instance that the agg task group reads data from.
  TargetPrometheusId:
    Type: String
    Label:
      zh-cn: Target Prometheus Instance ID
      en: Target Prometheus Instance ID
    Description:
      zh-cn: The ID of the target Prometheus instance to which the aggregation results are written.
      en: The ID of the target Prometheus instance that the agg task group writes data to.
  AggTaskGroupName:
    Type: String
    Label:
      zh-cn: Aggregation Task Group Name
      en: Agg Task Group Name
    Description:
      zh-cn: The name of the aggregation task group.
      en: The name of the aggregation task group.
    Default: simple-agg-task-group
Resources:
  AggTaskGroup:
    Type: ALIYUN::CMS2::AggTaskGroup
    Properties:
      AggTaskGroupName:
        Ref: AggTaskGroupName
      InstanceId:
        Ref: SourcePrometheusId
      TargetPrometheusId:
        Ref: TargetPrometheusId
      AggTaskGroupConfig: |-
        groups:
          - name: basic_rules
            rules:
              - record: job:node_cpu_usage:avg_rate5m
                expr: avg by (job) (rate(node_cpu_seconds_total{mode!="idle"}[5m]))
      Description: Simple aggregation task group
Outputs:
  AggTaskGroupId:
    Description:
      zh-cn: Aggregation task group ID.
      en: Agg task group ID.
    Label:
      zh-cn: Aggregation Task Group ID
      en: Agg Task Group ID
    Value:
      Fn::GetAtt:
        - AggTaskGroup
        - AggTaskGroupId
  AggTaskGroupName:
    Description:
      zh-cn: Aggregation task group name.
      en: Agg task group name.
    Label:
      zh-cn: Aggregation Task Group Name
      en: Agg Task Group Name
    Value:
      Fn::GetAtt:
        - AggTaskGroup
        - AggTaskGroupName
  Status:
    Description:
      zh-cn: Aggregation task group status.
      en: Agg task group status.
    Label:
      zh-cn: Aggregation Task Group Status
      en: Status
    Value:
      Fn::GetAtt:
        - AggTaskGroup
        - Status
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - SourcePrometheusId
          - TargetPrometheusId
          - AggTaskGroupName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create a simple aggregation task group for an existing Prometheus instance by using the default scheduling configuration and basic recording rules.",
    "en": "Create a simple aggregation task group for an existing Prometheus instance with default schedule configuration and basic recording rules."
  },
  "Parameters": {
    "SourcePrometheusId": {
      "Type": "String",
      "Label": {
        "zh-cn": "Source Prometheus Instance ID",
        "en": "Source Prometheus Instance ID"
      },
      "Description": {
        "zh-cn": "The ID of the source Prometheus instance from which the aggregation task group reads data.",
        "en": "The ID of the source Prometheus instance that the agg task group reads data from."
      }
    },
    "TargetPrometheusId": {
      "Type": "String",
      "Label": {
        "zh-cn": "Target Prometheus Instance ID",
        "en": "Target Prometheus Instance ID"
      },
      "Description": {
        "zh-cn": "The ID of the target Prometheus instance to which the aggregation results are written.",
        "en": "The ID of the target Prometheus instance that the agg task group writes data to."
      }
    },
    "AggTaskGroupName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Aggregation Task Group Name",
        "en": "Agg Task Group Name"
      },
      "Description": {
        "zh-cn": "The name of the aggregation task group.",
        "en": "The name of the aggregation task group."
      },
      "Default": "simple-agg-task-group"
    }
  },
  "Resources": {
    "AggTaskGroup": {
      "Type": "ALIYUN::CMS2::AggTaskGroup",
      "Properties": {
        "AggTaskGroupName": {
          "Ref": "AggTaskGroupName"
        },
        "InstanceId": {
          "Ref": "SourcePrometheusId"
        },
        "TargetPrometheusId": {
          "Ref": "TargetPrometheusId"
        },
        "AggTaskGroupConfig": "groups:\n  - name: basic_rules\n    rules:\n      - record: job:node_cpu_usage:avg_rate5m\n        expr: avg by (job) (rate(node_cpu_seconds_total{mode!=\"idle\"}[5m]))",
        "Description": "Simple aggregation task group"
      }
    }
  },
  "Outputs": {
    "AggTaskGroupId": {
      "Description": {
        "zh-cn": "Aggregation task group ID.",
        "en": "Agg task group ID."
      },
      "Label": {
        "zh-cn": "Aggregation Task Group ID",
        "en": "Agg Task Group ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "AggTaskGroup",
          "AggTaskGroupId"
        ]
      }
    },
    "AggTaskGroupName": {
      "Description": {
        "zh-cn": "Aggregation task group name.",
        "en": "Agg task group name."
      },
      "Label": {
        "zh-cn": "Aggregation Task Group Name",
        "en": "Agg Task Group Name"
      },
      "Value": {
        "Fn::GetAtt": [
          "AggTaskGroup",
          "AggTaskGroupName"
        ]
      }
    },
    "Status": {
      "Description": {
        "zh-cn": "Aggregation task group status.",
        "en": "Agg task group status."
      },
      "Label": {
        "zh-cn": "Aggregation Task Group Status",
        "en": "Status"
      },
      "Value": {
        "Fn::GetAtt": [
          "AggTaskGroup",
          "Status"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "SourcePrometheusId",
            "TargetPrometheusId",
            "AggTaskGroupName"
          ]
        }
      ]
    }
  }
}

Scenario 2: Create Prometheus instances and configure an aggregation task group with Cron scheduling

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create source and target Prometheus instances and configure an aggregation task group that uses Cron scheduling, a custom retry policy, and multiple recording rules.
  en: Create source and target Prometheus instances, configure aggregation task group with Cron schedule mode, custom retry policy, and multiple recording rules.
Parameters:
  PrometheusInstanceNamePrefix:
    Type: String
    Label:
      zh-cn: Prometheus Instance Name Prefix
      en: Prometheus Instance Name Prefix
    Description:
      zh-cn: The name prefix of the source and target Prometheus instances.
      en: Name prefix for source and target Prometheus instances.
    Default: monitoring
    MinLength: 1
    MaxLength: 100
  StorageDuration:
    Type: Number
    Label:
      zh-cn: Storage Duration (Days)
      en: Storage Duration (Days)
    Description:
      zh-cn: The data retention period of the Prometheus instance.
      en: Data storage duration of the Prometheus instance.
    AllowedValues:
      - 15
      - 30
      - 60
      - 90
      - 180
    Default: 90
  AggTaskGroupName:
    Type: String
    Label:
      zh-cn: Aggregation Task Group Name
      en: Agg Task Group Name
    Description:
      zh-cn: The name of the aggregation task group.
      en: The name of the aggregation task group.
    Default: cron-agg-task-group
  CronExpr:
    Type: String
    Label:
      zh-cn: Cron Expression
      en: Cron Expression
    Description:
      zh-cn: Cron scheduling expression. For example, "0/5 * * * *" runs every 5 minutes.
      en: Cron schedule expression, e.g. "0/5 * * * *" means every 5 minutes.
    Default: 0/5 * * * *
  MaxRetries:
    Type: Number
    Label:
      zh-cn: Maximum Number of Retries
      en: Max Retries
    Description:
      zh-cn: The maximum number of retries for the aggregation task.
      en: The maximum number of retries for executing the agg task.
    Default: 20
  MaxRunTimeInSeconds:
    Type: Number
    Label:
      zh-cn: Maximum Runtime (Seconds)
      en: Max Run Time (Seconds)
    Description:
      zh-cn: The maximum runtime of the aggregation task.
      en: The maximum run time for executing the agg task in seconds.
    Default: 600
Resources:
  SourcePrometheus:
    Type: ALIYUN::CMS2::PrometheusInstance
    Properties:
      PrometheusInstanceName:
        Fn::Sub: ${PrometheusInstanceNamePrefix}-source
      StorageDuration:
        Ref: StorageDuration
      ArchiveDuration: 0
      PaymentType: POSTPAY
      EnableAuthFreeRead: true
      EnableAuthFreeWrite: false
      EnableAuthToken: true
  TargetPrometheus:
    Type: ALIYUN::CMS2::PrometheusInstance
    Properties:
      PrometheusInstanceName:
        Fn::Sub: ${PrometheusInstanceNamePrefix}-target
      StorageDuration:
        Ref: StorageDuration
      ArchiveDuration: 0
      PaymentType: POSTPAY
      EnableAuthFreeRead: true
      EnableAuthFreeWrite: false
      EnableAuthToken: true
  AggTaskGroup:
    Type: ALIYUN::CMS2::AggTaskGroup
    DependsOn:
      - SourcePrometheus
      - TargetPrometheus
    Properties:
      AggTaskGroupName:
        Ref: AggTaskGroupName
      InstanceId:
        Fn::GetAtt:
          - SourcePrometheus
          - PrometheusInstanceId
      TargetPrometheusId:
        Fn::GetAtt:
          - TargetPrometheus
          - PrometheusInstanceId
      ScheduleMode: Cron
      CronExpr:
        Ref: CronExpr
      MaxRetries:
        Ref: MaxRetries
      MaxRunTimeInSeconds:
        Ref: MaxRunTimeInSeconds
      Delay: 60
      ScheduleTimeExpr: '@m'
      OverrideIfExists: true
      Description: Aggregation task group with Cron schedule and custom retry policy
      AggTaskGroupConfig: |-
        groups:
          - name: cpu_aggregation
            rules:
              - record: job:node_cpu_usage:avg_rate5m
                expr: avg by (job) (rate(node_cpu_seconds_total{mode!="idle"}[5m]))
              - record: job:node_cpu_usage:max_rate5m
                expr: max by (job) (rate(node_cpu_seconds_total{mode!="idle"}[5m]))
          - name: memory_aggregation
            rules:
              - record: job:node_memory_usage:avg
                expr: avg by (job) (node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes)
              - record: job:node_memory_usage:percent
                expr: avg by (job) ((node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes * 100)
      Tags:
        - Key: Environment
          Value: Production
        - Key: Team
          Value: SRE
Outputs:
  AggTaskGroupId:
    Description:
      zh-cn: Aggregation task group ID.
      en: Agg task group ID.
    Label:
      zh-cn: Aggregation Task Group ID
      en: Agg Task Group ID
    Value:
      Fn::GetAtt:
        - AggTaskGroup
        - AggTaskGroupId
  SourcePrometheusId:
    Description:
      zh-cn: Source Prometheus instance ID.
      en: Source Prometheus instance ID.
    Label:
      zh-cn: Source Prometheus Instance ID
      en: Source Prometheus ID
    Value:
      Fn::GetAtt:
        - SourcePrometheus
        - PrometheusInstanceId
  TargetPrometheusId:
    Description:
      zh-cn: Target Prometheus instance ID.
      en: Target Prometheus instance ID.
    Label:
      zh-cn: Target Prometheus Instance ID
      en: Target Prometheus ID
    Value:
      Fn::GetAtt:
        - TargetPrometheus
        - PrometheusInstanceId
  AggTaskGroupStatus:
    Description:
      zh-cn: Aggregation task group status.
      en: Agg task group status.
    Label:
      zh-cn: Aggregation Task Group Status
      en: Status
    Value:
      Fn::GetAtt:
        - AggTaskGroup
        - Status
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - PrometheusInstanceNamePrefix
          - StorageDuration
      - Parameters:
          - AggTaskGroupName
          - CronExpr
          - MaxRetries
          - MaxRunTimeInSeconds
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create source and target Prometheus instances and configure an aggregation task group that uses Cron scheduling, a custom retry policy, and multiple recording rules.",
    "en": "Create source and target Prometheus instances, configure aggregation task group with Cron schedule mode, custom retry policy, and multiple recording rules."
  },
  "Parameters": {
    "PrometheusInstanceNamePrefix": {
      "Type": "String",
      "Label": {
        "zh-cn": "Prometheus Instance Name Prefix",
        "en": "Prometheus Instance Name Prefix"
      },
      "Description": {
        "zh-cn": "The name prefix of the source and target Prometheus instances.",
        "en": "Name prefix for source and target Prometheus instances."
      },
      "Default": "monitoring",
      "MinLength": 1,
      "MaxLength": 100
    },
    "StorageDuration": {
      "Type": "Number",
      "Label": {
        "zh-cn": "Storage Duration (Days)",
        "en": "Storage Duration (Days)"
      },
      "Description": {
        "zh-cn": "The data retention period of the Prometheus instance.",
        "en": "Data storage duration of the Prometheus instance."
      },
      "AllowedValues": [
        15,
        30,
        60,
        90,
        180
      ],
      "Default": 90
    },
    "AggTaskGroupName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Aggregation Task Group Name",
        "en": "Agg Task Group Name"
      },
      "Description": {
        "zh-cn": "The name of the aggregation task group.",
        "en": "The name of the aggregation task group."
      },
      "Default": "cron-agg-task-group"
    },
    "CronExpr": {
      "Type": "String",
      "Label": {
        "zh-cn": "Cron Expression",
        "en": "Cron Expression"
      },
      "Description": {
        "zh-cn": "Cron scheduling expression. For example, \"0/5 * * * *\" runs every 5 minutes.",
        "en": "Cron schedule expression, e.g. \"0/5 * * * *\" means every 5 minutes."
      },
      "Default": "0/5 * * * *"
    },
    "MaxRetries": {
      "Type": "Number",
      "Label": {
        "zh-cn": "Maximum Number of Retries",
        "en": "Max Retries"
      },
      "Description": {
        "zh-cn": "The maximum number of retries for the aggregation task.",
        "en": "The maximum number of retries for executing the agg task."
      },
      "Default": 20
    },
    "MaxRunTimeInSeconds": {
      "Type": "Number",
      "Label": {
        "zh-cn": "Maximum Runtime (Seconds)",
        "en": "Max Run Time (Seconds)"
      },
      "Description": {
        "zh-cn": "The maximum runtime of the aggregation task.",
        "en": "The maximum run time for executing the agg task in seconds."
      },
      "Default": 600
    }
  },
  "Resources": {
    "SourcePrometheus": {
      "Type": "ALIYUN::CMS2::PrometheusInstance",
      "Properties": {
        "PrometheusInstanceName": {
          "Fn::Sub": "${PrometheusInstanceNamePrefix}-source"
        },
        "StorageDuration": {
          "Ref": "StorageDuration"
        },
        "ArchiveDuration": 0,
        "PaymentType": "POSTPAY",
        "EnableAuthFreeRead": true,
        "EnableAuthFreeWrite": false,
        "EnableAuthToken": true
      }
    },
    "TargetPrometheus": {
      "Type": "ALIYUN::CMS2::PrometheusInstance",
      "Properties": {
        "PrometheusInstanceName": {
          "Fn::Sub": "${PrometheusInstanceNamePrefix}-target"
        },
        "StorageDuration": {
          "Ref": "StorageDuration"
        },
        "ArchiveDuration": 0,
        "PaymentType": "POSTPAY",
        "EnableAuthFreeRead": true,
        "EnableAuthFreeWrite": false,
        "EnableAuthToken": true
      }
    },
    "AggTaskGroup": {
      "Type": "ALIYUN::CMS2::AggTaskGroup",
      "DependsOn": [
        "SourcePrometheus",
        "TargetPrometheus"
      ],
      "Properties": {
        "AggTaskGroupName": {
          "Ref": "AggTaskGroupName"
        },
        "InstanceId": {
          "Fn::GetAtt": [
            "SourcePrometheus",
            "PrometheusInstanceId"
          ]
        },
        "TargetPrometheusId": {
          "Fn::GetAtt": [
            "TargetPrometheus",
            "PrometheusInstanceId"
          ]
        },
        "ScheduleMode": "Cron",
        "CronExpr": {
          "Ref": "CronExpr"
        },
        "MaxRetries": {
          "Ref": "MaxRetries"
        },
        "MaxRunTimeInSeconds": {
          "Ref": "MaxRunTimeInSeconds"
        },
        "Delay": 60,
        "ScheduleTimeExpr": "@m",
        "OverrideIfExists": true,
        "Description": "Aggregation task group with Cron schedule and custom retry policy",
        "AggTaskGroupConfig": "groups:\n  - name: cpu_aggregation\n    rules:\n      - record: job:node_cpu_usage:avg_rate5m\n        expr: avg by (job) (rate(node_cpu_seconds_total{mode!=\"idle\"}[5m]))\n      - record: job:node_cpu_usage:max_rate5m\n        expr: max by (job) (rate(node_cpu_seconds_total{mode!=\"idle\"}[5m]))\n  - name: memory_aggregation\n    rules:\n      - record: job:node_memory_usage:avg\n        expr: avg by (job) (node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes)\n      - record: job:node_memory_usage:percent\n        expr: avg by (job) ((node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes * 100)",
        "Tags": [
          {
            "Key": "Environment",
            "Value": "Production"
          },
          {
            "Key": "Team",
            "Value": "SRE"
          }
        ]
      }
    }
  },
  "Outputs": {
    "AggTaskGroupId": {
      "Description": {
        "zh-cn": "Aggregation task group ID.",
        "en": "Agg task group ID."
      },
      "Label": {
        "zh-cn": "Aggregation Task Group ID",
        "en": "Agg Task Group ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "AggTaskGroup",
          "AggTaskGroupId"
        ]
      }
    },
    "SourcePrometheusId": {
      "Description": {
        "zh-cn": "Source Prometheus instance ID.",
        "en": "Source Prometheus instance ID."
      },
      "Label": {
        "zh-cn": "Source Prometheus Instance ID",
        "en": "Source Prometheus ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "SourcePrometheus",
          "PrometheusInstanceId"
        ]
      }
    },
    "TargetPrometheusId": {
      "Description": {
        "zh-cn": "Target Prometheus instance ID.",
        "en": "Target Prometheus instance ID."
      },
      "Label": {
        "zh-cn": "Target Prometheus Instance ID",
        "en": "Target Prometheus ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "TargetPrometheus",
          "PrometheusInstanceId"
        ]
      }
    },
    "AggTaskGroupStatus": {
      "Description": {
        "zh-cn": "Aggregation task group status.",
        "en": "Agg task group status."
      },
      "Label": {
        "zh-cn": "Aggregation Task Group Status",
        "en": "Status"
      },
      "Value": {
        "Fn::GetAtt": [
          "AggTaskGroup",
          "Status"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "PrometheusInstanceNamePrefix",
            "StorageDuration"
          ]
        },
        {
          "Parameters": [
            "AggTaskGroupName",
            "CronExpr",
            "MaxRetries",
            "MaxRunTimeInSeconds"
          ]
        }
      ]
    }
  }
}

Scenario 3: Create a complete monitoring data aggregation solution

ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create a complete monitoring data aggregation solution including an SLS log project, a CMS2 workspace, multiple Prometheus instance groups, and multiple aggregation task groups with recording rules of different granularities, enabling multidimensional monitoring data aggregation and centralized management.
  en: Create a complete monitoring data aggregation solution including SLS log project, CMS2 workspace, multiple Prometheus instance groups, and multiple aggregation task groups with different granularity recording rules for multi-dimensional monitoring data aggregation and centralized management.
Parameters:
  CommonName:
    Type: String
    Label:
      zh-cn: Resource Name Prefix
      en: Resource Name Prefix
    Description:
      zh-cn: The common prefix for all resource names.
      en: Unified name prefix for all resources.
    Default: monitor-center
    MinLength: 1
    MaxLength: 50
  StorageDuration:
    Type: Number
    Label:
      zh-cn: Storage Duration (Days)
      en: Storage Duration (Days)
    Description:
      zh-cn: The data retention period of the Prometheus instance.
      en: Data storage duration of the Prometheus instance.
    AllowedValues:
      - 15
      - 30
      - 60
      - 90
      - 180
    Default: 90
  SourcePrometheusCount:
    Type: Number
    Label:
      zh-cn: Number of Source Prometheus Instances
      en: Source Prometheus Instance Count
    Description:
      zh-cn: The number of source Prometheus instances to create.
      en: Number of source Prometheus instances to create.
    AllowedValues:
      - 1
      - 2
    Default: 2
Resources:
  SlsProject:
    Type: ALIYUN::SLS::Project
    Properties:
      Name:
        Fn::Sub: ${CommonName}-sls
      Description: SLS project for monitoring workspace
  Workspace:
    Type: ALIYUN::CMS2::Workspace
    Properties:
      WorkspaceName:
        Fn::Sub: ${CommonName}-ws
      DisplayName: Monitoring Center Workspace
      Description: Centralized monitoring workspace for metric aggregation
      SlsProject:
        Ref: SlsProject
  SourcePrometheusA:
    Type: ALIYUN::CMS2::PrometheusInstance
    Properties:
      PrometheusInstanceName:
        Fn::Sub: ${CommonName}-src-a
      StorageDuration:
        Ref: StorageDuration
      ArchiveDuration: 0
      PaymentType: POSTPAY
      EnableAuthFreeRead: true
      EnableAuthFreeWrite: false
      EnableAuthToken: true
      Workspace:
        Ref: Workspace
  SourcePrometheusB:
    Type: ALIYUN::CMS2::PrometheusInstance
    Properties:
      PrometheusInstanceName:
        Fn::Sub: ${CommonName}-src-b
      StorageDuration:
        Ref: StorageDuration
      ArchiveDuration: 0
      PaymentType: POSTPAY
      EnableAuthFreeRead: true
      EnableAuthFreeWrite: false
      EnableAuthToken: true
      Workspace:
        Ref: Workspace
  TargetPrometheus:
    Type: ALIYUN::CMS2::PrometheusInstance
    Properties:
      PrometheusInstanceName:
        Fn::Sub: ${CommonName}-target
      StorageDuration:
        Ref: StorageDuration
      ArchiveDuration: 365
      PaymentType: POSTPAY
      EnableAuthFreeRead: true
      EnableAuthFreeWrite: false
      EnableAuthToken: true
      Workspace:
        Ref: Workspace
  SystemMetricsAgg:
    Type: ALIYUN::CMS2::AggTaskGroup
    DependsOn:
      - SourcePrometheusA
      - TargetPrometheus
    Properties:
      AggTaskGroupName: system-metrics-agg
      InstanceId:
        Fn::GetAtt:
          - SourcePrometheusA
          - PrometheusInstanceId
      TargetPrometheusId:
        Fn::GetAtt:
          - TargetPrometheus
          - PrometheusInstanceId
      ScheduleMode: Cron
      CronExpr: 0/1 * * * *
      ScheduleTimeExpr: '@m'
      Delay: 30
      MaxRetries: 20
      MaxRunTimeInSeconds: 600
      OverrideIfExists: true
      Status: Running
      Description: Aggregate system-level metrics (CPU, memory, disk, network)
      AggTaskGroupConfig: |-
        groups:
          - name: cpu_rules
            interval: 1m
            rules:
              - record: job:node_cpu_usage:avg_rate5m
                expr: avg by (job) (rate(node_cpu_seconds_total{mode!="idle"}[5m]))
              - record: job:node_cpu_usage:max_rate5m
                expr: max by (job) (rate(node_cpu_seconds_total{mode!="idle"}[5m]))
              - record: instance:node_cpu_usage:rate5m
                expr: rate(node_cpu_seconds_total{mode!="idle"}[5m])
          - name: memory_rules
            interval: 1m
            rules:
              - record: job:node_memory_usage:avg
                expr: avg by (job) (node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes)
              - record: job:node_memory_usage:percent
                expr: avg by (job) ((node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes * 100)
              - record: job:node_memory_available:avg
                expr: avg by (job) (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100)
          - name: disk_rules
            interval: 1m
            rules:
              - record: job:node_disk_usage:percent
                expr: avg by (job) ((node_filesystem_size_bytes - node_filesystem_avail_bytes) / node_filesystem_size_bytes * 100)
              - record: job:node_disk_io:rate5m
                expr: avg by (job) (rate(node_disk_io_time_seconds_total[5m]))
          - name: network_rules
            interval: 1m
            rules:
              - record: job:node_network_receive:rate5m
                expr: avg by (job) (rate(node_network_receive_bytes_total[5m]))
              - record: job:node_network_transmit:rate5m
                expr: avg by (job) (rate(node_network_transmit_bytes_total[5m]))
      Tags:
        - Key: Category
          Value: SystemMetrics
        - Key: Environment
          Value: Production
        - Key: Team
          Value: SRE
  AppMetricsAgg:
    Type: ALIYUN::CMS2::AggTaskGroup
    DependsOn:
      - SourcePrometheusB
      - TargetPrometheus
    Properties:
      AggTaskGroupName: app-metrics-agg
      InstanceId:
        Fn::GetAtt:
          - SourcePrometheusB
          - PrometheusInstanceId
      TargetPrometheusId:
        Fn::GetAtt:
          - TargetPrometheus
          - PrometheusInstanceId
      ScheduleMode: FixedRate
      Delay: 60
      MaxRetries: 30
      MaxRunTimeInSeconds: 900
      OverrideIfExists: true
      Status: Running
      Description: Aggregate application-level metrics (HTTP requests, latency, errors)
      AggTaskGroupConfig: |-
        groups:
          - name: http_rules
            interval: 1m
            rules:
              - record: job:http_requests:rate5m
                expr: sum by (job) (rate(http_requests_total[5m]))
              - record: job:http_requests:error_rate5m
                expr: sum by (job) (rate(http_requests_total{status=~"5.."}[5m])) / sum by (job) (rate(http_requests_total[5m])) * 100
              - record: job:http_request_duration:p99
                expr: histogram_quantile(0.99, sum by (job, le) (rate(http_request_duration_seconds_bucket[5m])))
              - record: job:http_request_duration:p95
                expr: histogram_quantile(0.95, sum by (job, le) (rate(http_request_duration_seconds_bucket[5m])))
              - record: job:http_request_duration:avg
                expr: avg by (job) (rate(http_request_duration_seconds_sum[5m]) / rate(http_request_duration_seconds_count[5m]))
          - name: availability_rules
            interval: 1m
            rules:
              - record: job:up:avg_rate5m
                expr: avg by (job) (avg_over_time(up[5m]))
              - record: job:up:min_rate5m
                expr: min by (job) (avg_over_time(up[5m]))
      Tags:
        - Key: Category
          Value: AppMetrics
        - Key: Environment
          Value: Production
        - Key: Team
          Value: DevOps
Outputs:
  WorkspaceName:
    Description:
      zh-cn: Workspace name.
      en: Workspace name.
    Label:
      zh-cn: Workspace Name
      en: Workspace Name
    Value:
      Fn::GetAtt:
        - Workspace
        - WorkspaceName
  SystemMetricsAggId:
    Description:
      zh-cn: The ID of the system metrics aggregation task group.
      en: System metrics aggregation task group ID.
    Label:
      zh-cn: System Metrics Aggregation Task Group ID
      en: System Metrics Agg ID
    Value:
      Fn::GetAtt:
        - SystemMetricsAgg
        - AggTaskGroupId
  AppMetricsAggId:
    Description:
      zh-cn: The ID of the application metrics aggregation task group.
      en: App metrics aggregation task group ID.
    Label:
      zh-cn: Application Metrics Aggregation Task Group ID
      en: App Metrics Agg ID
    Value:
      Fn::GetAtt:
        - AppMetricsAgg
        - AggTaskGroupId
  TargetPrometheusId:
    Description:
      zh-cn: Target Prometheus instance ID.
      en: Target Prometheus instance ID.
    Label:
      zh-cn: Target Prometheus Instance ID
      en: Target Prometheus ID
    Value:
      Fn::GetAtt:
        - TargetPrometheus
        - PrometheusInstanceId
  TargetPrometheusRemoteWriteUrl:
    Description:
      zh-cn: The internal Remote Write URL of the target Prometheus instance.
      en: Target Prometheus instance Remote Write internal URL.
    Label:
      zh-cn: Target Prometheus Remote Write URL
      en: Target Prometheus Remote Write URL
    Value:
      Fn::GetAtt:
        - TargetPrometheus
        - RemoteWriteIntraUrl
  TargetPrometheusHttpApiUrl:
    Description:
      zh-cn: The internal HTTP API URL of the target Prometheus instance.
      en: Target Prometheus instance HTTP API internal URL.
    Label:
      zh-cn: Target Prometheus HTTP API URL
      en: Target Prometheus HTTP API URL
    Value:
      Fn::GetAtt:
        - TargetPrometheus
        - HttpApiIntraUrl
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - CommonName
          - StorageDuration
          - SourcePrometheusCount
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create a complete monitoring data aggregation solution including an SLS log project, a CMS2 workspace, multiple Prometheus instance groups, and multiple aggregation task groups with recording rules of different granularities, enabling multidimensional monitoring data aggregation and centralized management.",
    "en": "Create a complete monitoring data aggregation solution including SLS log project, CMS2 workspace, multiple Prometheus instance groups, and multiple aggregation task groups with different granularity recording rules for multi-dimensional monitoring data aggregation and centralized management."
  },
  "Parameters": {
    "CommonName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Resource Name Prefix",
        "en": "Resource Name Prefix"
      },
      "Description": {
        "zh-cn": "The common prefix for all resource names.",
        "en": "Unified name prefix for all resources."
      },
      "Default": "monitor-center",
      "MinLength": 1,
      "MaxLength": 50
    },
    "StorageDuration": {
      "Type": "Number",
      "Label": {
        "zh-cn": "Storage Duration (Days)",
        "en": "Storage Duration (Days)"
      },
      "Description": {
        "zh-cn": "The data retention period of the Prometheus instance.",
        "en": "Data storage duration of the Prometheus instance."
      },
      "AllowedValues": [
        15,
        30,
        60,
        90,
        180
      ],
      "Default": 90
    },
    "SourcePrometheusCount": {
      "Type": "Number",
      "Label": {
        "zh-cn": "Number of Source Prometheus Instances",
        "en": "Source Prometheus Instance Count"
      },
      "Description": {
        "zh-cn": "The number of source Prometheus instances to create.",
        "en": "Number of source Prometheus instances to create."
      },
      "AllowedValues": [
        1,
        2
      ],
      "Default": 2
    }
  },
  "Resources": {
    "SlsProject": {
      "Type": "ALIYUN::SLS::Project",
      "Properties": {
        "Name": {
          "Fn::Sub": "${CommonName}-sls"
        },
        "Description": "SLS project for monitoring workspace"
      }
    },
    "Workspace": {
      "Type": "ALIYUN::CMS2::Workspace",
      "Properties": {
        "WorkspaceName": {
          "Fn::Sub": "${CommonName}-ws"
        },
        "DisplayName": "Monitoring Center Workspace",
        "Description": "Centralized monitoring workspace for metric aggregation",
        "SlsProject": {
          "Ref": "SlsProject"
        }
      }
    },
    "SourcePrometheusA": {
      "Type": "ALIYUN::CMS2::PrometheusInstance",
      "Properties": {
        "PrometheusInstanceName": {
          "Fn::Sub": "${CommonName}-src-a"
        },
        "StorageDuration": {
          "Ref": "StorageDuration"
        },
        "ArchiveDuration": 0,
        "PaymentType": "POSTPAY",
        "EnableAuthFreeRead": true,
        "EnableAuthFreeWrite": false,
        "EnableAuthToken": true,
        "Workspace": {
          "Ref": "Workspace"
        }
      }
    },
    "SourcePrometheusB": {
      "Type": "ALIYUN::CMS2::PrometheusInstance",
      "Properties": {
        "PrometheusInstanceName": {
          "Fn::Sub": "${CommonName}-src-b"
        },
        "StorageDuration": {
          "Ref": "StorageDuration"
        },
        "ArchiveDuration": 0,
        "PaymentType": "POSTPAY",
        "EnableAuthFreeRead": true,
        "EnableAuthFreeWrite": false,
        "EnableAuthToken": true,
        "Workspace": {
          "Ref": "Workspace"
        }
      }
    },
    "TargetPrometheus": {
      "Type": "ALIYUN::CMS2::PrometheusInstance",
      "Properties": {
        "PrometheusInstanceName": {
          "Fn::Sub": "${CommonName}-target"
        },
        "StorageDuration": {
          "Ref": "StorageDuration"
        },
        "ArchiveDuration": 365,
        "PaymentType": "POSTPAY",
        "EnableAuthFreeRead": true,
        "EnableAuthFreeWrite": false,
        "EnableAuthToken": true,
        "Workspace": {
          "Ref": "Workspace"
        }
      }
    },
    "SystemMetricsAgg": {
      "Type": "ALIYUN::CMS2::AggTaskGroup",
      "DependsOn": [
        "SourcePrometheusA",
        "TargetPrometheus"
      ],
      "Properties": {
        "AggTaskGroupName": "system-metrics-agg",
        "InstanceId": {
          "Fn::GetAtt": [
            "SourcePrometheusA",
            "PrometheusInstanceId"
          ]
        },
        "TargetPrometheusId": {
          "Fn::GetAtt": [
            "TargetPrometheus",
            "PrometheusInstanceId"
          ]
        },
        "ScheduleMode": "Cron",
        "CronExpr": "0/1 * * * *",
        "ScheduleTimeExpr": "@m",
        "Delay": 30,
        "MaxRetries": 20,
        "MaxRunTimeInSeconds": 600,
        "OverrideIfExists": true,
        "Status": "Running",
        "Description": "Aggregate system-level metrics (CPU, memory, disk, network)",
        "AggTaskGroupConfig": "groups:\n  - name: cpu_rules\n    interval: 1m\n    rules:\n      - record: job:node_cpu_usage:avg_rate5m\n        expr: avg by (job) (rate(node_cpu_seconds_total{mode!=\"idle\"}[5m]))\n      - record: job:node_cpu_usage:max_rate5m\n        expr: max by (job) (rate(node_cpu_seconds_total{mode!=\"idle\"}[5m]))\n      - record: instance:node_cpu_usage:rate5m\n        expr: rate(node_cpu_seconds_total{mode!=\"idle\"}[5m])\n  - name: memory_rules\n    interval: 1m\n    rules:\n      - record: job:node_memory_usage:avg\n        expr: avg by (job) (node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes)\n      - record: job:node_memory_usage:percent\n        expr: avg by (job) ((node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes * 100)\n      - record: job:node_memory_available:avg\n        expr: avg by (job) (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100)\n  - name: disk_rules\n    interval: 1m\n    rules:\n      - record: job:node_disk_usage:percent\n        expr: avg by (job) ((node_filesystem_size_bytes - node_filesystem_avail_bytes) / node_filesystem_size_bytes * 100)\n      - record: job:node_disk_io:rate5m\n        expr: avg by (job) (rate(node_disk_io_time_seconds_total[5m]))\n  - name: network_rules\n    interval: 1m\n    rules:\n      - record: job:node_network_receive:rate5m\n        expr: avg by (job) (rate(node_network_receive_bytes_total[5m]))\n      - record: job:node_network_transmit:rate5m\n        expr: avg by (job) (rate(node_network_transmit_bytes_total[5m]))",
        "Tags": [
          {
            "Key": "Category",
            "Value": "SystemMetrics"
          },
          {
            "Key": "Environment",
            "Value": "Production"
          },
          {
            "Key": "Team",
            "Value": "SRE"
          }
        ]
      }
    },
    "AppMetricsAgg": {
      "Type": "ALIYUN::CMS2::AggTaskGroup",
      "DependsOn": [
        "SourcePrometheusB",
        "TargetPrometheus"
      ],
      "Properties": {
        "AggTaskGroupName": "app-metrics-agg",
        "InstanceId": {
          "Fn::GetAtt": [
            "SourcePrometheusB",
            "PrometheusInstanceId"
          ]
        },
        "TargetPrometheusId": {
          "Fn::GetAtt": [
            "TargetPrometheus",
            "PrometheusInstanceId"
          ]
        },
        "ScheduleMode": "FixedRate",
        "Delay": 60,
        "MaxRetries": 30,
        "MaxRunTimeInSeconds": 900,
        "OverrideIfExists": true,
        "Status": "Running",
        "Description": "Aggregate application-level metrics (HTTP requests, latency, errors)",
        "AggTaskGroupConfig": "groups:\n  - name: http_rules\n    interval: 1m\n    rules:\n      - record: job:http_requests:rate5m\n        expr: sum by (job) (rate(http_requests_total[5m]))\n      - record: job:http_requests:error_rate5m\n        expr: sum by (job) (rate(http_requests_total{status=~\"5..\"}[5m])) / sum by (job) (rate(http_requests_total[5m])) * 100\n      - record: job:http_request_duration:p99\n        expr: histogram_quantile(0.99, sum by (job, le) (rate(http_request_duration_seconds_bucket[5m])))\n      - record: job:http_request_duration:p95\n        expr: histogram_quantile(0.95, sum by (job, le) (rate(http_request_duration_seconds_bucket[5m])))\n      - record: job:http_request_duration:avg\n        expr: avg by (job) (rate(http_request_duration_seconds_sum[5m]) / rate(http_request_duration_seconds_count[5m]))\n  - name: availability_rules\n    interval: 1m\n    rules:\n      - record: job:up:avg_rate5m\n        expr: avg by (job) (avg_over_time(up[5m]))\n      - record: job:up:min_rate5m\n        expr: min by (job) (avg_over_time(up[5m]))",
        "Tags": [
          {
            "Key": "Category",
            "Value": "AppMetrics"
          },
          {
            "Key": "Environment",
            "Value": "Production"
          },
          {
            "Key": "Team",
            "Value": "DevOps"
          }
        ]
      }
    }
  },
  "Outputs": {
    "WorkspaceName": {
      "Description": {
        "zh-cn": "Workspace name.",
        "en": "Workspace name."
      },
      "Label": {
        "zh-cn": "Workspace Name",
        "en": "Workspace Name"
      },
      "Value": {
        "Fn::GetAtt": [
          "Workspace",
          "WorkspaceName"
        ]
      }
    },
    "SystemMetricsAggId": {
      "Description": {
        "zh-cn": "The ID of the system metrics aggregation task group.",
        "en": "System metrics aggregation task group ID."
      },
      "Label": {
        "zh-cn": "System Metrics Aggregation Task Group ID",
        "en": "System Metrics Agg ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "SystemMetricsAgg",
          "AggTaskGroupId"
        ]
      }
    },
    "AppMetricsAggId": {
      "Description": {
        "zh-cn": "The ID of the application metrics aggregation task group.",
        "en": "App metrics aggregation task group ID."
      },
      "Label": {
        "zh-cn": "Application Metrics Aggregation Task Group ID",
        "en": "App Metrics Agg ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "AppMetricsAgg",
          "AggTaskGroupId"
        ]
      }
    },
    "TargetPrometheusId": {
      "Description": {
        "zh-cn": "Target Prometheus instance ID.",
        "en": "Target Prometheus instance ID."
      },
      "Label": {
        "zh-cn": "Target Prometheus Instance ID",
        "en": "Target Prometheus ID"
      },
      "Value": {
        "Fn::GetAtt": [
          "TargetPrometheus",
          "PrometheusInstanceId"
        ]
      }
    },
    "TargetPrometheusRemoteWriteUrl": {
      "Description": {
        "zh-cn": "The internal Remote Write URL of the target Prometheus instance.",
        "en": "Target Prometheus instance Remote Write internal URL."
      },
      "Label": {
        "zh-cn": "Target Prometheus Remote Write URL",
        "en": "Target Prometheus Remote Write URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "TargetPrometheus",
          "RemoteWriteIntraUrl"
        ]
      }
    },
    "TargetPrometheusHttpApiUrl": {
      "Description": {
        "zh-cn": "The internal HTTP API URL of the target Prometheus instance.",
        "en": "Target Prometheus instance HTTP API internal URL."
      },
      "Label": {
        "zh-cn": "Target Prometheus HTTP API URL",
        "en": "Target Prometheus HTTP API URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "TargetPrometheus",
          "HttpApiIntraUrl"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "CommonName",
            "StorageDuration",
            "SourcePrometheusCount"
          ]
        }
      ]
    }
  }
}