CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-trafficmanager

Microsoft Azure Traffic Manager Management Client Library for Python

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

analytics.mddocs/

Analytics and Monitoring

Traffic analytics through heat maps, health monitoring configuration, and real user metrics for performance optimization. These capabilities provide insights into traffic patterns, endpoint health, and user experience to optimize Traffic Manager configurations.

Capabilities

Heat Map Analytics

Retrieves traffic analytics and performance data showing user traffic patterns, query volumes, and latency measurements across geographic regions.

def get(
    resource_group_name: str,
    profile_name: str,
    top_left: Optional[List[float]] = None,
    bot_right: Optional[List[float]] = None
) -> HeatMapModel:
    """
    Gets the latest heat map for a Traffic Manager profile.

    Args:
        resource_group_name (str): Name of the resource group
        profile_name (str): Name of the Traffic Manager profile
        top_left (List[float], optional): Top-left coordinates [latitude, longitude]
        bot_right (List[float], optional): Bottom-right coordinates [latitude, longitude]

    Returns:
        HeatMapModel: Heat map data with traffic flows and latency information
    """

Usage Examples:

# Get global heat map for entire profile
heat_map = client.heat_map.get(
    resource_group_name="my-rg",
    profile_name="my-profile"
)

print(f"Heat map period: {heat_map.start_time} to {heat_map.end_time}")
print(f"Endpoints analyzed: {len(heat_map.endpoints)}")

# Analyze traffic flows
for traffic_flow in heat_map.traffic_flows:
    print(f"Source: {traffic_flow.source_ip} ({traffic_flow.latitude}, {traffic_flow.longitude})")
    for query_exp in traffic_flow.query_experiences:
        print(f"  -> Endpoint {query_exp.endpoint_id}: {query_exp.query_count} queries, {query_exp.latency}ms avg")

# Get regional heat map (e.g., North America)
na_heat_map = client.heat_map.get(
    resource_group_name="my-rg",
    profile_name="my-profile",
    top_left=[60.0, -130.0],   # Northwest corner
    bot_right=[25.0, -70.0]    # Southeast corner
)

Real User Metrics Management

Manages Real User Metrics (RUM) keys that enable client-side performance measurement collection from actual users.

def create_or_update() -> UserMetricsModel:
    """
    Creates or updates the subscription-level Real User Metrics key.

    Returns:
        UserMetricsModel: User metrics configuration with operation key
    """

def get() -> UserMetricsModel:
    """
    Gets the subscription-level Real User Metrics key.

    Returns:
        UserMetricsModel: Current user metrics configuration
    """

def delete() -> DeleteOperationResult:
    """
    Deletes the subscription-level Real User Metrics key.

    Returns:
        DeleteOperationResult: Operation result
    """

Usage Examples:

# Enable Real User Metrics for subscription
rum_config = client.traffic_manager_user_metrics_keys.create_or_update()
print(f"RUM Key: {rum_config.key}")

# Use the key in client-side JavaScript
js_code = f"""
<script>
// Add to your web pages to collect real user metrics
window.trafficManagerConfig = {{
    subscriptionKey: "{rum_config.key}"
}};
</script>
<script src="https://js.monitor.azure.com/scripts/c/ms.tm-4.0.0.min.js"></script>
"""

# Check current RUM configuration
current_rum = client.traffic_manager_user_metrics_keys.get()
if current_rum.key:
    print("Real User Metrics is enabled")
else:
    print("Real User Metrics is not configured")

# Disable Real User Metrics
delete_result = client.traffic_manager_user_metrics_keys.delete()
if delete_result.operation_result:
    print("Real User Metrics disabled successfully")

Analytics Data Models

Heat Map Model

class HeatMapModel:
    """Traffic Manager heat map analytics data."""
    start_time: datetime                    # Heat map time window start
    end_time: datetime                      # Heat map time window end
    endpoints: List[HeatMapEndpoint]        # Endpoints included in analysis
    traffic_flows: List[TrafficFlow]        # Traffic flow data points

class HeatMapEndpoint:
    """Sparse endpoint representation for heat maps."""
    resource_id: str                        # ARM Resource ID
    endpoint_id: int                        # Unique endpoint identifier for heat map

class TrafficFlow:
    """Heat map traffic flow properties."""
    source_ip: str                          # Source IP address (masked for privacy)
    latitude: float                         # Approximate source latitude
    longitude: float                        # Approximate source longitude  
    query_experiences: List[QueryExperience] # Performance data for each endpoint

