Skip to main content
Glama
cloudbring

New Relic MCP Server

by cloudbring

get_metric_data_for_host

Retrieve metric timeslice data for a specific host in New Relic applications using REST v2 queries to monitor performance and analyze system behavior.

Instructions

Get metric timeslices for metrics on a host (REST v2).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
application_idYes
host_idYes
namesYes
valuesNo
fromNo
toNo
periodNo
summarizeNo
pageNo
auto_paginateNo
regionNo

Implementation Reference

  • The handler function that implements the core logic for fetching metric timeslices data for a host via New Relic REST API v2, supporting pagination and query parameters.
    async getMetricData(args: GetMetricDataArgs): Promise<unknown> { const client = this.restFor(args.region); const path = `/applications/${args.application_id}/hosts/${args.host_id}/metrics/data`; const query: Record<string, unknown> = { names: args.names, values: args.values }; if (args.from) query.from = args.from; if (args.to) query.to = args.to; if (args.period) query.period = args.period; if (args.summarize !== undefined) query.summarize = args.summarize; if (args.page) query.page = args.page; const results: unknown[] = []; let nextUrl: string | undefined; let page = args.page; do { const res = await client.get<unknown>(path, page ? { ...query, page } : query); results.push(res.data); const next = res.links?.next; if (args.auto_paginate && next) { const u = new URL(next); const p = u.searchParams.get('page'); page = p ? Number(p) : undefined; nextUrl = next; } else { nextUrl = undefined; } } while (args.auto_paginate && nextUrl); return { items: args.auto_paginate ? results : results[0], page }; }
  • Defines the tool's metadata, description, and input schema for validation.
    getMetricDataTool(): Tool { return { name: 'get_metric_data_for_host', description: 'Get metric timeslices for metrics on a host (REST v2).', inputSchema: { type: 'object', properties: { application_id: { type: 'number' }, host_id: { type: 'number' }, names: { type: 'array', items: { type: 'string' } }, values: { type: 'array', items: { type: 'string' } }, from: { type: 'string' }, to: { type: 'string' }, period: { type: 'number' }, summarize: { type: 'boolean' }, page: { type: 'number' }, auto_paginate: { type: 'boolean' }, region: { type: 'string', enum: ['US', 'EU'] }, }, required: ['application_id', 'host_id', 'names'], }, }; }
  • src/server.ts:85-87 (registration)
    Registers the tool by including its definition in the server's list of available tools.
    restMetrics.getListMetricNamesTool(), restMetrics.getMetricDataTool(), restMetrics.getListApplicationHostsTool(),
  • src/server.ts:195-198 (registration)
    Registers the execution handler in the server's tool dispatcher switch statement.
    case 'get_metric_data_for_host': return await new RestMetricsTool().getMetricData( args as Parameters<RestMetricsTool['getMetricData']>[0] );
  • TypeScript type definition for the tool's input arguments, aligning with the inputSchema.
    type GetMetricDataArgs = { application_id: number; host_id: number; names: string[]; values?: string[]; from?: string; to?: string; period?: number; summarize?: boolean; page?: number; auto_paginate?: boolean; region?: Region; };

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/cloudbring/newrelic-mcp'

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