ALIYUN::ARMS::TraceResource类型用于创建追踪资源。
语法
{
"Type": "ALIYUN::ARMS::TraceResource",
"Properties": {
"AppType": String,
"CreateAllResource": Boolean,
"Workspace": String
}
}属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
AppType | String | 否 | 否 | 该追踪资源的应用类型。 | 取值范围:
|
CreateAllResource | Boolean | 否 | 否 | 是否创建所有追踪资源。 | 无 |
Workspace | String | 否 | 否 | 该追踪资源所属的工作空间。 | 无 |
返回值
Fn::GetAtt
SlsEndpointDesc:该追踪资源对应的 SLS Endpoint 的说明。
TraceEndpointDesc:该追踪资源对应的 Endpoint 的描述信息。
示例
场景 1 :创建ARMS链路追踪资源,获取数据上报端点。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建ARMS链路追踪资源,获取数据上报端点供应用SDK接入。
en: Create an ARMS trace resource and obtain the reporting endpoints for SDK access.
Parameters:
AppType:
Type: String
Label:
zh-cn: 应用类型
en: Application Type
Description:
zh-cn: >-
链路追踪资源的应用类型。
default:通用类型;trace:分布式链路追踪;cms:云监控集成。
en: >-
The application type of the trace resource.
default: general; trace: distributed tracing; cms: CloudMonitor integration.
Default: default
AllowedValues:
- default
- trace
- cms
Resources:
TraceResource:
Type: ALIYUN::ARMS::TraceResource
Properties:
AppType:
Ref: AppType
CreateAllResource: true
Outputs:
TraceEndpoint:
Label:
zh-cn: 链路追踪上报端点
en: Trace Reporting Endpoint
Description:
zh-cn: 应用SDK上报链路追踪数据的端点地址。
en: The endpoint for SDKs to report trace data.
Value:
Fn::GetAtt:
- TraceResource
- TraceEndpointDesc
SlsEndpoint:
Label:
zh-cn: 日志服务端点
en: SLS Endpoint
Description:
zh-cn: 链路追踪数据对应的日志服务端点地址。
en: The SLS endpoint for trace data.
Value:
Fn::GetAtt:
- TraceResource
- SlsEndpointDesc{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "创建ARMS链路追踪资源,获取数据上报端点供应用SDK接入。",
"en": "Create an ARMS trace resource and obtain the reporting endpoints for SDK access."
},
"Parameters": {
"AppType": {
"Type": "String",
"Label": {
"zh-cn": "应用类型",
"en": "Application Type"
},
"Description": {
"zh-cn": "链路追踪资源的应用类型。default:通用类型;trace:分布式链路追踪;cms:云监控集成。",
"en": "The application type of the trace resource. default: general; trace: distributed tracing; cms: CloudMonitor integration."
},
"Default": "default",
"AllowedValues": [
"default",
"trace",
"cms"
]
}
},
"Resources": {
"TraceResource": {
"Type": "ALIYUN::ARMS::TraceResource",
"Properties": {
"AppType": {
"Ref": "AppType"
},
"CreateAllResource": true
}
}
},
"Outputs": {
"TraceEndpoint": {
"Label": {
"zh-cn": "链路追踪上报端点",
"en": "Trace Reporting Endpoint"
},
"Description": {
"zh-cn": "应用SDK上报链路追踪数据的端点地址。",
"en": "The endpoint for SDKs to report trace data."
},
"Value": {
"Fn::GetAtt": [
"TraceResource",
"TraceEndpointDesc"
]
}
},
"SlsEndpoint": {
"Label": {
"zh-cn": "日志服务端点",
"en": "SLS Endpoint"
},
"Description": {
"zh-cn": "链路追踪数据对应的日志服务端点地址。",
"en": "The SLS endpoint for trace data."
},
"Value": {
"Fn::GetAtt": [
"TraceResource",
"SlsEndpointDesc"
]
}
}
}
}场景 2 :创建链路追踪资源并接入应用监控任务,实现分布式应用全链路追踪。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建链路追踪资源并接入应用监控任务,用于分布式应用的全链路追踪。
en: Create a trace resource and an application monitoring task for distributed tracing.
Parameters:
Workspace:
Type: String
Label:
zh-cn: 工作空间
en: Workspace
Description:
zh-cn: 链路追踪资源所属的工作空间,留空则使用默认工作空间。
en: The workspace of the trace resource. Leave empty to use the default workspace.
Default: ''
XTraceAppName:
Type: String
Label:
zh-cn: 应用监控名称
en: Application Monitoring Name
Description:
zh-cn: 应用监控任务名称,1~64个字符,可包含字母、数字、短横线和下划线。
en: The application monitoring task name, 1-64 characters.
Default: arms-trace-demo
Resources:
TraceResource:
Type: ALIYUN::ARMS::TraceResource
Properties:
AppType: trace
Workspace:
Ref: Workspace
CreateAllResource: true
TraceApp:
Type: ALIYUN::ARMS::XTraceApp
Properties:
XTraceAppName:
Ref: XTraceAppName
Outputs:
TraceEndpoint:
Label:
zh-cn: 链路追踪上报端点
en: Trace Reporting Endpoint
Description:
zh-cn: 应用SDK上报链路追踪数据的端点地址。
en: The endpoint for SDKs to report trace data.
Value:
Fn::GetAtt:
- TraceResource
- TraceEndpointDesc
SlsEndpoint:
Label:
zh-cn: 日志服务端点
en: SLS Endpoint
Description:
zh-cn: 链路追踪数据对应的日志服务端点地址。
en: The SLS endpoint for trace data.
Value:
Fn::GetAtt:
- TraceResource
- SlsEndpointDesc
AppPid:
Label:
zh-cn: 应用PID
en: Application PID
Description:
zh-cn: 应用监控任务的唯一标识PID,用于SDK接入。
en: The unique PID of the application monitoring task for SDK access.
Value:
Fn::GetAtt:
- TraceApp
- Pid
AppResourceGroupId:
Label:
zh-cn: 应用资源组ID
en: Application Resource Group ID
Description:
zh-cn: 应用监控任务所属的资源组ID。
en: The resource group ID of the application monitoring task.
Value:
Fn::GetAtt:
- TraceApp
- ResourceGroupId{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "创建链路追踪资源并接入应用监控任务,用于分布式应用的全链路追踪。",
"en": "Create a trace resource and an application monitoring task for distributed tracing."
},
"Parameters": {
"Workspace": {
"Type": "String",
"Label": {
"zh-cn": "工作空间",
"en": "Workspace"
},
"Description": {
"zh-cn": "链路追踪资源所属的工作空间,留空则使用默认工作空间。",
"en": "The workspace of the trace resource. Leave empty to use the default workspace."
},
"Default": ""
},
"XTraceAppName": {
"Type": "String",
"Label": {
"zh-cn": "应用监控名称",
"en": "Application Monitoring Name"
},
"Description": {
"zh-cn": "应用监控任务名称,1~64个字符,可包含字母、数字、短横线和下划线。",
"en": "The application monitoring task name, 1-64 characters."
},
"Default": "arms-trace-demo"
}
},
"Resources": {
"TraceResource": {
"Type": "ALIYUN::ARMS::TraceResource",
"Properties": {
"AppType": "trace",
"Workspace": {
"Ref": "Workspace"
},
"CreateAllResource": true
}
},
"TraceApp": {
"Type": "ALIYUN::ARMS::XTraceApp",
"Properties": {
"XTraceAppName": {
"Ref": "XTraceAppName"
}
}
}
},
"Outputs": {
"TraceEndpoint": {
"Label": {
"zh-cn": "链路追踪上报端点",
"en": "Trace Reporting Endpoint"
},
"Description": {
"zh-cn": "应用SDK上报链路追踪数据的端点地址。",
"en": "The endpoint for SDKs to report trace data."
},
"Value": {
"Fn::GetAtt": [
"TraceResource",
"TraceEndpointDesc"
]
}
},
"SlsEndpoint": {
"Label": {
"zh-cn": "日志服务端点",
"en": "SLS Endpoint"
},
"Description": {
"zh-cn": "链路追踪数据对应的日志服务端点地址。",
"en": "The SLS endpoint for trace data."
},
"Value": {
"Fn::GetAtt": [
"TraceResource",
"SlsEndpointDesc"
]
}
},
"AppPid": {
"Label": {
"zh-cn": "应用PID",
"en": "Application PID"
},
"Description": {
"zh-cn": "应用监控任务的唯一标识PID,用于SDK接入。",
"en": "The unique PID of the application monitoring task for SDK access."
},
"Value": {
"Fn::GetAtt": [
"TraceApp",
"Pid"
]
}
},
"AppResourceGroupId": {
"Label": {
"zh-cn": "应用资源组ID",
"en": "Application Resource Group ID"
},
"Description": {
"zh-cn": "应用监控任务所属的资源组ID。",
"en": "The resource group ID of the application monitoring task."
},
"Value": {
"Fn::GetAtt": [
"TraceApp",
"ResourceGroupId"
]
}
}
}
}场景 3 :创建链路追踪资源与ECS应用,自动安装ARMS Java探针实现端到端分布式追踪。
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建链路追踪资源与ECS应用,自动安装ARMS Java探针实现端到端分布式追踪。
en: Create a trace resource and an ECS app, install the ARMS Java agent for end-to-end tracing.
Parameters:
ZoneId:
Type: String
Label:
zh-cn: 可用区
en: Availability Zone
Description:
zh-cn: ECS实例所属的可用区。
en: The availability zone for the ECS instance.
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
InstanceType:
Type: String
Label:
zh-cn: 实例规格
en: Instance Type
Description:
zh-cn: ECS实例规格。
en: The ECS instance type.
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
InstanceChargeType: PostPaid
ZoneId: ${ZoneId}
ImageId:
Type: String
Label:
zh-cn: 镜像ID
en: Image ID
Description:
zh-cn: ECS实例使用的镜像。
en: The image used by the ECS instance.
AssociationProperty: ALIYUN::ECS::ImageId::ImageID
AssociationPropertyMetadata:
InstanceType: ${InstanceType}
SystemDiskCategory:
Type: String
Label:
zh-cn: 系统盘类型
en: System Disk Category
Description:
zh-cn: ECS系统盘的磁盘类型。
en: The system disk category of the ECS instance.
AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
AssociationPropertyMetadata:
InstanceType: ${InstanceType}
ZoneId: ${ZoneId}
Default: cloud_essd
InstancePassword:
Type: String
Label:
zh-cn: 实例密码
en: Instance Password
Description:
zh-cn: 8~30个字符,包含大小写字母、数字和特殊字符中的三种。
en: 8-30 characters, at least three of uppercase, lowercase, digits, special chars.
NoEcho: true
AssociationProperty: ALIYUN::ECS::Instance::Password
AppName:
Type: String
Label:
zh-cn: ARMS应用名称
en: ARMS Application Name
Description:
zh-cn: 在ARMS控制台显示的应用名称。
en: The application name shown in the ARMS console.
Default: arms-ecs-demo
LicenseKey:
Type: String
Label:
zh-cn: ARMS LicenseKey
en: ARMS LicenseKey
Description:
zh-cn: >-
ARMS应用监控的LicenseKey,用于Java探针接入。
请在ARMS控制台「应用监控 > 探针管理」获取。
en: >-
The ARMS LicenseKey for the Java agent.
Obtain it from the ARMS console under Application Monitoring > Agent Management.
NoEcho: true
Resources:
AutoEnableARMS:
Type: ALIYUN::ROS::AutoEnableService
Properties:
ServiceName: ARMS
TraceResource:
Type: ALIYUN::ARMS::TraceResource
Properties:
AppType: trace
CreateAllResource: true
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock: 192.168.0.0/16
VpcName: arms-trace-vpc
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
CidrBlock: 192.168.0.0/24
VpcId:
Ref: Vpc
VSwitchName: arms-trace-vsw
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: Vpc
SecurityGroupName: arms-trace-sg
SecurityGroupIngress:
- PortRange: 8080/8080
SourceCidrIp: 0.0.0.0/0
IpProtocol: tcp
EcsInstance:
Type: ALIYUN::ECS::InstanceGroup
Properties:
ZoneId:
Ref: ZoneId
InstanceType:
Ref: InstanceType
ImageId:
Ref: ImageId
SystemDiskCategory:
Ref: SystemDiskCategory
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
SecurityGroupId:
Ref: SecurityGroup
Password:
Ref: InstancePassword
InstanceName: arms-trace-ecs
MaxAmount: 1
InternetMaxBandwidthOut: 5
InstallArmsAgent:
Type: ALIYUN::ECS::RunCommand
Properties:
InstanceIds:
Fn::GetAtt:
- EcsInstance
- InstanceIds
Type: RunShellScript
Sync: true
Timeout: 600
CommandContent:
Fn::Sub:
- |
#!/bin/bash
set -e
# 下载并解压ARMS Java探针(公网下载地址,按地域选择)
wget -q "http://arms-apm-${Region}.oss-${Region}.aliyuncs.com/AliyunJavaAgent.zip" -O /tmp/AliyunJavaAgent.zip
unzip -o /tmp/AliyunJavaAgent.zip -d /opt/arms/ >/dev/null 2>&1
# 写入ARMS接入参数到环境变量
cat << EOF >> /etc/profile.d/arms.sh
export ARMS_APP_NAME=${AppName}
export ARMS_LICENSE_KEY=${LicenseKey}
export ARMS_TRACE_ENDPOINT=${TraceEp}
EOF
source /etc/profile.d/arms.sh
echo "ARMS agent installed at /opt/arms/aliyun-java-agent.jar"
echo "Configure -javaagent:/opt/arms/aliyun-java-agent.jar in your Java app startup."
echo "Trace endpoint: ${TraceEp}"
- Region:
Ref: ALIYUN::Region
AppName:
Ref: AppName
LicenseKey:
Ref: LicenseKey
TraceEp:
Fn::GetAtt:
- TraceResource
- TraceEndpointDesc
DependsOn: EcsInstance
Outputs:
TraceEndpoint:
Label:
zh-cn: 链路追踪上报端点
en: Trace Reporting Endpoint
Description:
zh-cn: 应用SDK上报链路追踪数据的端点地址。
en: The endpoint for SDKs to report trace data.
Value:
Fn::GetAtt:
- TraceResource
- TraceEndpointDesc
SlsEndpoint:
Label:
zh-cn: 日志服务端点
en: SLS Endpoint
Description:
zh-cn: 链路追踪数据对应的日志服务端点地址。
en: The SLS endpoint for trace data.
Value:
Fn::GetAtt:
- TraceResource
- SlsEndpointDesc
EcsPublicIp:
Label:
zh-cn: ECS公网IP
en: ECS Public IP
Description:
zh-cn: ECS实例的公网IP地址。
en: The public IP of the ECS instance.
Value:
Fn::Select:
- 0
- Fn::GetAtt:
- EcsInstance
- PublicIps
Console.ArmsApp:
Description:
zh-cn: ARMS应用监控控制台地址。
en: The ARMS application monitoring console URL.
Label:
zh-cn: ARMS控制台
en: ARMS Console
Value:
Fn::Sub: https://arms.console.aliyun.com/next#/apmApp/${ALIYUN::Region}/appList{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"zh-cn": "创建链路追踪资源与ECS应用,自动安装ARMS Java探针实现端到端分布式追踪。",
"en": "Create a trace resource and an ECS app, install the ARMS Java agent for end-to-end tracing."
},
"Parameters": {
"ZoneId": {
"Type": "String",
"Label": {
"zh-cn": "可用区",
"en": "Availability Zone"
},
"Description": {
"zh-cn": "ECS实例所属的可用区。",
"en": "The availability zone for the ECS instance."
},
"AssociationProperty": "ALIYUN::ECS::Instance::ZoneId"
},
"InstanceType": {
"Type": "String",
"Label": {
"zh-cn": "实例规格",
"en": "Instance Type"
},
"Description": {
"zh-cn": "ECS实例规格。",
"en": "The ECS instance type."
},
"AssociationProperty": "ALIYUN::ECS::Instance::InstanceType",
"AssociationPropertyMetadata": {
"InstanceChargeType": "PostPaid",
"ZoneId": "${ZoneId}"
}
},
"ImageId": {
"Type": "String",
"Label": {
"zh-cn": "镜像ID",
"en": "Image ID"
},
"Description": {
"zh-cn": "ECS实例使用的镜像。",
"en": "The image used by the ECS instance."
},
"AssociationProperty": "ALIYUN::ECS::ImageId::ImageID",
"AssociationPropertyMetadata": {
"InstanceType": "${InstanceType}"
}
},
"SystemDiskCategory": {
"Type": "String",
"Label": {
"zh-cn": "系统盘类型",
"en": "System Disk Category"
},
"Description": {
"zh-cn": "ECS系统盘的磁盘类型。",
"en": "The system disk category of the ECS instance."
},
"AssociationProperty": "ALIYUN::ECS::Disk::SystemDiskCategory",
"AssociationPropertyMetadata": {
"InstanceType": "${InstanceType}",
"ZoneId": "${ZoneId}"
},
"Default": "cloud_essd"
},
"InstancePassword": {
"Type": "String",
"Label": {
"zh-cn": "实例密码",
"en": "Instance Password"
},
"Description": {
"zh-cn": "8~30个字符,包含大小写字母、数字和特殊字符中的三种。",
"en": "8-30 characters, at least three of uppercase, lowercase, digits, special chars."
},
"NoEcho": true,
"AssociationProperty": "ALIYUN::ECS::Instance::Password"
},
"AppName": {
"Type": "String",
"Label": {
"zh-cn": "ARMS应用名称",
"en": "ARMS Application Name"
},
"Description": {
"zh-cn": "在ARMS控制台显示的应用名称。",
"en": "The application name shown in the ARMS console."
},
"Default": "arms-ecs-demo"
},
"LicenseKey": {
"Type": "String",
"Label": {
"zh-cn": "ARMS LicenseKey",
"en": "ARMS LicenseKey"
},
"Description": {
"zh-cn": "ARMS应用监控的LicenseKey,用于Java探针接入。请在ARMS控制台「应用监控 > 探针管理」获取。",
"en": "The ARMS LicenseKey for the Java agent. Obtain it from the ARMS console under Application Monitoring > Agent Management."
},
"NoEcho": true
}
},
"Resources": {
"AutoEnableARMS": {
"Type": "ALIYUN::ROS::AutoEnableService",
"Properties": {
"ServiceName": "ARMS"
}
},
"TraceResource": {
"Type": "ALIYUN::ARMS::TraceResource",
"Properties": {
"AppType": "trace",
"CreateAllResource": true
}
},
"Vpc": {
"Type": "ALIYUN::ECS::VPC",
"Properties": {
"CidrBlock": "192.168.0.0/16",
"VpcName": "arms-trace-vpc"
}
},
"VSwitch": {
"Type": "ALIYUN::ECS::VSwitch",
"Properties": {
"ZoneId": {
"Ref": "ZoneId"
},
"CidrBlock": "192.168.0.0/24",
"VpcId": {
"Ref": "Vpc"
},
"VSwitchName": "arms-trace-vsw"
}
},
"SecurityGroup": {
"Type": "ALIYUN::ECS::SecurityGroup",
"Properties": {
"VpcId": {
"Ref": "Vpc"
},
"SecurityGroupName": "arms-trace-sg",
"SecurityGroupIngress": [
{
"PortRange": "8080/8080",
"SourceCidrIp": "0.0.0.0/0",
"IpProtocol": "tcp"
}
]
}
},
"EcsInstance": {
"Type": "ALIYUN::ECS::InstanceGroup",
"Properties": {
"ZoneId": {
"Ref": "ZoneId"
},
"InstanceType": {
"Ref": "InstanceType"
},
"ImageId": {
"Ref": "ImageId"
},
"SystemDiskCategory": {
"Ref": "SystemDiskCategory"
},
"VpcId": {
"Ref": "Vpc"
},
"VSwitchId": {
"Ref": "VSwitch"
},
"SecurityGroupId": {
"Ref": "SecurityGroup"
},
"Password": {
"Ref": "InstancePassword"
},
"InstanceName": "arms-trace-ecs",
"MaxAmount": 1,
"InternetMaxBandwidthOut": 5
}
},
"InstallArmsAgent": {
"Type": "ALIYUN::ECS::RunCommand",
"Properties": {
"InstanceIds": {
"Fn::GetAtt": [
"EcsInstance",
"InstanceIds"
]
},
"Type": "RunShellScript",
"Sync": true,
"Timeout": 600,
"CommandContent": {
"Fn::Sub": [
"#!/bin/bash\nset -e\n# 下载并解压ARMS Java探针(公网下载地址,按地域选择)\nwget -q \"http://arms-apm-${Region}.oss-${Region}.aliyuncs.com/AliyunJavaAgent.zip\" -O /tmp/AliyunJavaAgent.zip\nunzip -o /tmp/AliyunJavaAgent.zip -d /opt/arms/ >/dev/null 2>&1\n# 写入ARMS接入参数到环境变量\ncat << EOF >> /etc/profile.d/arms.sh\nexport ARMS_APP_NAME=${AppName}\nexport ARMS_LICENSE_KEY=${LicenseKey}\nexport ARMS_TRACE_ENDPOINT=${TraceEp}\nEOF\nsource /etc/profile.d/arms.sh\necho \"ARMS agent installed at /opt/arms/aliyun-java-agent.jar\"\necho \"Configure -javaagent:/opt/arms/aliyun-java-agent.jar in your Java app startup.\"\necho \"Trace endpoint: ${TraceEp}\"",
{
"Region": {
"Ref": "ALIYUN::Region"
},
"AppName": {
"Ref": "AppName"
},
"LicenseKey": {
"Ref": "LicenseKey"
},
"TraceEp": {
"Fn::GetAtt": [
"TraceResource",
"TraceEndpointDesc"
]
}
}
]
}
},
"DependsOn": "EcsInstance"
}
},
"Outputs": {
"TraceEndpoint": {
"Label": {
"zh-cn": "链路追踪上报端点",
"en": "Trace Reporting Endpoint"
},
"Description": {
"zh-cn": "应用SDK上报链路追踪数据的端点地址。",
"en": "The endpoint for SDKs to report trace data."
},
"Value": {
"Fn::GetAtt": [
"TraceResource",
"TraceEndpointDesc"
]
}
},
"SlsEndpoint": {
"Label": {
"zh-cn": "日志服务端点",
"en": "SLS Endpoint"
},
"Description": {
"zh-cn": "链路追踪数据对应的日志服务端点地址。",
"en": "The SLS endpoint for trace data."
},
"Value": {
"Fn::GetAtt": [
"TraceResource",
"SlsEndpointDesc"
]
}
},
"EcsPublicIp": {
"Label": {
"zh-cn": "ECS公网IP",
"en": "ECS Public IP"
},
"Description": {
"zh-cn": "ECS实例的公网IP地址。",
"en": "The public IP of the ECS instance."
},
"Value": {
"Fn::Select": [
0,
{
"Fn::GetAtt": [
"EcsInstance",
"PublicIps"
]
}
]
}
},
"Console.ArmsApp": {
"Description": {
"zh-cn": "ARMS应用监控控制台地址。",
"en": "The ARMS application monitoring console URL."
},
"Label": {
"zh-cn": "ARMS控制台",
"en": "ARMS Console"
},
"Value": {
"Fn::Sub": "https://arms.console.aliyun.com/next#/apmApp/${ALIYUN::Region}/appList"
}
}
}
}该文章对您有帮助吗?