本文介绍事件目标中的元数据参数。

字段解释

如下表所示,事件目标的元数据包含以下字段。

字段 类型 说明
resourceKey String 事件转换的资源参数。
resourceName String 事件转换的资源参数名称。
forms String 事件转换的格式。有四种类型:
  • ORIGINAL:完整事件。无需定义valuetemplate事件总线EventBridge不对事件进行转换,将原生CloudEvents的完整结构路由到事件目标。更多信息,请参见完整事件
  • JSONPATH:部分事件。无需定义template,只需定义value事件总线EventBridge通过JSONPath从CloudEvents中提取事件中的参数,将指定的事件内容路由到事件目标。更多信息,请参见部分事件
    value示例值如下所示。
    $.data.name
  • CONSTANT:常量。无需定义template,只需定义value。无论事件内容是什么,事件总线EventBridge只把value定义的常量路由到事件目标。更多信息,请参见常量
    value示例值如下所示。
    "test1"
  • TEMPLATE:模板。需定义valuetemplate事件总线EventBridge通过JSONPath从CloudEvents提取事件中的参数,把参数值存放在value中,然后按照template定义的格式路由到事件目标。更多信息,请参见模板
    value示例值如下所示。
    {
        "name":"$.data.name",
        "constant":"Please deal with it timely."
    }
    template示例值如下所示。
    The instance is broken,which name is ${name} , ${constant}

钉钉

当事件目标选择钉钉时,元数据参数如下表所示。

resourceKey resourceName forms
URL 地址 CONSTANT
SecretKey 密钥 CONSTANT
Body 推送内容 TEMPLATE

JSONPath示例如下:

{
    "id":"KD20k9rpqDRXPq0SXXlqeTn6kZ",
    "type":"acs.dingtalk",
    "endpoint":"https://oapi.dingtalk.com/robot/send?access_token=1560abe367f48877c69bb6a9916244979927abbbbf82f4fe8801692cd6ea****",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"https://oapi.dingtalk.com/robot/send?access_token=1560abe367f48877c69bb6a9916244979927abbbbf82f4fe8801692cd6ea****",
            "resourceKey":"URL",
            "form":"CONSTANT"
        },
        {
            "value":"SEC1eca5209e0c6c23165b9504967522d47b0d0004e1caf3a75f6ddfda7359d****",
            "resourceKey":"SecretKey",
            "form":"CONSTANT"
        },
        {
            "value":{
                "content":"$.data.content"
            },
            "resourceKey":"Body",
            "form":"TEMPLATE",
            "template":{
                "msgtype":"text",
                "text":{
                    "content":"@1851111***** ${content}"
                },
                "at":{

                }
            }
        }
    ]
}

邮箱

当事件目标选择邮箱时,元数据参数如下表所示。

resourceKey resourceName forms
Subject 主题 CONSTANT
AccountName 发信地址 CONSTANT
AddressType 地址类型 CONSTANT
ReplyToAddress 回信地址 CONSTANT
ToAddress 收件人
  • CONSTANT
  • JSONPATH
IsHtmlBody 是否HTML正文 CONSTANT
Body 正文 TEMPLATE

JSONPath示例如下:

{
    "id":"KD20k9rpqDRXPq0SXXlqeTn6kZ",
    "type":"acs.mail",
    "endpoint":"acs:mail:cn-hangzhou:164901546557****",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"test",
            "resourceKey":"Subject",
            "form":"CONSTANT"
        },
        {
            "value":"test.com",
            "resourceKey":"AccountName",
            "form":"CONSTANT"
        },
        {
            "value":"1",
            "resourceKey":"AddressType",
            "form":"CONSTANT"
        },
        {
            "value":"true",
            "resourceKey":"ReplyToAddress",
            "form":"CONSTANT"
        },
        {
            "value":"$.data.name",
            "resourceKey":"ToAddress",
            "form":"JSONPATH"
        },
        {
            "value":"true",
            "resourceKey":"IsHtmlBody",
            "form":"CONSTANT"
        },
        {
            "value":{
                "mobile":"$.data.mobile",
                "subject":"$.subject"
            },
            "resourceKey":"Body",
            "form":"TEMPLATE",
            "template":{
                "code":"${subject}"
            }
        }
    ]
}

短信

当事件目标选择短信时,元数据参数如下表所示。

resourceKey resourceName forms
PhoneNumbers 手机号码
  • CONSTANT
  • JSONPATH
SignName 签名名称 CONSTANT
TemplateCode 模板CODE CONSTANT
TemplateParam 模板参数 TEMPLATE

JSONPath示例如下:

{
    "id":"KD20k9rpqDRXPq0SXXlqeTn6kZ",
    "type":"acs.sms",
    "endpoint":"acs:sms:cn-hangzhou:164901546557****",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"$.data",
            "resourceKey":"PhoneNumbers",
            "form":"JSONPATH"
        },
        {
            "value":"[测试专用]阿里云通信",
            "resourceKey":"SignName",
            "form":"CONSTANT"
        },
        {
            "value":" [测试专用]阿里云通信测试模版",
            "resourceKey":"TemplateCode",
            "form":"CONSTANT"
        },
        {
            "value":{
                "mobile":"$.data.mobile",
                "subject":"$.subject"
            },
            "resourceKey":"TemplateParam",
            "form":"TEMPLATE",
            "template":{
                "code":"${subject}"
            }
        }
    ]
}

