Skip to main content
Glama

list_metrics

Retrieve available metrics in an Oracle Cloud Infrastructure compartment to monitor and analyze resource performance, with optional namespace filtering for targeted insights.

Instructions

List available metrics in a compartment. Args: compartment_id: OCID of the compartment namespace: Optional namespace to filter metrics (e.g., oci_computeagent, oci_blockstore) Returns: List of available metrics with their namespaces and dimensions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
compartment_idYes
namespaceNo

Implementation Reference

  • MCP tool handler for 'list_metrics': wraps the core helper function, provides input validation via signature/docstring, logging, error handling, and calls OCI monitoring client via helper.
    @mcp.tool(name="list_metrics") @mcp_tool_wrapper( start_msg="Listing metrics in compartment {compartment_id}...", error_prefix="Error listing metrics" ) async def mcp_list_metrics(ctx: Context, compartment_id: str, namespace: Optional[str] = None) -> List[Dict[str, Any]]: """ List available metrics in a compartment. Args: compartment_id: OCID of the compartment namespace: Optional namespace to filter metrics (e.g., oci_computeagent, oci_blockstore) Returns: List of available metrics with their namespaces and dimensions """ return list_metrics(oci_clients["monitoring"], compartment_id, namespace)
  • Explicit registration of the tool with name 'list_metrics' using FastMCP decorator.
    @mcp.tool(name="list_metrics")
  • Core helper function implementing the OCI API call to list_metrics, with pagination, response formatting, and error handling.
    def list_metrics(monitoring_client: oci.monitoring.MonitoringClient, compartment_id: str, namespace: Optional[str] = None) -> List[Dict[str, Any]]: """ List available metrics in a compartment. Args: monitoring_client: OCI Monitoring client compartment_id: OCID of the compartment namespace: Optional namespace to filter metrics Returns: List of available metrics """ try: list_metrics_details = oci.monitoring.models.ListMetricsDetails( compartment_id=compartment_id, namespace=namespace ) metrics_response = oci.pagination.list_call_get_all_results( monitoring_client.list_metrics, compartment_id, list_metrics_details ) metrics = [] for metric in metrics_response.data: metrics.append({ "name": metric.name, "namespace": metric.namespace, "resource_group": metric.resource_group, "compartment_id": metric.compartment_id, "dimensions": metric.dimensions, }) logger.info(f"Found {len(metrics)} metrics in compartment {compartment_id}") return metrics except Exception as e: logger.exception(f"Error listing metrics: {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