Common Expression Language(CEL)는 표현식을 평가하는 데 사용할 수 있는 오픈소스 비튜링 완전 언어입니다. Eventarc Advanced의 모든 등록에는 메시지를 평가하고 필터링하는 데 사용되는 CEL로 작성된 조건 표현식이 포함되어 있습니다. CEL을 사용하여 변환 표현식을 작성하여 이벤트 데이터 콘텐츠를 변환할 수도 있습니다.
일반적으로 조건 표현식은 논리 연산자(&&, ||, !)로 조인된 하나 이상의 문으로 구성됩니다. 각 문은 데이터에 적용되는 속성 기반 규칙을 나타냅니다. 일반적으로 연산자는 변수에 포함된 값을 리터럴 값과 비교하는 데 사용됩니다.
예를 들어 message.type의 값이 google.cloud.dataflow.job.v1beta3.statusChanged이면 message.type == "google.cloud.dataflow.job.v1beta3.statusChanged" 표현식은 True로 평가됩니다.
모든 이벤트 컨텍스트 속성은 사전 정의된 message 객체를 통해 변수로 액세스할 수 있습니다. 이러한 변수는 런타임 시 이벤트 컨텍스트 속성에 따른 값으로 채워집니다. 등록은 변수를 사용하여 지정된 속성을 표현할 수 있습니다. 예를 들어 message.type은 type 속성의 값을 반환합니다.
다음에 유의하세요.
이벤트는 고유한 이름을 가진 추가적인 커스텀 CloudEvents 속성(확장 속성이라고도 함)을 원하는 만큼 포함할 수 있으며 등록에서 이를 사용할 수 있습니다.
그러나 실제 형식과 관계없이 CEL 표현식에서는 String 유형으로 표시됩니다. CEL 표현식을 사용하여 값을 다른 유형으로 변환할 수 있습니다.
이벤트 페이로드 콘텐츠를 기반으로 등록을 평가할 수는 없습니다. message.data와 message.data_base64는 모두 예약된 변수이며 표현식에 사용할 수 없습니다. 하지만 이벤트 데이터를 변환할 때는 CEL이 지원되므로 (예: 특정 대상의 API 계약을 충족하기 위해) 이벤트 페이로드 콘텐츠를 수정할 수 있습니다.
발생 시점의 타임스탬프입니다. CloudEvents 프로듀서가 다른 시간(예: 현재 시간)으로 설정할 수 있지만 동일한 source의 모든 프로듀서가 일관되어야 합니다.
message.type
String
원래 발생과 관련된 이벤트 유형을 설명합니다.
연산자 및 함수
연산자와 함수를 사용하여 복잡한 로직 표현식을 빌드할 수 있습니다.
&&, ||,, !와 같은 논리 연산자를 사용하면 조건부 표현식에서 여러 변수를 확인할 수 있습니다. 예를 들어 message.time.getFullYear() < 2020 && message.type == "google.cloud.dataflow.job.v1beta3.statusChanged"는 두 개의 문을 결합하며, True라는 전체 결과를 생성하려면 두 문이 모두 True여야 합니다.
x.contains('y')와 같은 문자열 조작 연산자는 정의된 문자열 또는 하위 문자열과 일치하며, 가능한 모든 조합을 나열하지 않고도 메시지를 일치시키는 규칙을 개발할 수 있게 해줍니다.
Eventarc Advanced는 데이터를 변환하고 버스에서 수신된 이벤트의 수정을 간소화하는 데 사용할 수 있는 merge 및 flatten과 같은 확장 함수도 지원합니다.
RE2 패턴은 유니코드 기능을 사용 중지하는 RE2::Latin1 옵션을 통해 컴파일됩니다.
x.replace(y,z)
하위 문자열 y가 하위 문자열 z로 대체된 새 문자열을 반환합니다. 대체할 횟수를 제한하는 선택적 인수를 허용합니다. 예를 들어 다음 표현식은 'wello hello'를 반환합니다.
'hello hello'.replace('he', 'we', 1)
x.split(y)
구분자 y로 입력에서 분할된 문자열 목록을 반환합니다. 생성할 하위 문자열 수를 제한하는 선택적 인수를 허용합니다. 예를 들어 다음 표현식은 ['hello', 'hello hello']를 반환합니다.
'hello hello hello'.split(' ', 2)
x.startsWith(y)
문자열 x가 하위 문자열 y로 시작하면 True를 반환합니다.
x.upperAscii()
모든 ASCII 문자가 대문자인 새 문자열을 반환합니다.
정규 표현식 함수
다음 표에서는 Eventarc Advanced에서 지원하는 정규 표현식 함수를 설명합니다.
표현식
설명
re.capture(target,regex)
regex를 사용하여 target 문자열에서 이름이 지정되지 않았거나 이름이 지정된 첫 번째 그룹 값을 캡처하고 문자열을 반환합니다. 예를 들어 다음 표현식은 "o"를 반환합니다.
re.capture("hello", R"hell(o)")
re.captureN(target,regex)
regex를 사용하여 target 문자열에서 그룹 이름 및 문자열(이름이 지정된 그룹)과 그룹 색인 및 문자열(이름이 지정되지 않은 그룹)을 캡처하고 키-값 쌍의 맵을 반환합니다. 예를 들어 다음 표현식은 {"1": "user", "Username": "testuser", "Domain": "testdomain"}를 반환합니다.
re.captureN("The user testuser belongs to testdomain", R"The (user|domain) (?P.*) belongs to (?P.*)")
re.extract(target,regex,rewrite)
regex를 사용하여 target 문자열에서 일치하는 그룹 값을 추출하고 rewrite 인수를 기반으로 형식이 지정된 추출된 값의 문자열을 반환합니다. 예를 들어 다음 표현식은 "example.com"를 반환합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eEventarc Advanced utilizes Common Expression Language (CEL) for evaluating and filtering messages, allowing users to define condition and transformation expressions.\u003c/p\u003e\n"],["\u003cp\u003eCondition expressions in Eventarc Advanced use logical operators like \u003ccode\u003e&&\u003c/code\u003e, \u003ccode\u003e||\u003c/code\u003e, and \u003ccode\u003e!\u003c/code\u003e to compare variables with literal values, such as checking if \u003ccode\u003emessage.type\u003c/code\u003e equals a specific string.\u003c/p\u003e\n"],["\u003cp\u003eEvent context attributes are accessible as variables within a \u003ccode\u003emessage\u003c/code\u003e object, enabling enrollments to express specific attribute rules, for instance \u003ccode\u003emessage.type\u003c/code\u003e to check the event type.\u003c/p\u003e\n"],["\u003cp\u003eString manipulation and regular expression functions are supported in Eventarc Advanced, facilitating tasks like string comparison, substring extraction, and matching patterns using RE2 syntax.\u003c/p\u003e\n"],["\u003cp\u003eEventarc advanced provides functions such as \u003ccode\u003emerge\u003c/code\u003e and \u003ccode\u003eflatten\u003c/code\u003e, which can be used to simplify the transformation of data.\u003c/p\u003e\n"]]],[],null,["# Use Common Expression Language\n\n[Advanced](/eventarc/advanced/docs/overview)\n\n[Common Expression Language (CEL)](https://opensource.google/projects/cel) is an\nopen source non-Turing-complete language that can be used to evaluate\nexpressions. Every enrollment in Eventarc Advanced includes a condition\nexpression written in CEL that is used to evaluate and filter messages. You can\nalso transform your event data content by writing transformation expressions\nusing CEL.\n\nIn general, a condition expression consists of one or more statements that are\njoined by logical operators (`&&`, `||`, or `!`). Each statement expresses an\nattribute-based rule that is applied to the data. Most commonly, operators are\nused to compare the value contained in a variable with a literal value.\n\nFor example, if the value of `message.type` is\n`google.cloud.dataflow.job.v1beta3.statusChanged`, then the expression\n`message.type == \"google.cloud.dataflow.job.v1beta3.statusChanged\"` evaluates to\n`True`.\n\nFor more information, see the following:\n\n- [Create an enrollment to receive events](/eventarc/advanced/docs/receive-events/create-enrollment)\n- [Transform received events](/eventarc/advanced/docs/receive-events/transform-events)\n- [CEL language definition](https://github.com/google/cel-spec/blob/master/doc/langdef.md)\n\nAvailable attributes\n--------------------\n\nAll event context attributes can be accessed as variables through a predefined\n`message` object. These variables are populated with values based on event\ncontext attributes at runtime. An enrollment can use a variable to express a\ngiven attribute. For example, `message.type` returns the value of the `type`\nattribute.\n\nNote the following:\n\n- Events might include, and enrollments can use, any number of additional custom\n [CloudEvents](https://cloudevents.io/) attributes with distinct names (also\n known as\n [extension attributes](https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md#extension-context-attributes)).\n However, they are represented as `String` types in CEL expressions regardless of\n their actual format. You can use a CEL expression to cast their values to other\n types.\n\n- You can't evaluate enrollments based on the event payload content. Both\n `message.data` and `message.data_base64` are reserved variables and can't be\n used in expressions. However, CEL is supported when\n [transforming event data](/eventarc/advanced/docs/receive-events/transform-events)\n which lets you modify the event payload content (for example, to satisfy the\n API contract for a specific destination).\n\nThe following attributes can be accessed when evaluating condition expressions\nfor an enrollment:\n\n\u003cbr /\u003e\n\nOperators and functions\n-----------------------\n\nYou can use operators and functions to build complex logic expressions.\n\nLogical operators, such as `&&`, `||,` and `!`, let you verify multiple\nvariables in a conditional expression. For example,\n`message.time.getFullYear() \u003c 2020 && message.type == \"google.cloud.dataflow.job.v1beta3.statusChanged\"`\njoins two statements, and requires both statements to be `True` to produce an\noverall result of `True`.\n| **Note:** A distinction is made between an attribute that is not set versus an attribute with an empty value. You can use the `has` macro to test for a field's existence. For example, `has(message.bucket)` returns `True` if the extension attribute `bucket` is set. If an attribute isn't set, any logical operations using it always evaluate to `False` regardless of the literal value.\n\nString manipulation operators, such as `x.contains('y')`, match strings or\nsubstrings that you define, and let you develop rules to match messages without\nlisting every possible combination.\n\nEventarc Advanced also supports extension functions, such as\n`merge` and `flatten`, which can be used to transform data and simplify the\nmodification of events received from a bus.\n\nSee the list of\n[CEL predefined operators and functions](https://github.com/google/cel-spec/blob/master/doc/langdef.md#standard-definitions)\nand\n[CEL predefined macros](https://github.com/google/cel-spec/blob/master/doc/langdef.md#macros).\n\n### Logical operators\n\nThe following table describes the logical operators that Eventarc Advanced\nsupports.\n\n### String manipulation operators\n\nThe following table describes the string manipulation operators that\nEventarc Advanced supports.\n\n### Regular expression functions\n\nThe following table describes the regular expression functions that\nEventarc Advanced supports.\n\nThe regular expressions follow the\n[RE2 syntax](https://github.com/google/re2/wiki/Syntax). Note that the\n`R` preceding the regular expressions indicates a raw string that doesn't\nrequire escaping.\n\n### Extension functions\n\nEventarc Advanced supports certain extension functions that can\nbe used to transform the event data received through a bus. For more information\nand examples, see\n[Transform received events](/eventarc/advanced/docs/receive-events/transform-events#transform-functions).\n\nWhat's next\n-----------\n\n- [Transformation examples](/eventarc/advanced/docs/receive-events/transformation-examples)"]]