函数计算

当事件目标选择函数计算时,元数据参数如下表所示。

resourceKey resourceName forms
serviceName 服务 CONSTANT
functionName 函数 CONSTANT
Body 事件
  • ORIGINAL
  • CONSTANT
  • JSONPATH
  • TEMPLATE

JSONPath示例如下:

{
    "id":"KD20k9rpqDRXPq0SXXlqeTn6kZ",
    "type":"acs.fc.function",
    "endpoint":"acs:fc:cn-hangzhou:164901546557****:services/guide-hello_world.LATEST/functions/hello_world",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"guide-hello_world",
            "resourceKey":"serviceName",
            "form":"CONSTANT"
        },
        {
            "value":"hello_world",
            "resourceKey":"functionName",
            "form":"CONSTANT"
        },
        {
            "value":"$.data.name",
            "resourceKey":"Body",
            "form":"JSONPATH"
        },
        {
            "value":"LATEST",
            "resourceKey":"Qualifier",
            "form":"CONSTANT"
        }
    ]
}

消息服务

当事件目标选择消息服务时,元数据参数如下表所示。

resourceKey resourceName forms
queue 队列 CONSTANT
Body 消息内容
  • ORIGINAL
  • CONSTANT
  • JSONPATH
  • TEMPLATE

JSONPath示例如下:

{
    "id":"KD20k9rpqDRXPq0SXXlqeTn6kZ",
    "type":"acs.mns.queue",
    "endpoint":"acs:mns:cn-hangzhou:164901546557****:queues/MyQueue",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"MyQueue",
            "resourceKey":"queue",
            "form":"CONSTANT"
        },
        {
            "value":{
                "source":"$.source"
            },
            "resourceKey":"Body",
            "form":"TEMPLATE",
            "template":"The event comes from ${source} is abnormal."
        }
    ]
}

消息队列RocketMQ版

当事件目标选择消息队列RocketMQ版时,元数据参数如下表所示。

resourceKey resourceName forms
InstanceId 实例ID CONSTANT
Topic Topic CONSTANT
Body Body
  • ORIGINAL
  • JSONPATH
  • CONSTANT
  • TEMPLATE
Properties Properties
  • JSONPATH
  • TEMPLATE
Keys Keys
  • JSONPATH
  • CONSTANT
  • TEMPLATE
Tags Tags
  • JSONPATH
  • CONSTANT
  • TEMPLATE

JSONPath示例如下:

{
    "id":"KD20k9rpqDRXPq0SXXlqeTn6kZ",
    "type":"acs.rocketmq",
    "endpoint":"acs:mq:cn-hangzhou:164901546557****:/instances/${instanceId}/topic/${topic}",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"MQ_INST_164901546557****_BAAQ4gWo",
            "resourceKey":"InstanceId",
            "form":"CONSTANT"
        },
        {
            "value":"test-topic1",
            "resourceKey":"Topic",
            "form":"CONSTANT"
        },
        {
            "value":"$.data.name",
            "resourceKey":"Body",
            "form":"JSONPATH"
        },
        {
            "value":"$.data.userProperties",
            "resourceKey":"Properties",
            "form":"JSONPATH"
        },
        {
            "value":"$.data.systemProperties.KEYS",
            "resourceKey":"Keys",
            "form":"JSONPATH"
        },
        {
            "value":"$.data.systemProperties.TAGS",
            "resourceKey":"Tags",
            "form":"JSONPATH"
        }
    ]
}

消息队列RabbitMQ版

当事件目标选择消息队列RabbitMQ版时,元数据参数如下表所示。

resourceKey resourceName forms
InstanceId 实例 ID CONSTANT
Vhost Vhost CONSTANT
TargetType 目标类型 CONSTANT
Exchange Exchange CONSTANT
说明 参数ExchangeQueue同时只能选择其中一个。
Routing Key Routing Key
  • JSONPATH
  • CONSTANT
Queue Queue CONSTANT
说明 参数ExchangeQueue同时只能选择其中一个。
Body Body
  • ORIGINAL
  • JSONPATH
  • CONSTANT
  • TEMPLATE
MessageId MessageId
  • JSONPATH
  • CONSTANT
  • TEMPLATE
Properties Properties
  • JSONPATH
  • TEMPLATE

JSONPath示例如下:

示例一:目标类型Exchange

