Understand path patterns

Preview

This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. Pre-GA features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.

Eventarc supports applying a path pattern when filtering. The pathpattern syntax lets you define an expression that matches events. This letsyou control the granularity of the Eventarc trigger you arecreating, and to capture and act on certain events. For example, you can createa trigger that applies to a single event, such as a change to a specific file,or you can extend the scope of the pattern and create a trigger that appliesmore broadly.

Apply a path pattern

You can apply a path pattern to filter events when you create a triggerusing the Eventarc Google Cloud console page or by runningagcloud command.

For example, you can apply a path pattern when filtering onresource names ordatabase instances (a single instance or a path).

  • Specifying aresource name path pattern applies when creating a triggerforCloud Audit Logs events and toresourceName values. A resourcename indicates the resource being audited through an audit log.Resource names are organized hierarchically using identifiers made up of theID of the resource itself and the IDs of any parent resources, all separated byforward slashes, like this:/projects/project-1/datasets/dataset-id.The filtering done by Eventarc matches patterns based on thevalues of these identifiers. For more information, in this document, seeResource name format.

  • Specifying adatabase instance path pattern applies when creating atrigger forFirebase Realtime Database events and toinstance orrefvalues. A database instance indicates a Firebase Realtime Databaseinstance. You can apply a path pattern to the instance name of the databaseinstance, or a document path for which you want to receive events when data iscreated, updated, or deleted in that path, or any of its children.

  • Specifying aresource ID path pattern applies when creating a triggerforCloud IoT events and toregistry anddevice values.You can apply a path pattern to filter changes in registries, and devices in aregistry, with wildcard matching.

For details, see the instructions tocreate a trigger for a specific provider, event type, and destination.

Identify if you can apply a path pattern

To confirm if you can apply a path pattern to an attribute of an event from aprovider, describe the event provider. For example:

gcloudeventarcprovidersdescribecloudaudit.googleapis.com--location=us-central1

The output is similar to the following and apathPatternSupported value oftrue indicates that you can apply a path pattern:

displayName:CloudAuditLogseventTypes:-description:Anauditlogiscreatedthatmatchesthetrigger's filter criteria.  filteringAttributes:  - attribute: methodName    description: The identifier of the service'soperation.required:true-attribute:resourceNamedescription:Thecompletepathtoaresource.Usedtofiltereventsforaspecificresource.pathPatternSupported:true-attribute:serviceNamedescription:TheidentifieroftheGoogleCloudservice.required:true-attribute:typerequired:truetype:google.cloud.audit.log.v1.writtenname:projects/project-name/locations/us-central1/providers/cloudaudit.googleapis.com

Or, for example:

gcloudeventarcprovidersdescribefirebasedatabase.googleapis.com--location=us-central1

Where the output is similar to the following:

displayName:FirebaseRealtimeDatabaseeventTypes:-description:Newdatahasbeencreatedinthedatabase.filteringAttributes:-attribute:instancedescription:Asingledatabaseinstance.pathPatternSupported:truerequired:true-attribute:refdescription:Patterntomatchforthedatabaseinstance.pathPatternSupported:truerequired:true-attribute:typerequired:truetype:google.firebase.database.ref.v1.created[...]

For more information, seegcloud eventarc providers describe.

Path pattern syntax

The path pattern syntax is defined as follows:

Path pattern syntax

