| name | visibility-search |
| description | This skill should be used when the user asks about "search attributes", "temporal search", "list workflows", "visibility query", "elasticsearch temporal", "find workflow", "workflow filter", or needs guidance on searching and filtering Temporal workflows. |
| version | 1.0.0 |
Visibility and Search
Guidance for searching and filtering Temporal workflows using visibility features.
Visibility Overview
Temporal visibility allows searching workflows by:
- Standard attributes - Built-in fields (status, type, time)
- Custom search attributes - User-defined indexed fields
Visibility Stores
| Store | Features | Use Case |
|---|
| Standard (SQL) | Basic queries | Development, small scale |
| Advanced (Elasticsearch) | Full queries, aggregations | Production, complex queries |
Standard Attributes
Built-in searchable attributes:
| Attribute | Type | Description |
|---|
WorkflowId | Keyword | Workflow identifier |
RunId | Keyword | Run identifier |
WorkflowType | Keyword | Workflow function name |
ExecutionStatus | Keyword | Running, Completed, Failed, etc. |
StartTime | Datetime | When workflow started |
CloseTime | Datetime | When workflow completed |
ExecutionDuration | Int | Duration in milliseconds |
TaskQueue | Keyword | Task queue name |
Query Syntax
Basic Queries
ExecutionStatus = 'Running'
ExecutionStatus = 'Failed'
ExecutionStatus = 'Completed'
ExecutionStatus = 'Terminated'
ExecutionStatus = 'TimedOut'
WorkflowType = 'OrderWorkflow'
WorkflowId = 'order-12345'
TaskQueue = 'order-processing'
Time-Based Queries
StartTime > '2024-01-01T00:00:00Z'
StartTime BETWEEN '2024-01-01' AND '2024-01-31'
CloseTime > '2024-01-15T00:00:00Z'
ExecutionDuration > 3600000
Compound Queries
WorkflowType = 'OrderWorkflow' AND ExecutionStatus = 'Failed'
ExecutionStatus = 'Failed' OR ExecutionStatus = 'TimedOut'
(WorkflowType = 'OrderWorkflow' OR WorkflowType = 'PaymentWorkflow')
AND ExecutionStatus = 'Running'
AND StartTime > '2024-01-01'
ORDER BY
ORDER BY StartTime DESC
ORDER BY WorkflowType ASC, StartTime DESC
CLI Usage
List with Query
temporal workflow list --query "ExecutionStatus='Running'"
temporal workflow list \
--query "WorkflowType='OrderWorkflow' AND ExecutionStatus='Failed'"
temporal workflow list \
--query "ExecutionStatus='Failed' AND CloseTime > '2024-01-15'" \
--limit 20
temporal workflow list \
--query "ExecutionStatus='Running'" \
--output json
timelord CLI
timelord workflow list --query "ExecutionStatus='Failed'" --limit 10 --json
Custom Search Attributes
Creating Attributes
temporal operator search-attribute create \
--namespace default \
--name CustomerId \
--type Keyword
temporal operator search-attribute create \
--namespace default \
--name Description \
--type Text
temporal operator search-attribute create \
--namespace default \
--name OrderTotal \
--type Double
temporal operator search-attribute create \
--namespace default \
--name ItemCount \
--type Int
temporal operator search-attribute create \
--namespace default \
--name IsPriority \
--type Bool
temporal operator search-attribute create \
--namespace default \
--name DueDate \
--type Datetime
temporal operator search-attribute create \
--namespace default \
--name Tags \
--type KeywordList
Setting Attributes in Workflow
At workflow start:
options := client.StartWorkflowOptions{
ID: "order-12345",
TaskQueue: "orders",
SearchAttributes: map[string]interface{}{
"CustomerId": "cust-789",
"OrderTotal": 99.99,
"IsPriority": true,
"Tags": []string{"electronics", "express"},
},
}
we, err := c.ExecuteWorkflow(ctx, options, OrderWorkflow, order)
During workflow execution:
func OrderWorkflow(ctx workflow.Context, order Order) error {
err := workflow.UpsertSearchAttributes(ctx, map[string]interface{}{
"OrderStatus": "processing",
"ItemCount": len(order.Items),
})
if err != nil {
return err
}
return nil
}
Querying Custom Attributes
CustomerId = 'cust-789'
OrderTotal >= 100.00 AND OrderTotal < 500.00
IsPriority = true
Tags = 'electronics'
WorkflowType = 'OrderWorkflow'
AND CustomerId = 'cust-789'
AND ExecutionStatus = 'Running'
Common Query Patterns
Debugging Queries
ExecutionStatus = 'Failed'
AND CloseTime > '2024-01-15T00:00:00Z'
ExecutionStatus = 'Running'
AND StartTime < '2024-01-15T10:00:00Z'
ExecutionStatus = 'Terminated'
AND CloseTime > '2024-01-14'
Business Queries
OrderTotal > 1000 AND ExecutionStatus = 'Running'
CustomerId = 'cust-123'
IsPriority = true AND DueDate < '2024-01-16'
Region = 'US-WEST' AND WorkflowType = 'OrderWorkflow'
Operations Queries
TaskQueue = 'critical-processing'
ExecutionDuration > 86400000
InitiatingService = 'api-gateway'
Elasticsearch Setup
Why Elasticsearch?
| Feature | Standard SQL | Elasticsearch |
|---|
| Basic queries | ✓ | ✓ |
| ORDER BY | Limited | ✓ |
| COUNT queries | Limited | ✓ |
| Full-text search | ✗ | ✓ |
| Aggregations | ✗ | ✓ |
| Performance at scale | Limited | Excellent |
Configuration
Helm values for Elasticsearch:
elasticsearch:
enabled: true
replicas: 3
server:
config:
persistence:
advancedVisibilityStore: es-visibility
Verification
temporal operator cluster describe
temporal operator search-attribute list
Best Practices
Search Attribute Design
| Do | Don't |
|---|
| Index frequently queried fields | Index everything |
| Use appropriate types | Store JSON as Keyword |
| Plan attributes upfront | Add attributes ad-hoc |
| Keep names consistent | Use inconsistent naming |
Query Optimization
| Do | Don't |
|---|
| Use indexed fields | Scan all workflows |
| Add time bounds | Open-ended time queries |
| Limit results | Fetch unlimited rows |
| Use specific conditions | Use OR excessively |
Naming Conventions
CustomerId # Keyword - entity reference
OrderTotal # Double - numeric value
IsPriority # Bool - flag
ProcessingStage # Keyword - enum value
Tags # KeywordList - multiple values
Description # Text - searchable content
DueDate # Datetime - temporal value
Troubleshooting
Query Returns No Results
- Check attribute exists:
temporal operator search-attribute list
- Verify attribute type matches query
- Check time zone in datetime queries
- Verify workflow actually set the attribute
Slow Queries
- Add time bounds to queries
- Reduce result limits
- Use more specific conditions
- Consider Elasticsearch for complex queries
Attribute Not Searchable
- Confirm attribute was created before workflow started
- Verify attribute name spelling
- Check namespace context
Additional Resources
Reference Files
For detailed search patterns, consult:
references/query-examples.md - Common query patterns
references/elasticsearch-setup.md - Advanced ES configuration