Prerequisites
GCP account
Open Console.
Open Menu > Pubsub > Subscriptions
Click on create Subscription

Give the subscription ID.
Choose the pubsub topic.

Choose the delivery type.
Choose the retention period for message. Choose the expiration period.
Give the Acknowledgement time

In subscription filter give the filter syntax.

These filter types you can use to filter the messages.
Filter | Description |
attributes:domain | Messages with the domain attribute |
NOT attributes:domain | Messages without the domain attribute |
attributes.domain = “com” | Messages with the domain attribute and the value of com |
attributes.domain != “com” | Messages without the domain attribute and the value of com |
hasPrefix(attributes.domain, “co”) | Messages with the domain attribute and a value that starts with co |
NOT hasPrefix(attributes.domain, “co”) | Messages without the domain attribute and a value that starts with co |
Click create. The subscription with message filtering will be created
