list_log_parsing_rules
Retrieve all log parsing rules configured for a New Relic account to manage log data processing and analysis.
Instructions
List all log parsing rules for an account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | No |
Input Schema (JSON Schema)
{
"properties": {
"account_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Account Id"
}
},
"type": "object"
}
Implementation Reference
- newrelic_mcp/log_parsing.py:364-402 (handler)Core implementation of list_log_parsing_rules: executes NerdGraph query to fetch and filter log parsing rulesasync def list_log_parsing_rules(client, account_id: str) -> List[Dict[str, Any]]: """List all log parsing rules for an account""" query = """ query($accountId: Int!) { actor { account(id: $accountId) { logConfigurations { parsingRules { accountId deleted description enabled grok id lucene nrql updatedAt createdBy { email name } } } } } } """ variables = {"accountId": int(account_id)} result = await client.nerdgraph_query(query, variables) if result and "data" in result: account_data = result["data"].get("actor", {}).get("account", {}) if account_data and "logConfigurations" in account_data: rules = account_data["logConfigurations"].get("parsingRules", []) return [r for r in rules if r and not r.get("deleted", False)] return []
- newrelic_mcp/server.py:647-662 (handler)MCP tool handler: registers the tool and wraps the core implementation with error handling and JSON serializationasync def list_log_parsing_rules(account_id: Optional[str] = None) -> str: """List all log parsing rules for an account""" if not client: return json.dumps({"error": "New Relic client not initialized"}) # Use provided account_id or fall back to client's account_id acct_id = account_id or client.account_id if not acct_id: return json.dumps({"error": "Account ID required but not provided"}) try: result = await log_parsing.list_log_parsing_rules(client, acct_id) return json.dumps(result, indent=2) except Exception as e: return json.dumps({"error": str(e)}, indent=2)
- newrelic_mcp/server.py:647-647 (registration)Registration of the list_log_parsing_rules tool via FastMCP decoratorasync def list_log_parsing_rules(account_id: Optional[str] = None) -> str: