Skip to main content
Glama

get_alarm

Retrieve detailed alarm information including query, thresholds, and notification settings from Oracle Cloud Infrastructure using the alarm's OCID.

Instructions

Get detailed information about a specific alarm.

Args:
    alarm_id: OCID of the alarm to retrieve

Returns:
    Detailed alarm information including query, thresholds, and notification settings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
alarm_idYes

Implementation Reference

  • Registration of the 'get_alarm' tool using @mcp.tool decorator with wrapper for error handling.
    @mcp.tool(name="get_alarm")
    @mcp_tool_wrapper(
        start_msg="Getting alarm details for {alarm_id}...",
        success_msg="Retrieved alarm details successfully",
        error_prefix="Error getting alarm details"
    )
  • The main handler function for the 'get_alarm' tool, which receives the alarm_id parameter and delegates to the helper function with the OCI monitoring client.
    async def mcp_get_alarm(ctx: Context, alarm_id: str) -> Dict[str, Any]:
        """
        Get detailed information about a specific alarm.
    
        Args:
            alarm_id: OCID of the alarm to retrieve
    
        Returns:
            Detailed alarm information including query, thresholds, and notification settings
        """
        return get_alarm(oci_clients["monitoring"], alarm_id)
  • Core helper function that performs the actual OCI API call to retrieve alarm details and formats the response dictionary.
    def get_alarm(monitoring_client: oci.monitoring.MonitoringClient, alarm_id: str) -> Dict[str, Any]:
        """
        Get details of a specific alarm.
    
        Args:
            monitoring_client: OCI Monitoring client
            alarm_id: OCID of the alarm
    
        Returns:
            Details of the alarm
        """
        try:
            alarm = monitoring_client.get_alarm(alarm_id).data
    
            alarm_details = {
                "id": alarm.id,
                "display_name": alarm.display_name,
                "compartment_id": alarm.compartment_id,
                "metric_compartment_id": alarm.metric_compartment_id,
                "metric_compartment_id_in_subtree": alarm.metric_compartment_id_in_subtree,
                "namespace": alarm.namespace,
                "resource_group": alarm.resource_group,
                "query": alarm.query,
                "resolution": alarm.resolution,
                "pending_duration": alarm.pending_duration,
                "severity": alarm.severity,
                "body": alarm.body,
                "is_enabled": alarm.is_enabled,
                "lifecycle_state": alarm.lifecycle_state,
                "suppress": {
                    "time_suppress_from": str(alarm.suppression.time_suppress_from) if alarm.suppression else None,
                    "time_suppress_until": str(alarm.suppression.time_suppress_until) if alarm.suppression else None,
                    "description": alarm.suppression.description if alarm.suppression else None,
                } if alarm.suppression else None,
                "destinations": alarm.destinations,
                "repeat_notification_duration": alarm.repeat_notification_duration,
                "time_created": str(alarm.time_created),
                "time_updated": str(alarm.time_updated),
            }
    
            logger.info(f"Retrieved details for alarm {alarm_id}")
            return alarm_details
    
        except Exception as e:
            logger.exception(f"Error getting alarm details: {e}")
            raise

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/jopsis/mcp-server-oci'

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