The UModel Platform as a Service (PaaS) interface offers a comprehensive set of tools for debugging and optimization. These tools help developers quickly locate issues, optimize query performance, and ensure stable system operation.
1. DryRun mode
1.1 DryRun overview
DryRun mode is a core debugging feature of the UModel PaaS interface. It lets you preview the Structured Process Language (SPL) generated by a query without actually executing it. This is useful for the following tasks:
Query preview: View the final generated SPL search statement.
SPL validation: Verify that the transformation logic and field mappings are correct.
Debugging and analysis: Quickly locate issues in the transformation process.
Learning and understanding: Understand the mechanism that transforms UModel abstractions into the underlying SPL.
1.2 How to use DryRun
Basic syntax
Add the DryRun setting before any UModel PaaS query:
.set "umodel_paas_mode"='dry_run';
-- Your UModel PaaS query
Phase 1 Table pattern example
.set "umodel_paas_mode"='dry_run';
.metric_set with(
domain='apm',
name='apm.metric.apm.service',
source='metrics',
metric='request_count',
query='service_id = "order-service"'
)
Response:
.metricstore with(region='cn-hangzhou', project='cms-cms-umodel-paas-0620-kffw8bjagidkeyc2', metricstore='metricstore-apm')
| prom-call promql_query_range('sum by (acs_arms_service_id) (rate(arms_app_requests_count_raw{acs_arms_service_id="order-service"}[1m]))', '1m')
Phase 2 Object pattern example
.set "umodel_paas_mode"='dry_run';
.entity_set with(domain='apm', name='apm.service', ids=['1ab40caaf6xa707e6'])
| entity-call get_golden_metrics()
Response:
.let golden_metric_request_count_1=.metricstore with(project='proj-xtrace-xx-ap-southeast-3', metricstore='metricstore-apm-metrics') | prom-call promql_query_range('sum(sum_over_time_lcro(arms_app_requests_count_ign_destid_endpoint_parent_ppid_prpc_rpc{acs_arms_service_id="hwx28v3j7p@xx",callKind=~"http|rpc|custom_entry|server|consumer|schedule",service="payment"}[1m]))') | extend metric = 'request_count', metric_set_id = 'apm@metric_set@apm.metric.apm.service'; .let golden_metric_error_count_2=.metricstore with(project='proj-xtrace-xx-ap-southeast-3', metricstore='metricstore-apm-metrics') | prom-call promql_query_range('sum(sum_over_time_lcro(arms_app_requests_error_count_ign_destid_endpoint_parent_ppid_prpc_rpc{acs_arms_service_id="hwx28v3j7p@xx",callKind=~"http|rpc|custom_entry|server|consumer|schedule",service="payment"}[1m]))') | extend metric = 'error_count', metric_set_id = 'apm@metric_set@apm.metric.apm.service'; .let golden_metric_avg_request_latency_seconds_3=.metricstore with(project='proj-xtrace-xx-ap-southeast-3', metricstore='metricstore-apm-metrics') | prom-call promql_query_range('sum(sum_over_time_lcro(arms_app_requests_seconds_ign_destid_endpoint_parent_ppid_prpc_rpc{acs_arms_service_id="hwx28v3j7p@xx",callKind=~"http|rpc|custom_entry|server|consumer|schedule",service="payment"}[1m])) / sum(sum_over_time_lcro(arms_app_requests_count_ign_destid_endpoint_parent_ppid_prpc_rpc{acs_arms_service_id="hwx28v3j7p@xx",callKind=~"http|rpc|custom_entry|server|consumer|schedule",service="payment"}[1m]))') | extend metric = 'avg_request_latency_seconds', metric_set_id = 'apm@metric_set@apm.metric.apm.service'; $golden_metric_request_count_1 | union $golden_metric_error_count_2, $golden_metric_avg_request_latency_seconds_3
1.3 DryRun debugging techniques
1.3.1 Field mapping validation
Use DryRun to check whether the field mappings are correct:
.set "umodel_paas_mode"='dry_run';
-- Check how entity IDs are mapped to storage fields through property information
.entity_set with(domain='apm', name='apm.service', id=['1ab40caaf6xa707e6'])
| entity-call get_metric('apm', 'apm.metric.apm.service', 'request_count')
-- Check how entity query fields are mapped to storage fields
.entity_set with(domain='apm', name='apm.service', query='service = "order-service"')
| entity-call get_metric('apm', 'apm.metric.apm.service', 'request_count')
Verify that the field mapping rules in the returned SPL are applied as expected.
1.3.2 Filter condition check
Verify the transformation of complex filter conditions:
.set "umodel_paas_mode"='dry_run';
.entity_set with(domain='apm', name='apm.service',
query='service_id = "order-service" and region = "cn-hangzhou"')
| entity-call get_metric('apm', 'apm.metric.apm.service', 'request_count')
Verify that the filter conditions in the generated SPL are complete and correct.
1.3.3 Relational query debugging
Verify the field mappings for entity relational queries:
.set "umodel_paas_mode"='dry_run';
.entity_set with(domain='apm', name='apm.service', query='service = "service-a"')
| entity-call get_relation_golden_metrics(
'apm', 'apm.service', [], 'service = "service-b"',
'calls', 'out', 'range', '5m')
Verify that the filter conditions for the source and target entities are combined correctly.
1.4 DryRun best practices
Verify step-by-step: Start with simple queries and gradually increase complexity.
Compare and verify: Compare the DryRun results with the expected SPL.
Check fields: Focus on checking the mapping of custom fields.
Estimate performance: Evaluate the query complexity based on the generated SPL.
2. Performance optimization
2.1 Query plan optimization
2.1.1 Filter condition optimization
Best practice: Provide precise filter conditions to reduce the amount of data scanned and improve query response speed.
Note: If you are using the phase 2 pattern, specify the entity IDs for the query using `ids` whenever possible. This allows UModel to handle the query transformation.
.profile_set with(
domain='apm',
name='apm.profile.cpu',
query='service_id = "order-service" and profile_type = "cpu"'
)
.entity_set with(domain='apm', name='apm.service', id=['1ab40caaf6xa707e6'])
| entity-call get_metric('apm', 'apm.metric.apm.service', 'request_count')
2.1.2 Metric pattern step size settings
Set a reasonable time step size for the metric pattern:
Note: Do not manually set the step size unless necessary. The built-in step size logic in UModel automatically selects an appropriate step size based on the query time range and data volume.
Query time range | Recommended step size | Description |
Within 1 hour | 1m | Precise analysis |
1 to 6 hours | 3m | Balances precision and performance |
6 to 24 hours | 5m | Trend analysis |
1 to 7 days | 1h | Long-term trends |
More than 7 days | 6h or 1d | Coarse-grained analysis |
2.1.3 Aggregation policy optimization
For metric-based queries, prioritize using aggregation methods. Otherwise, the query may return a large amount of data and adversely affect the response time.
-- Recommended: Use an aggregation method. To get a specific dimension, specify the aggregation dimension.
.metric_set with(
domain='apm',
name='apm.metric.apm.service',
source='metrics',
metric='request_count',
aggregate=true, -- Do not specify a dimension. Aggregate all metrics into a single line.
)
.metric_set with(
domain='apm',
name='apm.metric.apm.service',
source='metrics',
metric='request_count',
aggregate=true,
aggregate_labels=['region'] -- Aggregate only the necessary dimensions.
)
-- Not recommended: Do not aggregate. This returns all dimension combinations and results in a large amount of data.
.metric_set with(
domain='apm',
name='apm.metric.apm.service',
source='metrics',
metric='request_count',
aggregate=false -- Returns all dimension combinations.
)
2.2 Cache policy
2.2.1 Method list cache
-- Cache the entity method list (relatively stable)
.entity_set with(domain='apm', name='apm.service')
| entity-call __list_method__()
Cache policy:
Cache duration: 1 to 24 hours.
Invalidation condition: UModel configuration updates.
Scenario: Frequent method discovery calls.
2.2.2 Query result cache
Queries suitable for caching:
-- Relatively stable configuration query
.entity_set with(domain='apm', name='apm.service')
| entity-call list_data_set(['metric_set'], true)
-- Tag value query (changes infrequently)
.entity_set with(domain='apm', name='apm.service')
| entity-call get_label_values('apm', 'apm.metric.apm.service', 'region')
Cache policy:
Cache duration: 5 to 60 minutes.
Invalidation conditions: Data updates or configuration changes.
Scenario: High-frequency, repetitive queries.
3. Debugging toolset
3.1 Configuration check tool
-- Check the integrity of the UModel configuration
.entity_set with(domain='apm', name='apm.service')
| entity-call __inspect__(
check_data_sets=true,
check_links=true,
check_field_mappings=true,
check_metrics=true
)
3.2 Method discovery tool
-- Discover available methods
.entity_set with(domain='apm', name='apm.service')
| entity-call __list_method__()
-- Discover associated datasets
.entity_set with(domain='apm', name='apm.service')
| entity-call list_data_set(['metric_set'], true)
-- Discover related entities
.entity_set with(domain='apm', name='apm.service')
| entity-call list_related_entity_set(['contains'], 'out')
3.3 Step-by-step debugging flow
Step 1: Verify the basic configuration
-- 1. Check if the entity exists
.entity_set with(domain='apm', name='apm.service')
| entity-call get_entity_set()
-- 2. Check the associated dataset
.entity_set with(domain='apm', name='apm.service')
| entity-call list_data_set()
Step 2: Test a simple query
-- 3. Test a basic method call
.set "umodel_paas_mode"='dry_run';
.entity_set with(domain='apm', name='apm.service')
| entity-call __list_method__()
Step 3: Gradually increase complexity
-- 4. Add a filter condition
.set "umodel_paas_mode"='dry_run';
.entity_set with(domain='apm', name='apm.service', query='service_id = "order-service"')
| entity-call get_golden_metrics()
-- 5. Test a relational query
.entity_set with(domain='apm', name='apm.service', query='service_id = "order-service"')
| entity-call get_relation_golden_metrics('apm', 'apm.operation', [], '', 'contains', 'out')
4. Best practices summary
4.1 Development phase
Use DryRun first: During development, prioritize using DryRun to verify query logic.
Build incrementally: Start with simple queries and gradually increase complexity.
Test thoroughly: Test border conditions and abnormal scenarios.
4.2 Production environment
Performance monitoring: Continuously monitor query performance metrics.
Resource control: Set reasonable concurrent limits and timeout periods.
Cache optimization: Utilize the query result cache.
4.3 Fault handling
Quickly locate issues: Use DryRun and configuration checks to quickly identify the source of an issue.
Log analysis: Analyze system logs to determine the cause of failures.
Tiered handling: Adopt different handling policies based on the severity of the issue.