Pattern/? Segment(/Segment)*
SegmentCaptureGroup|Expression
CaptureGroup{ID(=Expression)? }
ExpressionWildcard| MultiSegmentWildcard|NameSegment
NameSegment(Character*Wildcard?Character*)
ID[a-zA-Z0-9_]+
Wildcard*
MultiSegmentWildcard**
Character1[\\w\\s\\t~@#$%&.,?:;+='[]()-]

Legend:

?zero or one
*zero or more
+one or more
|OR
1 Only listed ASCII characters are supported.Regular expression matching is not supported. Supported metacharacters:
  • \w refers to a word; also represented as[a-zA-Z0-9_]
  • \t refers to a tab
  • \s refers to a whitespace character

Expressions

An expression can be one of the following segment types and cannot be empty:

  • A single segmentWildcard defined as* matches zero or more charactersin the pattern.
  • AMultiSegmentWildcard defined as** matches zero or more segmentsin the pattern.
  • ANameSegmentconsists of zero or one* and other characters. Thiscombination lets you filter by prefix, suffix, or file extension; forexample,file-*.txt.

Note that a path can contain many single segment wildcards, but onlyone multiple segment wildcard. For example, the following path is invalid:/projects/**/buckets/**.

Resource regionality

Resource names can contain location identifiers. For example:

/projects/$PROJECT_ID/locations/$REGION/triggers/my-trigger

However, path pattern matching is constrained by resource regionality. Forexample, for Cloud Audit Logs triggers, location wildcards only matchtriggers from the Cloud Audit Logs region, or global triggers.

Capture groups

ACaptureGroup lets you capture the content of an expression. You do thisby assigning the value to a variable name in braces; for example,buckets/{path=**}/files/{filename=file-*.txt}. A single segment wildcard canomit=* in a capture group; for example,/projects/_/buckets/{bucket}/objects/file.*

Note: Capture groups have no semantic meaning; only the syntax is supported.

Resource name format

The following table provides examples of full resource names for commonly usedGoogle Cloud services.It is not a complete list. To learn more about howfull resource names are formatted, see theResource names section of the API design guide.

Resource typeFull resource name format
BigQuerydatasets//bigquery.googleapis.com/projects/PROJECT_ID/datasets/DATASET_ID
Cloud Billingaccounts//cloudbilling.googleapis.com/billingAccounts/BILLING_ACCOUNT_ID
Cloud Firestoredocuments1//firestore.googleapis.com/projects/PROJECT_ID/databases/DATABASE_ID/documents/DOCUMENT
Cloud Runservices//run.googleapis.com/projects/PROJECT_ID/locations/LOCATION_ID/services/SERVICE_ID
Cloud SQLinstances//sqladmin.googleapis.com/projects/PROJECT_ID/instances/INSTANCE_ID
Cloud Storagebuckets2//storage.googleapis.com/projects/_/buckets/BUCKET_ID
Cloud Storageobjects2, 3//storage.googleapis.com/projects/_/buckets/BUCKET_ID/objects/OBJECT_ID
Compute Engineinstances//compute.googleapis.com/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_ID
Compute Enginenetworks//compute.googleapis.com/projects/PROJECT_ID/global/networks/NETWORK
Compute Enginesubnetworks//compute.googleapis.com/projects/PROJECT_ID/regions/REGION/subnetworks/SUBNETWORK
Google Kubernetes Engineclusters//container.googleapis.com/projects/PROJECT_ID/clusters/CLUSTER_ID
Identity-Aware ProxyApp Engine app service//iap.googleapis.com/projects/PROJECT_NUMBER/iap_web/appengine-PROJECT_ID/services/APP_SERVICE_ID
IAPCompute Engine backend service//iap.googleapis.com/projects/PROJECT_NUMBER/iap_web/compute/services/BACKEND_SERVICE_ID_OR_NAME
Pub/Subtopics//pubsub.googleapis.com/projects/PROJECT_ID/topics/TOPIC_ID
Resource Managerorganizations//cloudresourcemanager.googleapis.com/organizations/ORGANIZATION_NUMBER
Resource Managerfolders//cloudresourcemanager.googleapis.com/folders/FOLDER_NUMBER
Resource Managerprojects//cloudresourcemanager.googleapis.com/projects/PROJECT_ID

1 For Cloud Firestore, don't specify a leading slashwhen creating a trigger(seeexamples).For more information, seeCloud Firestore data model.

2 For Cloud Storage, resource names contain anunderscore (_) rather than a project ID. Youcannot replace the underscorewith a project ID, project name, or project number.

3 For Cloud Storage, use the entire object name, includingforward slashes. These characters arepart of the object name, not path separators.

Examples

The following examples demonstrate how you can and can't use the syntax.

Valid patterns

PatternDescription
/projects/project-1/datasets/dataset-1Specific resource name.
/projects/project-1/regions/region-1/subnetworks/*Matches any subnetwork inproject-1 andregion-1.
/projects/_/buckets/bucket-1/objects/*.txtMatches all TXT files in the bucket.
/projects/_/buckets/bucket-1/objects/file-*.txtMatches all TXT files with prefixfile- in the bucket.
/projects/project-1/serviceAccounts/service-account-email-1/keys/**Matches any key for a specific service account email.
/projects/_/**/file-*.txtMatches any TXT file with prefixfile- for all buckets.
/projects/_/buckets/bucket-*/objects/file-*.txtMatches all TXT files with prefixfile- for any bucket with prefixbucket-.
/projects/_/buckets/{bucket}/objects/file.*
/projects/_/buckets/{bucket=*}/objects/file.*
/projects/_/buckets/*/objects/{filename=file.*}
Three different representations of the same filter. Matches any bucket with a file namedfile of any type. The first two examples also capture the bucket and the last example captures the filename.
/projects/project-1/zones/zone-1/instances/**Matches anything inproject-1 andzone-1.
/projects/*/zones/zone-1/instances/**Matches anything inzone-1 in any project.

Invalid patterns

PatternDescription
/projects/_/buckets/bucket-1/objects/Empty expression.
/projects//buckets/bucket-1/objects/file1.txtEmpty expression.
/projects/_/buckets/bucket**/objects/file1.txtExpression can contain only one*.
/projects/_/buckets/bucket-1/objects/file-*.*Expression can contain only one*.
/projects/**/buckets/**Resource path can contain only one**.
/projects/_/buckets/{=*}/objects/file1.txtMissing ID in segment.
/projects/_/buckets/{bucket=}/objects/file1.txtEmpty expression inside a capture group.
/projects/_/buckets/{bucket/objects/file1.txtCapture group not closed.

Pattern matching

PatternResourceMatches?
/buckets/bucket-1/objects/file1.txt/buckets/bucket-1/objects/file1.txt
/buckets/bucket-1/objects/file2.txt
/buckets/bucket-1/objects/*/buckets/bucket-1/objects/file3.txt
/buckets/bucket-1/objects/file4.jpg
/buckets/bucket-1/objects/files/file4.jpg
/buckets/bucket-1/objects
/buckets/bucket-1/objects/*.txt/buckets/bucket-1/objects/file5.txt
/buckets/bucket-1/objects/file6.jpg
/buckets/bucket-1/objects/file-*.txt/buckets/bucket-1/objects/file-777.txt
/buckets/bucket-1/objects/file-.txt
/buckets/bucket-1/objects/file.txt
/projects/_/**/{filename=file-*.txt}/projects/_/objects/object-1/files/file-9.txt
/projects/_/{ob}jects/**/-+=*/file-9.txt
/projects/_/file-10.txt
/projects/_/files-1/file-1.txt/files-2/file-2.txt
/projects/_//file-1234.txt
/projects/_/files/file-5.txt/file.txt
{collection=[clients,users]}/idusers/id
clients/id
[clients,users]/id
{collection=clients,users}/idusers/id
clients/id
clients,users/id
all users/{id=.*_ +1@gmail.com}all-users/aa_ +1@gmail.com
all users/bb_+1@gmail.com
all users/cc +1@gmail.com

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.