get_application_metric_data
Retrieve application performance metrics from New Relic monitoring to analyze application health, track key performance indicators, and monitor system behavior over specified time periods.
Instructions
Get metric data for an application
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| app_id | Yes | ||
| metric_names | Yes | ||
| from_time | No | ||
| to_time | No |
Input Schema (JSON Schema)
{
"properties": {
"app_id": {
"title": "App Id",
"type": "string"
},
"from_time": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "From Time"
},
"metric_names": {
"items": {
"type": "string"
},
"title": "Metric Names",
"type": "array"
},
"to_time": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "To Time"
}
},
"required": [
"app_id",
"metric_names"
],
"type": "object"
}
Implementation Reference
- newrelic_mcp/server.py:344-362 (handler)MCP tool handler function that wraps the client method to fetch and return application metric data as JSON.@mcp.tool() async def get_application_metric_data( app_id: str, metric_names: List[str], from_time: Optional[str] = None, to_time: Optional[str] = None, ) -> str: """Get metric data for an application""" if not client: return json.dumps({"error": "New Relic client not initialized"}) try: result = await client.get_application_metric_data( app_id, metric_names, from_time, to_time ) return json.dumps(result, indent=2) except Exception as e: return json.dumps({"error": str(e)}, indent=2)
- newrelic_mcp/server.py:88-104 (helper)NewRelicClient helper method that makes the HTTP request to New Relic API for application metric data.async def get_application_metric_data( self, app_id: str, metric_names: List[str], from_time: Optional[str] = None, to_time: Optional[str] = None, ) -> Dict[str, Any]: """Get metric data for an application""" url = f"{self.base_url}/applications/{app_id}/metrics/data.json" params = {"names": metric_names} if from_time: params["from"] = from_time if to_time: params["to"] = to_time return await self._make_request("GET", url, params=params)