Subscriptions
Subscriptions schedule when queries execute and who receives notifications.
Purpose
Subscriptions allow you to:
- Schedule queries with cron expressions
- Define execution frequency (hourly, daily, weekly, custom)
- Specify query timeout limits
- Configure notification recipients
- Control result storage
- Override query parameters
Use Cases
- Hourly Health Checks: Monitor system metrics every hour
- Daily Reports: Generate and deliver reports each morning
- Weekly Summaries: Aggregate weekly performance data
- On-Demand Alerts: Frequent checks for critical thresholds (every 5-15 minutes)
- Monthly Reports: End-of-month business analytics
Creating a Subscription
Step 1: Navigate to Subscriptions
- Click Subscriptions in the left navigation
- Click Create New Subscription
Step 2: Fill Subscription Details
| Field | Description | Required | Example |
|---|---|---|---|
| Name | Descriptive name | Yes | Daily User Count Report |
| Description | Purpose and audience | No | Sent to DevOps team every morning |
| Query | Query to execute | Yes | Select from dropdown |
| Cron Expression | Execution schedule | Yes | 0 9 * * * |
| Timeout | Max execution time (seconds) | Yes | 60 |
| Store Results | Save to history | No | ✓ Recommended |
| Send Notifications | Notify recipients | No | ✓ If recipients added |
Step 3: Configure Cron Schedule
The cron expression determines when the query runs.
Format:
* * * * *
│ │ │ │ │
│ │ │ │ └─── Day of week (0-7, 0 and 7 = Sunday)
│ │ │ └───── Month (1-12)
│ │ └─────── Day of month (1-31)
│ └───────── Hour (0-23)
└─────────── Minute (0-59)
Common expressions:
| Expression | Description | Frequency |
|---|---|---|
*/5 * * * * |
Every 5 minutes | 288 times/day |
0 * * * * |
Every hour, on the hour | 24 times/day |
0 */6 * * * |
Every 6 hours | 4 times/day |
0 9 * * * |
Daily at 9:00 AM | 1 time/day |
0 9 * * 1 |
Every Monday at 9:00 AM | 1 time/week |
0 9 1 * * |
First day of month at 9:00 AM | 1 time/month |
0 9 * * 1-5 |
Weekdays at 9:00 AM | 5 times/week |
Help: Hover over the cron expression field in Semantico to see a human-readable description. Or use crontab.guru for assistance.
Step 4: Set Timeout
The timeout determines maximum query execution time.
Guidelines:
- Simple queries: 30-60 seconds
- Complex aggregations: 120-300 seconds
- Long-running reports: 300-600 seconds
Queries exceeding timeout will be cancelled and marked as failed in execution history.
Step 5: Add Recipients
- In the Recipients section, click Add Recipient
- Select recipients from the list
- Click Save
📚 Learn more about Recipients →
Step 6: Configure Parameters (if applicable)
If your query uses parameters (e.g., ``), you’ll see a Parameters section:
- For each parameter, provide a value or expression
- Use static values:
2025-01-01 - Or use dynamic expressions:
NOW() - INTERVAL '7 days'
📚 Learn more about Query Parameters →
Step 7: Save Subscription
Click Save to create the subscription.
The subscription will execute automatically according to your cron schedule.
Managing Subscriptions
View Subscriptions
The Subscriptions page shows:
- Subscription name and query
- Cron schedule (human-readable)
- Next execution time
- Last execution status
- Enabled/disabled state
- Actions (Edit, Execute Now, Disable, Delete)
Execute Manually
Test a subscription without waiting for the schedule:
- Click Execute Now (play icon) on the subscription row
- Execution runs immediately
- Check notification delivery
- Review execution history
Manual executions don’t affect the cron schedule. Scheduled executions continue as configured.
Enable/Disable Subscription
Temporarily pause a subscription:
- Click Disable (pause icon) on the subscription row
- Subscription stops executing on schedule
- Click Enable to resume
Use cases for disabling:
- Maintenance windows
- Database migrations in progress
- Recipient is out of office
- Query needs modification
Edit Subscription
- Click Edit (pencil icon) on the subscription row
- Modify schedule, timeout, or recipients
- Click Save
Changes take effect on the next scheduled execution.
Delete Subscription
- Click Delete (trash icon) on the subscription row
- Confirm deletion
- Subscription is archived (soft delete)
Execution history is preserved even after subscription deletion.
Advanced Scheduling
Business Hours Only
Weekdays, 9 AM to 5 PM:
0 9-17 * * 1-5
Executes every hour from 9 AM to 5 PM, Monday through Friday.
Multiple Times Per Day
At 9 AM, 1 PM, and 5 PM:
0 9,13,17 * * *
Every N Minutes During Specific Hours
Every 15 minutes between 8 AM and 6 PM:
*/15 8-18 * * *
End of Month
Last day of month at 11 PM:
0 23 L * *
Note: Standard cron doesn’t support
L(last day). Use0 23 28-31 * *and handle logic in query.
Quarterly Reports
First day of quarter at 9 AM:
0 9 1 1,4,7,10 *
Runs January 1, April 1, July 1, and October 1.
Subscription Parameters
Static Parameter Values
Provide fixed values for parameters:
Parameter: threshold
Value: 100
Query:
SELECT COUNT(*) as high_value_transactions
FROM transactions
WHERE amount >
Dynamic Parameter Expressions
Use SQL expressions for dynamic values:
Parameter: start_date
Value: CURRENT_DATE - INTERVAL '7 days'
Parameter: end_date
Value: CURRENT_DATE
Query:
SELECT DATE(created_at) as date, COUNT(*) as orders
FROM orders
WHERE created_at >= ''
AND created_at < ''
GROUP BY DATE(created_at)
Execution Behavior
When Subscriptions Run
Semantico uses your configured ISemanticoScheduler implementation for job scheduling:
- Cron expressions are evaluated according to your scheduler configuration
- Execution timing depends on your scheduler implementation
- Multiple subscriptions can execute concurrently (depending on scheduler worker configuration)
Execution Order
When multiple subscriptions trigger simultaneously:
- Executions run in parallel (worker pool)
- Default worker count: CPU core count
- Long-running queries don’t block others
Failure Handling
If a query execution fails:
- Error is logged in execution history
- Notification includes error message
- Next scheduled execution still occurs
- No automatic retries (prevent cascading failures)
Monitoring Subscriptions
Execution History
View all past executions:
- Click Notifications in left navigation
- Filter by subscription or date range
- Review:
- Execution timestamp
- Query results
- Recipients notified
- Delivery status
- Errors (if any)
Next Execution Time
The Subscriptions page shows:
- Next Run: When subscription will execute next
- Last Run: When it last executed
- Status: Success, Failed, or Pending
Use this to verify cron expressions are correct.
Examples
Example 1: Hourly Health Check
Subscription:
- Name:
Database Connection Monitor - Query:
Check Active Connections - Cron:
0 * * * *(every hour) - Timeout: 30 seconds
- Recipients: DevOps Team (Teams)
Purpose: Alert if connection count approaches limit.
Example 2: Daily Morning Report
Subscription:
- Name:
Yesterday's Sales Summary - Query:
Daily Revenue Report - Cron:
0 8 * * *(every day at 8 AM) - Timeout: 120 seconds
- Recipients: Sales Team (Email with CSV)
Purpose: Deliver overnight sales data to management.
Example 3: Critical Alert (Every 5 Minutes)
Subscription:
- Name:
Critical Error Monitor - Query:
Recent Critical Errors - Cron:
*/5 * * * *(every 5 minutes) - Timeout: 30 seconds
- Recipients: On-Call Engineer (Teams + Email)
Purpose: Immediate notification of production errors.
Example 4: Weekly Summary (Monday Mornings)
Subscription:
- Name:
Weekly User Growth Report - Query:
New Users Last Week - Cron:
0 9 * * 1(Monday at 9 AM) - Timeout: 60 seconds
- Recipients: Product Team (Email)
Purpose: Weekly tracking of user acquisition.
Troubleshooting
Subscription Not Executing
Check:
- Subscription is enabled (not paused)
- Cron expression is valid
- Next execution time shows correct schedule
- Your job scheduler service is running
Verify Scheduler: Check application logs for your scheduler service status and any errors.
Execution Timeout
If queries consistently timeout:
- Increase timeout setting
- Optimize query performance (add indexes)
- Reduce result set size
- Split into multi-step query
Missing Notifications
Check:
- Recipients are added to subscription
- “Send Notifications” is enabled
- Notification delivery status in history
- Recipient configuration (email, Teams webhook)
Review notification history:
- Click Notifications
- Find failed delivery
- Check error message
Related Documentation
- Queries - Create and manage queries
- Recipients - Configure notification targets
- Query Parameters - Use dynamic values
- Notifications - Understand notification delivery
- Troubleshooting - Common subscription issues