All Products
Search
Document Center

ApsaraMQ for MQTT:Data extraction

Last Updated:Mar 11, 2026

When you create an event rule, EventBridge routes events in the standard CloudEvents 1.0 format to event targets. By default, the full event is forwarded as-is. If the target requires a different format or only a subset of the event data, you can configure a transformation method to extract and reshape the event content before delivery.

Four transformation methods are available:

MethodDescriptionTypical use case
Complete EventForward the full event with no changesPass the raw event to a target that can parse CloudEvents directly
Partial EventExtract a single field using a JSONPath expressionPull one specific value, such as a resource name or status
Fixed ValueRoute a static value; the event acts purely as a triggerTrigger a downstream action that does not depend on event content
TemplateExtract multiple fields into variables and compose a custom outputBuild a notification message or restructure the payload for the target

How it works

Each transformation follows two phases:

  1. Extract -- Read specific fields from the incoming CloudEvents event using JSONPath expressions (for example, $.data.name).

  2. Compose -- Assemble the extracted values into the output format defined by the transformation method, then deliver the result to the event target.

The method you choose determines which phases apply:

MethodExtract phaseCompose phase
Complete EventSkippedPasses the full event unchanged
Partial EventExtracts a single field via JSONPathReturns the extracted value
Fixed ValueSkippedReturns a static value you define
TemplateExtracts multiple fields into named variablesSubstitutes variables into a template

Sample event

All examples in this topic use the following CloudEvents event as input:

{
    "id": "7adc8c1a-645d-4476-bdef-5d6fb57f****",
    "source": "acs.oss",
    "specversion": "1.0",
    "type": "oss:ObjectCreated:PostObject",
    "datacontenttype": "application/json",
    "dataschema": "http://example.com/test.json",
    "subject": "acs:oss:cn-hangzhou:1234567:xls-papk/game_apk/123.jpg",
    "time": "2020-08-17T16:04:46.149Asia/Shanghai",
    "aliyuneventbusname": "demo-bus",
    "aliyunregionid": "Shanghai",
    "data": {
        "name": "test",
        "scope": 100
    }
}

Complete Event

EventBridge routes the full event to the target with no changes. The output is identical to the input shown in Sample event.

Use this method when the downstream target can parse the full CloudEvents payload directly.

Partial Event

EventBridge extracts a single value from the event using a JSONPath expression and routes only that value to the target.

Example

JSONPath expressionOutput
$.data.nametest
Note

Partial Event supports only one JSONPath expression per rule. The extracted value can be up to 10,240 characters in length.

Fixed Value

The event acts purely as a trigger. EventBridge routes a static value that you define to the target, regardless of the event content.

Example

Fixed valueOutput
test1test1
Note

The fixed value can be up to 10,240 characters in length.

Template

Template is the most flexible method. It works in two steps:

  1. Define variables -- Map JSONPath expressions to named variables.

  2. Write a template -- Reference the variables with ${variable_name} syntax to compose the output.

Variable definition example

{
    "name": "$.data.name",
    "state": "$.data.state"
}

This creates two variables: ${name} (resolves to "test") and ${state} (resolves to "RUNNING") when the data field contains {"name": "test", "state": "RUNNING"}.

Template format options

Templates support three output formats, compared below using the variables defined above.

FormatTemplateOutput
Simple string"name ${name} is in ${state}""name test is in RUNNING"
Simple JSON{"name": "${name}", "state": "${state}"}{"name": "test", "state": "RUNNING"}
JSON with variables and fixed values{"name": "${name}", "state": [9, "${state}", true], "Transformed": "Yes"}{"name": "test", "state": [9, "RUNNING", true], "Transformed": "Yes"}

Variables can also hold fixed values. For example, the following variable definition includes a constant string:

{
    "name": "$.data.name",
    "constant": "Please deal with it timely."
}

With the template The instance is broken, which name is ${name}, ${constant}, the output is:

The instance is broken, which name is test, Please deal with it timely.

Limitations

ConstraintLimit
Variable structureFlat key-value pairs only. Nested structures are not supported.
Variable value lengthUp to 10,240 characters
Template lengthUp to 10,240 characters

Troubleshooting

IssueCauseSolution
JSONPath returns no valueThe path does not match any field in the event.Verify the JSONPath expression against the actual event structure. Check for typos in field names.
Output exceeds character limitThe extracted value or template exceeds 10,240 characters.Reduce the scope of the extraction or simplify the template.
Template variable not replacedThe variable name in the template does not match the variable definition.Confirm that the ${variable_name} in the template exactly matches a key in the variable definition JSON.
Unexpected output formatVariables are defined with nested JSON objects.Flatten the variable definition. Nested structures are not supported.

Related topics