{"overview":"# Monitoring Service Documentation\n\n## Overview\n\nThe **Monitoring Service** for the Vivified platform is designed to provide real-time metrics and monitoring capabilities to ensure system reliability and compliance with HIPAA regulations. This service collects, aggregates, and exposes metrics using Prometheus, making it easier to monitor the health and performance of the platform.\n\n!!! note\n This service is compliant with HIPAA regulations, ensuring that all monitoring activities respect the privacy and security of protected health information (PHI).\n\n## Architecture\n\nThe Monitoring Service is built using the FastAPI framework and integrates with Prometheus for metrics collection.\n\n```mermaid\ngraph TD;\n A[User Request] -->|API Call| B[FastAPI Application];\n B --> C{Metrics Collection};\n C -->|Record Duration| D[Histogram: request_duration];\n C -->|Track Plugins| E[Gauge: active_plugins];\n C -->|Count Notifications| F[Counter: notifications_sends_total];\n C -->|Count Sent Notifications| G[Counter: notifications_sent_total];\n C -->|Count Failed Notifications| H[Counter: notifications_failed_total];\n D -->|Expose Metrics| I[Prometheus];\n E --> I;\n F --> I;\n G --> I;\n H --> I;\n```\n\n## Security Considerations\n\n!!! warning\n Ensure that the monitoring endpoints are secured and accessible only to authorized personnel. Exposing these endpoints publicly could lead to unauthorized access to sensitive operational data.\n\n- **Encryption**: All data in transit should be encrypted using TLS to prevent interception.\n- **Authentication**: Implement authentication mechanisms to restrict access to metrics.\n- **Audit Logs**: Maintain logs of who accesses the metrics and when, to comply with HIPAA auditing requirements.","api":"# API Reference\n\n## Endpoints\n\n### `/metrics`\n\nThis endpoint exposes all collected metrics in a format compatible with Prometheus.\n\n!!! tip\n Use authentication headers to access this endpoint securely.\n\n=== \"Python\"\n\n ```python\n import requests\n\n response = requests.get('https://your-domain.com/metrics', headers={'Authorization': 'Bearer YOUR_TOKEN'})\n print(response.text)\n ```\n\n=== \"curl\"\n\n ```bash\n curl -H \"Authorization: Bearer YOUR_TOKEN\" https://your-domain.com/metrics\n ```\n\n## Metrics Details\n\n- **`vivified_request_duration_seconds`**: Histogram tracking the duration of requests.\n- **`vivified_active_plugins`**: Gauge showing the number of active plugins.\n- **`vivified_notifications_sends_total`**: Counter for total notification requests received.\n- **`vivified_notifications_sent_total`**: Counter for notifications marked sent.\n- **`vivified_notifications_failed_total`**: Counter for notifications marked as failed.","config":"# Configuration Guide\n\n## Configuration Options\n\n| Option | Description | Default |\n|--------------------------|--------------------------------------|---------|\n| `PROMETHEUS_ENDPOINT` | URL for accessing Prometheus metrics | `/metrics`|\n| `AUTH_TOKEN` | Token for securing the metrics endpoint | None |\n| `ENABLE_TLS` | Boolean to enable/disable TLS | `True` |\n\n!!! note\n Ensure that the `PROMETHEUS_ENDPOINT` is secured and not exposed to unauthorized users.","examples":"# Usage Examples\n\n## Collecting Metrics\n\nTo collect metrics from the Monitoring Service, you can use the following examples:\n\n=== \"Python\"\n\n ```python\n import requests\n\n def fetch_metrics():\n url = 'https://your-domain.com/metrics'\n headers = {'Authorization': 'Bearer YOUR_TOKEN'}\n response = requests.get(url, headers=headers)\n if response.status_code == 200:\n return response.text\n else:\n raise Exception('Failed to fetch metrics')\n ```\n\n=== \"curl\"\n\n ```bash\n curl -H \"Authorization: Bearer YOUR_TOKEN\" https://your-domain.com/metrics\n ```\n\n## Troubleshooting\n\n### Common Issues\n\n- **Unauthorized Access**\n - Ensure your `AUTH_TOKEN` is correctly configured and passed in the request header.\n - Verify that the endpoint is not publicly accessible without proper authentication.\n\n- **Metrics Not Updating**\n - Check the application logs for any errors in metrics collection.\n - Ensure that the Prometheus server is correctly scraping the `/metrics` endpoint.\n\n!!! tip\n Regularly audit your configurations and access logs to maintain HIPAA compliance."}