{
    "id":"KD20k9rpqDRXPq0SXXlqeTn6kZ",
    "type":"acs.rabbitmq",
    "endpoint":"acs:amqp:cn-hangzhou:164901546557****:/instances/${instanceId}/vhosts/${vhostName}/exchanges/${exchangeName}",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"amqp-cn-i7m29o3s****",
            "resourceKey":"InstanceId",
            "form":"CONSTANT"
        },
        {
            "value":"test.host",
            "resourceKey":"Vhost",
            "form":"CONSTANT"
        },
        {
            "value":"Exchange",
            "resourceKey":"TargetType",
            "form":"CONSTANT"
        },
        {
            "value":"amq.direct",
            "resourceKey":"Exchange",
            "form":"CONSTANT"
        },
        {
            "value":"$.data.name",
            "resourceKey":"RoutingKey",
            "form":"JSONPATH"
        },
        {
            "value":"$.data.name",
            "resourceKey":"Body",
            "form":"JSONPATH"
        },
        {
            "value":"$.data.message",
            "resourceKey":"MessageId",
            "form":"JSONPATH"
        },
        {
            "value":"$.data.userProperties",
            "resourceKey":"Properties",
            "form":"JSONPATH"
        }
    ]
}

示例二:目标类型Queue

{
    "id":"EldwXoVAws5Ix8VpVmrDmrxQTR",
    "type":"acs.rabbitmq",
    "endpoint":"acs:amqp:cn-hangzhou:164901546557****:/instances/${instanceId}/vhosts/${vhostName}/exchanges/${exchangeName}",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"amqp-cn-i7m29o3s****",
            "resourceKey":"InstanceId",
            "form":"CONSTANT"
        },
        {
            "value":"test.host",
            "resourceKey":"Vhost",
            "form":"CONSTANT"
        },
        {
            "value":"Queue",
            "resourceKey":"TargetType",
            "form":"CONSTANT"
        },
        {
            "value":"test.event",
            "resourceKey":"Queue",
            "form":"CONSTANT"
        },
        {
            "value":"$.data.body",
            "resourceKey":"Body",
            "form":"JSONPATH"
        },
        {
            "value":"$.data.message",
            "resourceKey":"MessageId",
            "form":"JSONPATH"
        },
        {
            "value":"$.data.userproperties",
            "resourceKey":"Properties",
            "form":"JSONPATH"
        }
    ]
}

HTTP

当事件目标选择HTTP时,元数据参数如下表所示。

resourceKey resourceName forms
url URL CONSTANT
Body 推送内容
  • ORIGINAL
  • CONSTANT
  • JSONPATH
  • TEMPLATE
Network 网络类型 CONSTANT
VPCNameAndId VPC CONSTANT
VSwitchesNameAndId VSwitch CONSTANT
SecurityGroupNameAndId 安全组 CONSTANT
Token Token CONSTANT

JSONPath示例如下:

示例一:网络类型公网

{
    "id":"KD20k9rpqDRXPq0SXXlqeTn6kZ",
    "type":"http",
    "endpoint":"http://www.****.com/product/aliware/eventbridge",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"http://www.****.com/product/aliware/eventbridge",
            "resourceKey":"url",
            "form":"CONSTANT"
        },
        {
            "value":"",
            "resourceKey":"Body",
            "form":"ORIGINAL"
        },
        {
            "value":"PublicNetwork",
            "resourceKey":"Network",
            "form":"CONSTANT"
        }
    ]
}

示例二:网络类型专有网络

{
    "id":"ZOiNcqqzTGSrDJanZQ72vjL9Se",
    "type":"http",
    "endpoint":"http://192.168.XX.XX:8080",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"http://192.168.XX.XX:8080",
            "resourceKey":"url",
            "form":"CONSTANT"
        },
        {
            "value":"",
            "resourceKey":"Body",
            "form":"ORIGINAL"
        },
        {
            "value":"PrivateNetwork",
            "resourceKey":"Network",
            "form":"CONSTANT"
        },
        {
            "value":"catalog-system/vpc-bp1ohdo84u2lt9wzq****",
            "resourceKey":"VPCNameAndId",
            "form":"CONSTANT"
        },
        {
            "value":"[\"eb/vsw-bp10rbrt6rb6vrd89****\"]",
            "resourceKey":"VSwitchesNameAndId",
            "form":"CONSTANT"
        },
        {
            "value":"sg-catalog-eventlistener/sg-bp14zrnfyik5av27****",
            "resourceKey":"SecurityGroupNameAndId",
            "form":"CONSTANT"
        },
        {
            "value":"",
            "resourceKey":"Token",
            "form":"CONSTANT"
        }
    ]
}

HTTPS

当事件目标选择HTTPS时,元数据参数如下表所示。

resourceKey resourceName forms
url URL CONSTANT
Body 推送内容
  • ORIGINAL
  • CONSTANT
  • JSONPATH
  • TEMPLATE

JSONPath示例如下:

{
    "id":"KD20k9rpqDRXPq0SXXlqeTn6kZ",
    "type":"https",
    "endpoint":"https://www.****.com/product/aliware/eventbridge",
    "pushSelector":"PARAM_TRANSFORMER",
    "paramList":[
        {
            "value":"https://www.****.com/product/aliware/eventbridge",
            "resourceKey":"url",
            "form":"CONSTANT"
        },
        {
            "value":"",
            "resourceKey":"Body",
            "form":"ORIGINAL"
        }
    ]
}