class QueryExperience:
    """Heat map query experience properties."""
    endpoint_id: int                        # Target endpoint ID (required)
    query_count: int                        # Number of queries (required)
    latency: float                          # Average query latency in milliseconds

User Metrics Model

class UserMetricsModel:
    """Traffic Manager user metrics configuration."""
    key: str                               # User metrics operation key for client integration

Health Monitoring Configuration

Health monitoring is configured at the profile level through the MonitorConfig class but affects how endpoints are evaluated for traffic routing.

Monitor Configuration Details

class MonitorConfig:
    """Health monitoring configuration for endpoints."""
    # Status and protocol
    profile_monitor_status: ProfileMonitorStatus         # Overall monitoring status
    protocol: MonitorProtocol                           # Health check protocol
    port: int                                           # TCP port (1-65535)
    path: str                                           # Path for HTTP(S) checks
    
    # Timing configuration
    interval_in_seconds: int                            # Check interval (10 or 30)
    timeout_in_seconds: int                             # Check timeout (5-10)
    tolerated_number_of_failures: int                   # Allowed failures (0-9)
    
    # Advanced monitoring
    custom_headers: List[MonitorConfigCustomHeadersItem]     # Custom headers
    expected_status_code_ranges: List[MonitorConfigExpectedStatusCodeRangesItem]  # Expected HTTP codes

class MonitorConfigCustomHeadersItem:
    """Custom header for health check requests."""
    name: str                              # Header name (e.g., "Host", "Authorization")
    value: str                             # Header value

class MonitorConfigExpectedStatusCodeRangesItem:
    """Expected HTTP status code range for health checks."""
    min: int                               # Minimum status code (100-999)
    max: int                               # Maximum status code (100-999)

Health Monitoring Examples

# Configure advanced health monitoring
monitor_config = MonitorConfig(
    protocol="HTTPS",
    port=443,
    path="/api/health",
    interval_in_seconds=30,                # Check every 30 seconds
    timeout_in_seconds=10,                 # 10 second timeout
    tolerated_number_of_failures=3,        # Allow 3 failures before marking unhealthy
    custom_headers=[
        {"name": "Host", "value": "api.example.com"},
        {"name": "Authorization", "value": "Bearer health-check-token"},
        {"name": "User-Agent", "value": "TrafficManager-HealthCheck/1.0"}
    ],
    expected_status_code_ranges=[
        {"min": 200, "max": 299},           # 2xx success codes
        {"min": 401, "max": 401}            # Allow 401 (auth required) as healthy
    ]
)

# Apply to profile
profile.monitor_config = monitor_config

Monitoring Status Types

class ProfileMonitorStatus(str, Enum):
    """Profile-level health monitoring status."""
    CHECKING_ENDPOINTS = "CheckingEndpoints"    # Health checks in progress
    ONLINE = "Online"                           # All endpoints healthy
    DEGRADED = "Degraded"                       # Some endpoints unhealthy
    DISABLED = "Disabled"                       # Monitoring disabled
    INACTIVE = "Inactive"                       # Profile inactive

class MonitorProtocol(str, Enum):
    """Health check protocols."""
    HTTP = "HTTP"                               # HTTP health checks
    HTTPS = "HTTPS"                             # HTTPS health checks  
    TCP = "TCP"                                 # TCP port connectivity checks

Analytics Best Practices

Heat Map Analysis

  1. Regular Monitoring: Check heat maps regularly to understand traffic patterns and user distribution
  2. Geographic Optimization: Use heat map data to optimize endpoint placement and geographic routing
  3. Performance Tuning: Identify high-latency regions and add endpoints to improve performance
  4. Capacity Planning: Use query volume data for scaling decisions

Real User Metrics Integration

  1. Client Integration: Add RUM JavaScript to all pages that use Traffic Manager
  2. Privacy Compliance: RUM data is automatically anonymized but review privacy policies
  3. Performance Insights: Use RUM data to validate Traffic Manager routing decisions
  4. Optimization: Combine RUM data with heat maps for comprehensive performance analysis

Health Monitoring Optimization

  1. Appropriate Intervals: Use 30-second intervals for most scenarios, 10-second for critical applications
  2. Failure Tolerance: Set failure tolerance based on application criticality and expected variability
  3. Custom Headers: Use custom headers for application-specific health checks
  4. Status Code Ranges: Configure expected status codes to match application behavior

Install with Tessl CLI

npx tessl i tessl/pypi-azure-mgmt-trafficmanager

docs

analytics.md

client.md

endpoints.md

geographic.md

index.md

profiles.md

tile.json