{"id":9384,"date":"2026-10-10T06:11:22","date_gmt":"2026-10-10T06:11:22","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=9384"},"modified":"2026-10-12T02:12:19","modified_gmt":"2026-10-12T02:12:19","slug":"creating-pubsub-subscription-with-message-filtering","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/","title":{"rendered":"Creating pubsub subscription with message filtering"},"content":{"rendered":"\r\n<h1><strong><b>How to Filter Messages in a Pub\/Sub Subscription<\/b><\/strong><\/h1>\r\n<p class=\"wp-block-paragraph\">A single Pub\/Sub topic often carries several kinds of messages. An orders topic might carry orders from different countries, a logs topic might mix errors with routine notices, and an events topic might serve several teams at once. Without filtering, every subscription receives everything, and each subscriber has to throw away what it does not need.<\/p>\r\n<p>Message filtering moves that decision into Pub\/Sub. You attach a filter to a subscription, and only the messages that match are delivered to it. The rest are acknowledged automatically and never reach your code. Your subscribers get simpler, your traffic drops, and one topic can feed many different consumers, each seeing only its own slice.<\/p>\r\n<p>There is one thing to understand before you write a filter. Pub\/Sub filters look at message <strong><b>attributes<\/b><\/strong>, the small key and value labels you attach when you publish. They do not look inside the message body, and they do not support regular expressions. Many people discover that only after their filter matches nothing. This guide explains the rules clearly, then shows you how to create a filtered subscription in the console with the original screenshots kept in place, and with gcloud. We then cover the filter syntax with examples, a test, the limits, common mistakes and a short FAQ.<\/p>\r\n<h2><strong><b>What a Filter Can and Cannot Do?<\/b><\/strong><\/h2>\r\n<div style=\"width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px;\">\r\n<table style=\"width: 100%; min-width: 600px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.5; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 12px 14px; font-size: 18px; font-weight: bold; color: #0f2a4a;\">Pub\/Sub subscription filter support<\/caption>\r\n<thead>\r\n<tr style=\"background: #0f2a4a;\">\r\n<th style=\"padding: 12px 14px; text-align: left; color: #ffffff; font-weight: bold; border-bottom: 2px solid #0b1f38; width: 24%;\" scope=\"col\">Point<\/th>\r\n<th style=\"padding: 12px 14px; text-align: left; color: #ffffff; font-weight: bold; border-bottom: 2px solid #0b1f38; width: 38%;\" scope=\"col\">Supported<\/th>\r\n<th style=\"padding: 12px 14px; text-align: left; color: #ffffff; font-weight: bold; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Not supported<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 600; vertical-align: top; border-bottom: 1px solid #e5e9f0;\" scope=\"row\">What it reads<\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Message attributes<\/td>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">The message data, which is the body<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 600; vertical-align: top; border-bottom: 1px solid #e5e9f0;\" scope=\"row\">Matching<\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Exact match, key exists, starts with<\/td>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Regular expressions<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 600; vertical-align: top; border-bottom: 1px solid #e5e9f0;\" scope=\"row\">Logic<\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">AND, OR, NOT with parentheses<\/td>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Custom code<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 600; vertical-align: top; border-bottom: 1px solid #e5e9f0;\" scope=\"row\">Length<\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Up to 256 bytes<\/td>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Longer filters<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 600; vertical-align: top;\" scope=\"row\">Changing it later<\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top;\">Create a new subscription<\/td>\r\n<td style=\"padding: 12px 14px; vertical-align: top;\">Editing the filter in place<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<p>&nbsp;<\/p>\r\n<p>Because filters read attributes, the publisher has to put the information you want to filter on into attributes. If a country code lives only inside the message body, the filter cannot see it. Plan the attributes at the publishing side first.<\/p>\r\n<p><strong>Prerequisites:<\/strong><\/p>\r\n<ul>\r\n<li>A Google Cloud account with a project that has billing enabled.<\/li>\r\n<li>The Pub\/Sub API enabled.<\/li>\r\n<li>An existing topic whose publisher sets attributes on its messages.<\/li>\r\n<li>A role that can create subscriptions, such as Pub\/Sub Editor.<\/li>\r\n<li>Cloud Shell or the gcloud CLI for the testing steps.<\/li>\r\n<\/ul>\r\n<h2><strong><b>Create a Filtered Subscription Using the Console<\/b><\/strong><\/h2>\r\n<p>Menu labels move from time to time, so treat the wording below as a guide.<\/p>\r\n<p>1. Sign in to the Google Cloud console. Open the navigation menu, choose Pub\/Sub and then Subscriptions.<\/p>\r\n<p>2. Click <strong><b>Create subscription<\/b><\/strong>.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"139\" class=\"wp-image-9385\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644.png 628w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644-300x66.png 300w\" sizes=\"auto, (max-width: 628px) 100vw, 628px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">3. Enter a subscription ID, such as orders-india-sub.<br \/>4. Select the topic the subscription should read from.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"649\" height=\"412\" class=\"wp-image-9386\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/2-3.jpg\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/2-3.jpg 649w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/2-3-300x190.jpg 300w\" sizes=\"auto, (max-width: 649px) 100vw, 649px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">5. Choose the delivery type, either pull or push.<br \/>6. Set the message retention duration and the subscription expiration period.<br \/>7. Set the acknowledgement deadline.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"563\" height=\"659\" class=\"wp-image-9387\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/3-1.jpg\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/3-1.jpg 563w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/3-1-256x300.jpg 256w\" sizes=\"auto, (max-width: 563px) 100vw, 563px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\"><br \/>8. Find the subscription filter field and enter your filter, for example attributes.country = &#8220;IN&#8221;. Remember that you cannot change it after creating the subscription.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"495\" height=\"248\" class=\"wp-image-9388\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-645.png\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-645.png 495w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-645-300x150.png 300w\" sizes=\"auto, (max-width: 495px) 100vw, 495px\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"wp-block-paragraph\">9. Click Create. The filtered subscription appears in the list.<\/p>\r\n\r\n\r\n\r\n<figure class=\"wp-block-table is-style-stripes\"><\/figure>\r\n\r\n\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"232\" class=\"wp-image-9389\" src=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/4-2.jpg\" alt=\"\" srcset=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/4-2.jpg 525w, https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/4-2-300x133.jpg 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\r\n<h2><strong><b>Create a Filtered Subscription With gcloud<\/b><\/strong><\/h2>\r\n<p>gcloud pubsub subscriptions create orders-india-sub &#8211;topic=orders-topic &#8211;message-filter=&#8217;attributes.country = &#8220;IN&#8221;&#8216;<\/p>\r\n<p>For a push subscription, add the endpoint flag:<\/p>\r\n<p>gcloud pubsub subscriptions create orders-india-push &#8211;topic=orders-topic &#8211;push-endpoint=https:\/\/my-service.example.com\/push &#8211;message-filter=&#8217;attributes.country = &#8220;IN&#8221;&#8216;<\/p>\r\n<p>Wrap the whole filter in single quotes and use double quotes around the value, as shown, so your shell does not mangle it.<\/p>\r\n<h2><strong><b>Filter Syntax With Examples<\/b><\/strong><\/h2>\r\n<p>Here are the patterns you will use most, written for a message attribute named domain.<\/p>\r\n<div style=\"width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 20px 0; border: 1px solid #d9e0ea; border-radius: 8px;\">\r\n<table style=\"width: 100%; min-width: 600px; border-collapse: collapse; font-family: Arial,Helvetica,sans-serif; font-size: 16px; line-height: 1.5; color: #1f2937;\"><caption style=\"caption-side: top; text-align: left; padding: 12px 14px; font-size: 18px; font-weight: bold; color: #0f2a4a;\">Pub\/Sub subscription filter examples<\/caption>\r\n<thead>\r\n<tr style=\"background: #0f2a4a;\">\r\n<th style=\"padding: 12px 14px; text-align: left; color: #ffffff; font-weight: bold; border-bottom: 2px solid #0b1f38; width: 50%;\" scope=\"col\">Filter<\/th>\r\n<th style=\"padding: 12px 14px; text-align: left; color: #ffffff; font-weight: bold; border-bottom: 2px solid #0b1f38;\" scope=\"col\">Description<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 400; vertical-align: top; border-bottom: 1px solid #e5e9f0;\" scope=\"row\"><code style=\"font-family: 'Courier New',Courier,monospace; font-size: 14px; background: #eef2f7; padding: 2px 6px; border-radius: 4px; word-break: break-word;\">attributes:domain<\/code><\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Messages with the domain attribute<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 400; vertical-align: top; border-bottom: 1px solid #e5e9f0;\" scope=\"row\"><code style=\"font-family: 'Courier New',Courier,monospace; font-size: 14px; background: #e4eaf2; padding: 2px 6px; border-radius: 4px; word-break: break-word;\">NOT attributes:domain<\/code><\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Messages without the domain attribute<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 400; vertical-align: top; border-bottom: 1px solid #e5e9f0;\" scope=\"row\"><code style=\"font-family: 'Courier New',Courier,monospace; font-size: 14px; background: #eef2f7; padding: 2px 6px; border-radius: 4px; word-break: break-word;\">attributes.domain = \"com\"<\/code><\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Messages with the domain attribute and the value of com<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 400; vertical-align: top; border-bottom: 1px solid #e5e9f0;\" scope=\"row\"><code style=\"font-family: 'Courier New',Courier,monospace; font-size: 14px; background: #e4eaf2; padding: 2px 6px; border-radius: 4px; word-break: break-word;\">attributes.domain != \"com\"<\/code><\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Messages without the domain attribute and the value of com<\/td>\r\n<\/tr>\r\n<tr style=\"background: #ffffff;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 400; vertical-align: top; border-bottom: 1px solid #e5e9f0;\" scope=\"row\"><code style=\"font-family: 'Courier New',Courier,monospace; font-size: 14px; background: #eef2f7; padding: 2px 6px; border-radius: 4px; word-break: break-word;\">hasPrefix(attributes.domain, \"co\")<\/code><\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #e5e9f0;\">Messages with the domain attribute and a value that starts with co<\/td>\r\n<\/tr>\r\n<tr style=\"background: #f5f8fc;\">\r\n<th style=\"padding: 12px 14px; text-align: left; font-weight: 400; vertical-align: top;\" scope=\"row\"><code style=\"font-family: 'Courier New',Courier,monospace; font-size: 14px; background: #e4eaf2; padding: 2px 6px; border-radius: 4px; word-break: break-word;\">NOT hasPrefix(attributes.domain, \"co\")<\/code><\/th>\r\n<td style=\"padding: 12px 14px; vertical-align: top;\">Messages without the domain attribute and a value that starts with co<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<p>&nbsp;<\/p>\r\n<p>You can combine conditions. The words AND, OR and NOT must be written in capital letters, and you should use parentheses whenever you mix AND with OR:<\/p>\r\n<p>attributes:domain AND (attributes.domain = &#8220;net&#8221; OR attributes.domain = &#8220;org&#8221;)<\/p>\r\n<p>A few rules to remember:<\/p>\r\n<ul>\r\n<li>The attribute name goes on the left of the comparison and the value on the right.<\/li>\r\n<li>hasPrefix is the only function available.<\/li>\r\n<li>If an attribute name contains characters other than letters, numbers, hyphens and underscores, write it in quotes, for example attributes.&#8221;iana.org\/language_tag&#8221;.<\/li>\r\n<\/ul>\r\n<h2><strong><b>Test Your Filter<\/b><\/strong><\/h2>\r\n<p>Publish one message that should match and one that should not, with attributes set:<\/p>\r\n<ol>\r\n<li><em>Publish a matching message:<\/em><\/li>\r\n<\/ol>\r\n<p>gcloud pubsub topics publish orders-topic &#8211;message=&#8221;order 1&#8243; &#8211;attribute=country=IN<\/p>\r\n<ol start=\"2\">\r\n<li><em>Publish a message that should be filtered out:<\/em><\/li>\r\n<\/ol>\r\n<p>gcloud pubsub topics publish orders-topic &#8211;message=&#8221;order 2&#8243; &#8211;attribute=country=US<\/p>\r\n<ol start=\"3\">\r\n<li><em>Pull from the filtered subscription:<\/em><\/li>\r\n<\/ol>\r\n<p>gcloud pubsub subscriptions pull orders-india-sub &#8211;auto-ack &#8211;limit=10<\/p>\r\n<p>You should see order 1 only. If nothing arrives, check that the attribute name and value match your filter exactly. Matching is case sensitive.<\/p>\r\n<h2><strong><b>Change a Filter After Creation<\/b><\/strong><\/h2>\r\n<p>A filter cannot be edited. Google documents a safe way to replace one without losing messages:<\/p>\r\n<ol>\r\n<li>Take a snapshot of the existing subscription.<\/li>\r\n<li>Create a new subscription on the same topic with the new filter.<\/li>\r\n<li>Seek the new subscription to the snapshot, so it picks up where the old one left off.<\/li>\r\n<li>Move your subscribers to the new subscription.<\/li>\r\n<li>Delete the old subscription.<\/li>\r\n<\/ol>\r\n<h2><strong><b>Costs and Limits to Know<\/b><\/strong><\/h2>\r\n<ul>\r\n<li><b><\/b><strong><b>Filtered out messages are acknowledged automatically. <\/b><\/strong>They never reach your subscriber.<\/li>\r\n<li><b><\/b><strong><b>They are not entirely free. <\/b><\/strong>Google says you do not pay outbound message fees for them, but you still pay message delivery fees and seek related storage fees. Check the current pricing page.<\/li>\r\n<li><b><\/b><strong><b>Filters are limited to 256 bytes. <\/b><\/strong>For more complex logic, Google suggests a subscription Single Message Transform.<\/li>\r\n<li><b><\/b><strong><b>Backlog metrics count matching messages only. <\/b><\/strong>A quiet filtered subscription looks small in monitoring, by design.<\/li>\r\n<li><b><\/b><strong><b>Both delivery types support filters. <\/b><\/strong>Pull and push subscriptions can use them.<\/li>\r\n<li><b><\/b><strong><b>Ordering and dead lettering. <\/b><\/strong>I did not find how filters interact with these on Google&#8217;s page, so test the combination before relying on it.<\/li>\r\n<\/ul>\r\n<h2><strong><b>Common Mistakes to Avoid<\/b><\/strong><\/h2>\r\n<ul>\r\n<li><b><\/b><strong><b>Filtering on the message body. <\/b><\/strong>Filters read attributes only.<\/li>\r\n<li><b><\/b><strong><b>Using a regular expression. <\/b><\/strong>It is not supported. Use hasPrefix or exact matches.<\/li>\r\n<li><b><\/b><strong><b>Writing and, or, not in lower case. <\/b><\/strong>They must be in capitals.<\/li>\r\n<li><b><\/b><strong><b>Putting the value on the left. <\/b><\/strong>The attribute goes first.<\/li>\r\n<li><b><\/b><strong><b>Expecting to edit the filter later. <\/b><\/strong>Plan it up front, or use the snapshot method.<\/li>\r\n<li><b><\/b><strong><b>Copying commands with curly quotes or a long dash. <\/b><\/strong>Pasting from a web page can change the quote marks and the double dash before a flag. Type them by hand if a command fails oddly.<\/li>\r\n<\/ul>\r\n<p>Message filtering lets one topic serve many subscribers without each one wading through everything. Put the values you need into attributes at the publishing side, write the filter carefully, test it with one matching and one non matching message, and remember that you cannot edit it later.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>How to Filter Messages in a Pub\/Sub Subscription A single Pub\/Sub topic often carries several kinds of messages. An orders topic might carry orders from different countries, a logs topic might mix errors with routine notices, and an events topic might serve several teams at once. Without filtering, every subscription receives everything, and each subscriber [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,1635],"tags":[605,699,700,984,683,739,684,685,611,1400,1523,1524,1525,1528,1527],"class_list":["post-9384","post","type-post","status-publish","format-standard","hentry","category-google-cloud-platform","category-pubsub","tag-gcp","tag-gcp-certification","tag-gcp-cloud-console","tag-gcp-course","tag-google-cloud-certification","tag-google-cloud-components","tag-google-cloud-console","tag-google-cloud-courses","tag-google-cloud-platform","tag-google-cloud-platform-tutorial","tag-pubsub","tag-pubsub-google-cloud","tag-pubsub-message","tag-pubsub-message-filtering","tag-pubsub-push-message"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Filter Messages in a Pub\/Sub Subscription- Prwatech<\/title>\n<meta name=\"description\" content=\"Create a Pub\/Sub subscription with a message filter, learn the exact filter syntax on attributes, and avoid limits that trip people up, such as no regex.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Filter Messages in a Pub\/Sub Subscription- Prwatech\" \/>\n<meta property=\"og:description\" content=\"Create a Pub\/Sub subscription with a message filter, learn the exact filter syntax on attributes, and avoid limits that trip people up, such as no regex.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-10T06:11:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-12T02:12:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644.png\" \/>\n\t<meta property=\"og:image:width\" content=\"628\" \/>\n\t<meta property=\"og:image:height\" content=\"139\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/\",\"url\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/\",\"name\":\"How to Filter Messages in a Pub\/Sub Subscription- Prwatech\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644.png\",\"datePublished\":\"2026-10-10T06:11:22+00:00\",\"dateModified\":\"2026-10-12T02:12:19+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Create a Pub\/Sub subscription with a message filter, learn the exact filter syntax on attributes, and avoid limits that trip people up, such as no regex.\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/#primaryimage\",\"url\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644.png\",\"contentUrl\":\"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644.png\",\"width\":628,\"height\":139},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Creating pubsub subscription with message filtering\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Filter Messages in a Pub\/Sub Subscription- Prwatech","description":"Create a Pub\/Sub subscription with a message filter, learn the exact filter syntax on attributes, and avoid limits that trip people up, such as no regex.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/","og_locale":"en_US","og_type":"article","og_title":"How to Filter Messages in a Pub\/Sub Subscription- Prwatech","og_description":"Create a Pub\/Sub subscription with a message filter, learn the exact filter syntax on attributes, and avoid limits that trip people up, such as no regex.","og_url":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2026-10-10T06:11:22+00:00","article_modified_time":"2026-10-12T02:12:19+00:00","og_image":[{"width":628,"height":139,"url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644.png","type":"image\/png"}],"author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/","url":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/","name":"How to Filter Messages in a Pub\/Sub Subscription- Prwatech","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/#primaryimage"},"image":{"@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/#primaryimage"},"thumbnailUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644.png","datePublished":"2026-10-10T06:11:22+00:00","dateModified":"2026-10-12T02:12:19+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Create a Pub\/Sub subscription with a message filter, learn the exact filter syntax on attributes, and avoid limits that trip people up, such as no regex.","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/#primaryimage","url":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644.png","contentUrl":"https:\/\/prwatech.in\/blog\/wp-content\/uploads\/2021\/05\/image-644.png","width":628,"height":139},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/google-cloud-platform\/pubsub\/creating-pubsub-subscription-with-message-filtering\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Creating pubsub subscription with message filtering"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/9384","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=9384"}],"version-history":[{"count":6,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/9384\/revisions"}],"predecessor-version":[{"id":11953,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/9384\/revisions\/11953"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=9384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=9384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=9384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}