Skip to main content
Glama
driosalido
by driosalido

get_alerts_summary

Summarize Kubernetes alerts by severity and state to monitor and analyze alert status from the Karma dashboard.

Instructions

Get a summary of alerts grouped by severity and state

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler implementation for get_alerts_summary tool, which fetches Karma data and uses format_alert_summary utility to return the alert statistics.
    async def get_alerts_summary() -> str:
        """Get a summary of alerts grouped by severity and state"""
        data, error = await fetch_karma_alerts()
        if error:
            return error
    
        # Use the centralized summary function
        summary = format_alert_summary(data, include_clusters=True)
    
        # Add top alert types section
        alert_type_counts = {}
        grids = data.get("grids", [])
        for grid in grids:
            for group in grid.get("alertGroups", []):
                alertname = extract_label_value(
                    group.get("labels", []), "alertname", "Unknown"
                )
                alert_count = len(group.get("alerts", []))
                alert_type_counts[alertname] = (
                    alert_type_counts.get(alertname, 0) + alert_count
                )
    
        # Add top alert types to summary
        if alert_type_counts:
            summary += "\nšŸ” Top Alert Types:\n"
            top_alerts = sorted(
                alert_type_counts.items(), key=lambda x: x[1], reverse=True
            )[:10]
            for alertname, count in top_alerts:
                summary += f"  • {alertname}: {count}\n"
    
        return summary
  • Helper function that formats alert data into a readable summary, used by the get_alerts_summary tool.
    def format_alert_summary(alerts_data, include_clusters=False):
        """Format alert data into a readable summary"""
        total_alerts = 0
        severity_counts = {"critical": 0, "warning": 0, "info": 0, "none": 0}
        state_counts = {"active": 0, "suppressed": 0}
        cluster_counts = {}
    
        grids = alerts_data.get("grids", [])
    
        for grid in grids:
            for group in grid.get("alertGroups", []):
                alerts = group.get("alerts", [])
                total_alerts += len(alerts)
    
                for alert in alerts:
                    metadata = extract_alert_metadata(group, alert)
    
                    # Count by severity
                    severity = metadata["severity"]
                    if severity in severity_counts:
                        severity_counts[severity] += 1
    
                    # Count by state
                    state = metadata["state"]
                    if state in state_counts:
                        state_counts[state] += 1
    
                    # Count by cluster if needed
                    if include_clusters:
                        cluster = metadata["cluster"]
                        cluster_counts[cluster] = cluster_counts.get(cluster, 0) + 1
    
        # Format summary matching the expected test format
        summary = f"Total Alerts: {total_alerts}\n"
    
        # Severity breakdown
        summary += "\nBy Severity:\n"
        for severity, count in severity_counts.items():
            if count > 0:
                summary += f"  {severity.capitalize()}: {count}\n"
    
        summary += "\nBy State:\n"
        for state, count in state_counts.items():
            if count > 0:
                summary += f"  {state.capitalize()}: {count}\n"
    
        if include_clusters and cluster_counts:
            summary += "\nBy Cluster:\n"
            sorted_clusters = sorted(
                cluster_counts.items(), key=lambda x: x[1], reverse=True
            )
            for cluster, count in sorted_clusters:
                summary += f"  {cluster}: {count}\n"
    
        return summary
  • Registration of the get_alerts_summary tool in the MCP server's tool list.
        "name": "get_alerts_summary",
        "description": "Get alert statistics",
        "inputSchema": {"type": "object", "properties": {}, "required": []},
    },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/driosalido/mcp-karma'

If you have feedback or need assistance with the MCP directory API, please join our Discord server