Skip to main content
Glama
piekstra

New Relic MCP Server

by piekstra

update_log_parsing_rule

Modify an existing log parsing rule in New Relic to change its configuration, such as Grok patterns, NRQL queries, or enablement status.

Instructions

Update an existing log parsing rule

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rule_idYes
descriptionNo
grokNo
nrqlNo
enabledNo
luceneNo
account_idNo

Implementation Reference

  • MCP tool handler decorated with @mcp.tool(), which handles input parameters, client validation, and delegates to the log_parsing helper function.
    @mcp.tool() async def update_log_parsing_rule( rule_id: str, description: Optional[str] = None, grok: Optional[str] = None, nrql: Optional[str] = None, enabled: Optional[bool] = None, lucene: Optional[str] = None, account_id: Optional[str] = None, ) -> str: """Update an existing log parsing rule""" if not client: return json.dumps({"error": "New Relic client not initialized"}) 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.update_log_parsing_rule( client, acct_id, rule_id, description, grok, nrql, enabled, lucene ) return json.dumps(result, indent=2) except Exception as e: return json.dumps({"error": str(e)}, indent=2)
  • The @mcp.tool() decorator registers this function as an MCP tool named 'update_log_parsing_rule'.
    @mcp.tool() async def update_log_parsing_rule( rule_id: str, description: Optional[str] = None, grok: Optional[str] = None, nrql: Optional[str] = None, enabled: Optional[bool] = None, lucene: Optional[str] = None, account_id: Optional[str] = None, ) -> str: """Update an existing log parsing rule""" if not client: return json.dumps({"error": "New Relic client not initialized"}) 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.update_log_parsing_rule( client, acct_id, rule_id, description, grok, nrql, enabled, lucene ) return json.dumps(result, indent=2) except Exception as e: return json.dumps({"error": str(e)}, indent=2)
  • Helper function that constructs and executes the GraphQL mutation to update a log parsing rule in New Relic via NerdGraph API.
    async def update_log_parsing_rule( client, account_id: str, rule_id: str, description: Optional[str] = None, grok: Optional[str] = None, nrql: Optional[str] = None, enabled: Optional[bool] = None, lucene: Optional[str] = None, ) -> Dict[str, Any]: """Update an existing log parsing rule""" # Build the update fields rule_fields = [] if description is not None: rule_fields.append(f'description: "{description}"') if enabled is not None: rule_fields.append(f"enabled: {str(enabled).lower()}") if grok is not None: # grok_escaped = grok.replace("\\", "\\\\") rule_fields.append(f'grok: "{grok}"') if lucene is not None: rule_fields.append(f'lucene: "{lucene}"') if nrql is not None: rule_fields.append(f'nrql: "{nrql}"') rule_object = "{ " + ", ".join(rule_fields) + " }" mutation = f""" mutation {{ logConfigurationsUpdateParsingRule( accountId: {int(account_id)}, id: "{rule_id}", rule: {rule_object} ) {{ rule {{ id description enabled grok lucene nrql updatedAt }} errors {{ message type }} }} }} """ result = await client.nerdgraph_query(mutation) if result and "data" in result: update_result = result["data"].get("logConfigurationsUpdateParsingRule", {}) if update_result.get("errors"): raise Exception(f"Failed to update rule: {update_result['errors']}") return update_result.get("rule", {}) raise Exception("Failed to update parsing rule")

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

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