Skip to main content
Glama

get-metrics

Discover and list available metrics from Datadog to use in monitors or dashboards. Optionally search for specific metrics by pattern using the q parameter.

Instructions

List available metrics from Datadog. Optionally use the q parameter to search for specific metrics matching a pattern. Helpful for discovering metrics to use in monitors or dashboards.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
qNo

Implementation Reference

  • The execute function implementing the core logic of the get-metrics tool, using Datadog's MetricsApi to list metrics based on an optional query parameter.
    execute: async (params: GetMetricsParams) => { try { const { q } = params; const apiInstance = new v1.MetricsApi(configuration); const queryStr = q || "*"; const apiParams: v1.MetricsApiListMetricsRequest = { q: queryStr }; const response = await apiInstance.listMetrics(apiParams); return response; } catch (error) { console.error("Error fetching metrics:", error); throw error; }
  • src/index.ts:148-160 (registration)
    Registration of the 'get-metrics' tool in the MCP server, including name, description, input schema, and wrapper handler.
    server.tool( "get-metrics", "List available metrics from Datadog. Optionally use the q parameter to search for specific metrics matching a pattern. Helpful for discovering metrics to use in monitors or dashboards.", { q: z.string().optional() }, async (args) => { const result = await getMetrics.execute(args); return { content: [{ type: "text", text: JSON.stringify(result) }] }; } );
  • TypeScript type definition for the input parameters of the getMetrics tool.
    type GetMetricsParams = { q?: string; };
  • Initialization function that sets up the Datadog client configuration, including auth and site variables for metrics API.
    initialize: () => { const configOpts = { authMethods: { apiKeyAuth: process.env.DD_API_KEY, appKeyAuth: process.env.DD_APP_KEY } }; configuration = client.createConfiguration(configOpts); if (process.env.DD_METRICS_SITE) { configuration.setServerVariables({ site: process.env.DD_METRICS_SITE }); } },
  • Zod schema for input validation of the get-metrics tool, defining the optional 'q' query parameter.
    q: z.string().optional() },

Other Tools

Related Tools

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/GeLi2001/datadog-mcp-server'

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