CloudEvents Specification
repository·main·Indexed 26 days ago
https://github.com/cloudevents/specSpecification for describing event data in common formats to enable interoperability between systems. Includes the CloudEvents SQL Expression Language (CESQL) for filtering event instances, guidelines for CloudEvents Adapters (e.g., AWS S3, SNS, GitHub, GitLab), and definitions for Extension Attributes such as Distributed Tracing and Auth Context.
What's inside CloudEvents
- CloudEvents Adapters are used to convert events from producers that do not natively support the CloudEvents specification into valid CloudEvents. This process typically involves extracting metadata from the original event and mapping it to CloudEvents attributes. To ensure interoperability between different implementations, specific algorithms are proposed for various services.
Overview of CloudEvents SQL Expression Language (CESQL)
mainCloudEvents SQL Expression Language (CESQL) is a SQL-like expression language designed to define predicates for filtering CloudEvent instances. It is a total pure functional programming language, ensuring that expression evaluation always terminates and does not mutate the input CloudEvent instance.
Key Characteristics:
- Purpose: Computing values and matching CloudEvent attributes against complex expressions (similar to SQL
WHEREclauses). - Output Types: The primary output of an expression is always a
boolean, aninteger, or astring. Evaluation also produces a set of errors (which may be empty). - Limitations: CESQL does not support handling the
datafield of CloudEvent instances due to its polymorphic nature. - Environment Agnostic: It can be implemented in producers, intermediaries, or sources using any technology stack.
- Purpose: Computing values and matching CloudEvent attributes against complex expressions (similar to SQL
Core Functionality of a CloudEvents SDK
mainA compliant CloudEvents SDK must facilitate the transition between a high-level canonical
Eventobject and transport-specific encoded messages. The expected data flow is:- Encoding:
Event$\rightarrow$Message$\rightarrow$Transport(e.g., sending an event via HTTP). - Decoding:
Transport$\rightarrow$Message$\rightarrow$Event(e.g., receiving an event via HTTP).
Key tasks an SDK must support:
- Compose an Event: Create new events from raw data or mutate existing CloudEvents.
- Encode an Event: Convert an
Eventinto a transport-specific format (e.g.,structuredorbinarymode for HTTP). - Decode an Event: Convert a transport-specific message or request/response back into a canonical
Eventobject. - Data Unpacking: Provide methods to unpack event data from formats like
base64orjsoninto the language's native format.
- Encoding:
Use Correlation and Causation attributes for event traceability
mainThe Correlation extension provides two attributes to track relationships in distributed systems:
correlationid: Groups all events belonging to the same logical flow or business transaction. Use this to answer: "Which events are part of the same business transaction?"causationid: Tracks the direct parent-child relationship. This SHOULD be theidof the event that directly triggered the current event. Use this to answer: "Which specific event directly triggered this event?"
Both attributes are
OPTIONALbut, if present, MUST be non-empty strings.Understand CloudEvents Extension Attributes
mainCloudEvents Extension Attributes are additional metadata attributes used when transforming generic events into CloudEvents. While the core CloudEvents specification defines a minimal set of mandatory attributes, extensions provide additional metadata to improve interoperability for specific use cases.
Key characteristics of extensions:
- Optional Support: Implementations are not required to support any specific extension.
- Experimental Nature: Extensions may have a lower level of maturity than core attributes and can be changed or removed without the same rigorous process required for the core specification.
- Compliance: Even though they are not part of the core specification, extension attributes MUST follow the same serialization rules defined by the format and protocol binding specifications (e.g., JSON, binary).
Available CloudEvents SDKs
mainThe CloudEvents community maintains official SDKs for several programming languages to speed up integration. These SDKs are designed to work with the CloudEvents specification and provide idiomatic implementations for their respective languages.
Supported SDKs include:
- C#/.NET
- Go
- Java
- JavaScript
- Kotlin
- PHP
- PowerShell
- Python
- Ruby
- Rust
Use the recordedtime extension for bitemporal data
mainThe
recordedtimeextension allows you to represent bitemporal data in CloudEvents by providing two distinct timestamps for every event:- Occurrence time: The timestamp of when the event actually happened (represented by the standard
timeattribute). - Recorded time: The timestamp of when the CloudEvent was created by a producer (represented by the
recordedtimeextension attribute).
This distinction is useful for analytics, data science, and determining latency between producers and consumers.
- Occurrence time: The timestamp of when the event actually happened (represented by the standard
Use the Severity Extension attributes
mainThe Severity Extension provides a standardized way to describe the 'severity' or 'log-level' of a CloudEvent. This extension is designed to interoperate with OpenTelemetry Severity Fields.
When using this extension, you can include two attributes:
severitytextandseveritynumber. If both are used, theseveritytextvalues SHOULD have a one-to-one and onto relationship with theseveritynumbervalues produced by the same source.Use the Partitioning extension for event scaling
mainThe Partitioning extension provides an attribute used by message brokers and clients to support event partitioning, which is typically used for scaling large-scale systems. By using a partition key, events can be distributed into multiple buckets for separate, ordered processing. To ensure related events are processed in the same bucket, the sender MUST use the same partition key for those events.Access CloudEvents logos and artwork
mainCloudEvents logos are hosted in the CNCF artwork repository. The assets are provided in multiple formats, layouts, and color versions to suit different design requirements.
Available Formats:
- PNG
- SVG
- AI
Available Layouts:
- Horizontal (landscape format)
- Stacked (square-like layout)
- Icon (square icon only, excludes the project name)
Available Color Versions:
- Color
- Black
- White
For guidance on using CloudEvents terms in text, refer to the CNCF Style Guide.
Use the Auth Context extension to embed principal information
mainThe Auth Context extension allows you to embed information about the principal (the entity/user) that triggered a CloudEvent. This enables consumers to perform user-dependent actions without needing to parse the
dataorsourcefields for user IDs.Warning: This extension is purely informational and is not intended to secure CloudEvents.
Use proposed algorithms for specific CloudEvents adapters
mainWhen implementing adapters for specific services, follow the proposed algorithms to ensure interoperability. The following service-specific adapter documentation is available:
- AWS S3: Mapping AWS S3 events to CloudEvents.
- AWS SNS: Mapping AWS SNS events to CloudEvents.
- CouchDB: Mapping CouchDB events to CloudEvents.
- GitHub: Mapping GitHub webhooks/events to CloudEvents.
- GitLab: Mapping GitLab webhooks/events to CloudEvents.