Skip to main content
Glama
piekstra

New Relic MCP Server

by piekstra

update_log_parsing_rule

Modify existing log parsing rules to extract and structure log data for better analysis and monitoring in New Relic.

Instructions

Update an existing log parsing rule

Input Schema

NameRequiredDescriptionDefault
rule_idYes
descriptionNo
grokNo
nrqlNo
enabledNo
luceneNo
account_idNo

Input Schema (JSON Schema)

{ "properties": { "account_id": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Account Id" }, "description": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Description" }, "enabled": { "anyOf": [ { "type": "boolean" }, { "type": "null" } ], "default": null, "title": "Enabled" }, "grok": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Grok" }, "lucene": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Lucene" }, "nrql": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Nrql" }, "rule_id": { "title": "Rule Id", "type": "string" } }, "required": [ "rule_id" ], "type": "object" }

Implementation Reference

  • Registers the 'update_log_parsing_rule' MCP tool with @mcp.tool() decorator. This wrapper handles client initialization, account ID resolution, and delegates to the core implementation in log_parsing module.
    @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)
  • Core handler function that constructs and executes a NerdGraph GraphQL mutation to update a log parsing rule in New Relic. Handles dynamic field updates and error checking.
    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