This document describes the monitoring and observability features implemented in the profile repository.
The monitoring system provides:
- Workflow Metrics Tracking - Record and analyze workflow execution metrics
- Status Page - Visual dashboard showing system health
- Automated Alerts - Automatic issue creation for repeated failures
- Data Quality Checks - Validation and logging of data quality issues
Each workflow execution is tracked with the following metrics:
- Run Time: Duration of workflow execution in seconds
- Success/Failure Status: Whether the workflow completed successfully
- Consecutive Failures: Count of consecutive failed runs
- Success Rate: Percentage of successful runs
- API Call Counts: Number of calls to external APIs
- Run History: Last 20 workflow executions with timestamps
Workflows can record metrics using the record-workflow-metrics.py script:
# Record a successful run
python scripts/record-workflow-metrics.py oura --success --run-time 120.5
# Record a failed run
python scripts/record-workflow-metrics.py oura --failure --error-message "API timeout"
# Include API call counts
python scripts/record-workflow-metrics.py weather --success --run-time 45.2 \
--api-calls '{"openweather": 2, "geocoding": 1}'Metrics are stored as JSON files in data/metrics/:
data/metrics/
├── oura.json
├── weather.json
├── developer.json
└── ...
Each metrics file contains:
{
"workflow_name": "oura",
"total_runs": 10,
"successful_runs": 9,
"failed_runs": 1,
"consecutive_failures": 0,
"last_success": "2025-12-03T12:00:00Z",
"last_failure": "2025-12-02T10:00:00Z",
"last_run_time_seconds": 120.5,
"avg_run_time_seconds": 115.3,
"api_calls": {
"oura": 15,
"github": 5
},
"run_history": [...]
}The status page provides a visual dashboard showing the health of all workflows.
python scripts/generate-status-page.py data/status/status-page.svgThe status page displays:
- Status Indicator: Green (success), yellow (warning), or red (error)
- Workflow Name: Name of each monitored workflow
- Last Success: Time since last successful run
- Last Failure: Time since last failure (with consecutive count)
- Success Rate: Percentage of successful runs
- Success (🟢): No recent failures
- Warning (🟡): 1-2 consecutive failures
- Error (🔴): 3+ consecutive failures
The monitoring workflow automatically creates GitHub Issues when a workflow has 3 or more consecutive failures.
The .github/workflows/monitoring.yml workflow:
- Runs on a schedule (hourly)
- Checks metrics for all workflows
- Creates an issue if consecutive failures ≥ 3
- Includes detailed metrics and run history in the issue
Automatically created issues include:
- Current metrics (consecutive failures, success rate)
- Recent run history (last 5 runs)
- Recommended actions for investigation
- Links to workflow runs
The system checks for existing open issues before creating new ones, preventing duplicate alerts for the same workflow.
Data quality validation helps ensure workflow outputs meet expected standards.
# Basic validation
python scripts/validate-data-quality.py data.json \
--required-fields name score value \
--context "oura metrics"
# With range validation
python scripts/validate-data-quality.py oura/metrics.json \
--required-fields sleep_score readiness_score \
--ranges '{"sleep_score": {"min": 0, "max": 100}}' \
--context "oura health data"- Missing Fields: Detects required fields that are absent
- NaN/Null Values: Identifies invalid numeric values
- Range Validation: Checks if values are within expected bounds
Data quality issues are logged to stderr with warnings:
⚠️ DATA_QUALITY: Missing required field 'score' in oura health data
⚠️ DATA_QUALITY: NaN value in field 'readiness' in weather data
⚠️ DATA_QUALITY: Value 150 in field 'score' is above maximum 100 in metrics
- name: Fetch Oura Data
id: fetch
run: |
START_TIME=$(date +%s)
if scripts/fetch-oura.sh > oura/metrics.json; then
END_TIME=$(date +%s)
RUN_TIME=$((END_TIME - START_TIME))
python scripts/record-workflow-metrics.py oura \
--success \
--run-time $RUN_TIME \
--api-calls '{"oura": 3}'
else
END_TIME=$(date +%s)
RUN_TIME=$((END_TIME - START_TIME))
python scripts/record-workflow-metrics.py oura \
--failure \
--run-time $RUN_TIME \
--error-message "Failed to fetch Oura data"
exit 1
fi
- name: Validate Data Quality
if: success()
run: |
python scripts/validate-data-quality.py oura/metrics.json \
--required-fields sleep_score readiness_score activity_score \
--ranges '{"sleep_score": {"min": 0, "max": 100}, "readiness_score": {"min": 0, "max": 100}}' \
--context "Oura health metrics"record_workflow_run(workflow_name, success, run_time_seconds=None, api_calls=None, error_message=None)
Record a workflow execution and update metrics.
Parameters:
workflow_name(str): Name of the workflowsuccess(bool): Whether the run was successfulrun_time_seconds(float, optional): Duration in secondsapi_calls(dict, optional): API endpoint call countserror_message(str, optional): Error message if failed
Returns: Updated metrics dictionary
Check if consecutive failures exceed threshold.
Returns: True if threshold exceeded, False otherwise
Perform comprehensive data quality validation.
Parameters:
data(dict): Data dictionary to validaterequired_fields(list, optional): Required field namesnumeric_ranges(dict, optional): Range specifications for numeric fieldscontext(str): Description for logging
Returns: Validation results dictionary with:
is_valid(bool): Overall validation statusmissing_fields(list): Missing required fieldsnan_fields(dict): Fields with NaN valuesout_of_range(dict): Fields with out-of-range values
The monitoring workflow (.github/workflows/monitoring.yml) runs automatically:
- Schedule: Every hour
- Triggers: After any workflow completion
- Actions:
- Generate updated status page
- Check for consecutive failures
- Create issues for repeated failures
- Commit metrics and status page
Add metrics recording to every workflow to enable comprehensive monitoring:
- name: Record Success
if: success()
run: python scripts/record-workflow-metrics.py <workflow-name> --success
- name: Record Failure
if: failure()
run: python scripts/record-workflow-metrics.py <workflow-name> --failureAdd data quality checks for important workflow outputs:
- name: Validate Output
run: |
python scripts/validate-data-quality.py output.json \
--required-fields <fields> \
--context "<workflow> output"Include the status page in your README or documentation to provide visibility into system health.
When an automated issue is created:
- Review the workflow runs linked in the issue
- Check for recent changes to the workflow or dependencies
- Verify external service status (APIs, secrets)
- Fix the underlying issue
- Close the issue once resolved
Problem: Metrics are not being recorded for a workflow.
Solution:
- Ensure
record-workflow-metrics.pyis called in the workflow - Check that the script has execute permissions
- Verify the workflow has
contents: writepermission
Problem: Status page shows outdated information.
Solution:
- Check that the monitoring workflow is running on schedule
- Verify metrics files exist in
data/metrics/ - Ensure the workflow can commit changes to the repository
Problem: Issues are created for transient failures.
Solution:
- The threshold is set to 3 consecutive failures by default
- Adjust the threshold in
monitoring.ymlif needed - Implement retry logic in workflows for transient errors
Potential improvements to the monitoring system:
- Metrics aggregation and trending over time
- Slack/email notifications for failures
- Performance dashboards with charts
- Anomaly detection for unusual patterns
- Custom alerting rules per workflow
- Integration with external monitoring tools