list_log_parsing_rules
Retrieve all configured log parsing rules for a New Relic account to manage log data processing and structure.
Instructions
List all log parsing rules for an account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_id | No |
Implementation Reference
- newrelic_mcp/server.py:646-662 (handler)MCP tool registration and handler function for 'list_log_parsing_rules'. This is the entry point decorated with @mcp.tool() that handles input validation, client checks, and delegates to the log_parsing module.@mcp.tool() async 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/log_parsing.py:364-402 (helper)Core helper function that executes the NerdGraph GraphQL query to fetch and filter log parsing rules for the given account.async 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 []