You can create search queries of the graph database in Tanzu Platform to locate particular resources you can work with in Tanzu Platform.
Property conditions
Your resource configurations are stored as properties and values of the resource object. For example, running EC2 instances have a property StateName
with value running
.
To locate resources with specific configurations, you can use the following property conditions.
Condition | Syntax | Description |
---|---|---|
property with a value | pname = pvalue | Property with name pname has value equal to pvalue. |
property different than a value | pname != pvalue | Property with name pname has value different than pvalue. |
property exists | pn(pname) or propertyName(pname) | There is a property with name pname. |
property value exists | pv(pvalue) or propertyValue(pvalue) | There is a property with value pvalue. |
To apply the property conditions in your searches, use the following operators.
The operators are case-insensitive. The operator HAS and has might both be used.
Operator | Usage |
---|---|
HAS | Apply one or more conditions to a resource type. |
AND | Group conditions when all of them must be satisfied. |
OR | Group conditions when at least one of them must be satisfied. |
NOT | Reverse a condition. |
() | Specify the order in which conditions are evaluated. |
Tag condition
The tags you configure in your cloud provider can be accessed with the tag prefix. For example, use tag.createdBy
to access the tag with name createdBy
.
To locate resources by tag, you specify the following tag conditions.
Condition | Syntax | Description |
---|---|---|
tag with a value | tag.tagname = tagvalue | Tag with name tagname has value equal to tagvalue. |
tag different than a value | tag.tagname != tagvalue | Tag with name tagname has value different than tagvalue. |
tag exists | tag.tagname | There is a tag with name tagname. |
tag value exists | tag = tagvalue | There is a tag with value tagvalue. |
Tag conditions are applied using the same operators as property conditions and can be mixed and matched with property conditions.
Comparison operators with date and time functions
Comparison operators (<=, <, >, =>) are available for integer and datetime properties. In addition, some special date and time functions are available to construct dates easily.
Syntax | Description |
---|---|
hoursAgo(n) | Returns the time n hours earlier than now. |
daysAgo(n) | Returns the time n days earlier than now. |
monthsAgo(n) | Returns the time n months earlier than now. |
yearsAgo(n) | Returns the time n years earlier than now. |
Wildcards
To find resource matching a pattern, use the wildcard operator * (asterisk) in your query to match any string. You can use the operator in property names, property values, tag names, and tag values.
If you must search for the asterisk symbol as a value in a query, surround the string in double quotes to avoid the symbol having any special meaning. If the string itself contains double quotes, escape them with a backslash.
Statement type | Syntax | Description |
---|---|---|
begins with | abc* | Begins with “abc” |
ends with | *abc | Ends with “abc” |
begins and ends | abc*xyz | Begins with “abc” and ends with “xyz” |
Search for related resources
To find related resources use the relationship operator -> to search for relationships between two sets of resources. To locate resources that are not related, use the inverted relationship operator !->.
Count search results
To count the results of a search, add count(pname) at the end of the search query. This type of aggregation is supported for queries that don’t include the relationship operator.
Double quotes syntax rules
The usage of double quotes around strings is optional in most cases. However, you must enter double quotes if the string contains special characters that might cause ambiguity during parsing.
Query | Description |
---|---|
tag.Project = Stardeck | Equivalent to tag.Project = “Stardeck”. Double quotes are not required. |
tag.Project = “Stardeck(1)” | Double quotes are required because of the brackets. Otherwise the query is invalid. |
tag.Description = “This is a description with spaces” | Double quotes are required because of the spaces. |
tag.Description = “This is a description with spaces and special characters !@#$%^&*()_+[]” | Double quotes are required so that each of the special characters is interpreted literally. |
tag.Description = “This is a description with spaces and "quotes"” | Double quotes are required and the quotes must be escaped with a backslash. |
Content feedback and comments