list_metric_names_for_host
Retrieve metric names and values for a specific application host using the New Relic REST v2 API.
Instructions
List metric names and values for a specific application host (REST v2).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| application_id | Yes | ||
| host_id | Yes | ||
| name | No | ||
| page | No | ||
| auto_paginate | No | ||
| region | No |
Implementation Reference
- src/tools/rest/metrics.ts:61-83 (handler)The handler function that executes the list_metric_names_for_host tool logic. It calls the New Relic REST v2 API at /applications/{app_id}/hosts/{host_id}/metrics, supports optional name filtering and auto-pagination.
async listMetricNames(args: ListMetricNamesArgs): Promise<unknown> { const client = this.restFor(args.region); const path = `/applications/${args.application_id}/hosts/${args.host_id}/metrics`; const query: Record<string, unknown> = {}; if (args.name) query.name = args.name; 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 }; - src/tools/rest/metrics.ts:4-11 (schema)TypeScript type definition for the input arguments of listMetricNames.
type ListMetricNamesArgs = { application_id: number; host_id: number; name?: string; page?: number; auto_paginate?: boolean; region?: Region; }; - src/tools/rest/metrics.ts:42-58 (schema)The tool definition/schema for list_metric_names_for_host, describing its name, description, input properties, and required fields.
getListMetricNamesTool(): Tool { return { name: 'list_metric_names_for_host', description: 'List metric names and values for a specific application host (REST v2).', inputSchema: { type: 'object', properties: { application_id: { type: 'number' }, host_id: { type: 'number' }, name: { type: 'string' }, page: { type: 'number' }, auto_paginate: { type: 'boolean' }, region: { type: 'string', enum: ['US', 'EU'] }, }, required: ['application_id', 'host_id'], }, }; - src/server.ts:85-85 (registration)Registration of the list_metric_names_for_host tool in the registerTools() method via restMetrics.getListMetricNamesTool().
restMetrics.getListMetricNamesTool(), - src/server.ts:191-194 (registration)The dispatch case in executeTool() that routes to RestMetricsTool.listMetricNames when the tool name matches.
case 'list_metric_names_for_host': return await new RestMetricsTool().listMetricNames( args as Parameters<RestMetricsTool['listMetricNames']>[0] );