Skip to content
| Marketplace
Sign in
Visual Studio Code>Machine Learning>New Relic ToolsNew to Visual Studio Code? Get it now.
New Relic Tools

New Relic Tools

AutoOcto

|
3 installs
| (0) | Free
Query New Relic logs, traces, and entity relationships in Copilot chat
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

New Relic Tools VS Code Extension

A VS Code extension that provides New Relic observability tools through GitHub Copilot chat interface. Query logs, search entities, trace distributed transactions, and analyze service relationships directly from your editor.

✨ Features NerdGraph best practices: Rate limiting, retry logic, GraphQL variables, and proper error handling. See NERDGRAPH_INTEGRATION.md for details.

Features

Log Tools

  • Query Logs: Execute custom NRQL queries against New Relic logs
  • Get Error Logs: Quickly retrieve error and fatal logs
  • Search Logs: Find logs by message content
  • Get Service Logs: Filter logs by service/application name

Trace Tools

  • Get Trace: Retrieve distributed trace details by trace ID

Entity Tools

  • Search Entities: Find New Relic entities (apps, hosts, containers)
  • Get Entity Relationships: Analyze service dependencies and infrastructure connections

Installation

Prerequisites

  • VS Code 1.95.0 or higher
  • New Relic account with API access
  • New Relic User API key (Create one here)

Setup

  1. Install the extension from VSIX:

    code --install-extension newrelic-tools-0.1.0.vsix
    
  2. Configure your New Relic credentials in VS Code settings:

    • Open Settings (Ctrl+, or Cmd+,)
    • Search for "New Relic"
    • Set the following values:
      • newrelicTools.apiKey: Your New Relic User API key
      • newrelicTools.accountId: Your New Relic account ID
      • newrelicTools.logPartitions: (Optional) JSON array of log partitions, default: ["Log"]

Usage

All tools are available through GitHub Copilot chat using the @ mention syntax.

Examples

Query Logs

@copilot Use queryNewRelicLogs to find all error logs from the last hour

Get Error Logs

@copilot Use getNewRelicErrorLogs to show errors from the last 24 hours

Search Logs

@copilot Use searchNewRelicLogs to find logs containing "OutOfMemoryError"

Get Service Logs

@copilot Use getNewRelicServiceLogs to show logs for "email-api" service

Search Entities

@copilot Use searchNewRelicEntities to find all entities with "database" in the name

Get Entity Relationships

@copilot Use getNewRelicEntityRelationships with entity GUID "guid"

Development

Build from Source

# Install dependencies
npm install

# Compile TypeScript
npm run compile

# Watch for changes
npm run watch

# Package extension
vsce package

Testing

Setup Test Environment

  1. Create a .env file in the project root:

    cp .env.example .env
    
  2. Edit .env with your credentials:

    NEWRELIC_API_KEY=your-api-key
    NEWRELIC_ACCOUNT_ID=your-account-id
    

Run Tests

# Install dependencies (including dotenv and ts-node)
npm install

# Run comprehensive test suite (all 13 tools)
npm test

# Run individual test suites
npm run test:all       # All test categories
npm run test:entity    # Entity tools only
npm run test:logs      # Log tools only  
npm run test:query     # Query tools only

All tests automatically load credentials from .env file.

Tool Reference

queryNewRelicLogs

Execute custom NRQL queries.

Input:

  • nrql (required): NRQL query string
  • partition (optional): Log partition name

Example:

{
  "nrql": "SELECT * FROM Log WHERE level = 'ERROR' SINCE 1 hour ago LIMIT 10"
}

getNewRelicErrorLogs

Get error and fatal logs.

Input:

  • hours (optional): Hours to look back (default: 1)
  • partition (optional): Log partition name
  • limit (optional): Max results (default: 100)

searchNewRelicLogs

Search logs by message content.

Input:

  • searchText (required): Text to search for
  • hours (optional): Hours to look back (default: 1)
  • partition (optional): Log partition name
  • limit (optional): Max results (default: 100)

getNewRelicServiceLogs

Get logs for a specific service.

Input:

  • serviceName (required): Service/application name
  • hours (optional): Hours to look back (default: 1)
  • partition (optional): Log partition name
  • limit (optional): Max results (default: 100)

getNewRelicTrace

Get distributed trace details.

Input:

  • traceId (required): New Relic trace ID

searchNewRelicEntities

Search for entities.

Input:

  • searchTerm (required): Entity name or partial name
  • entityType (optional): Entity type filter (e.g., "APPLICATION", "HOST")
  • limit (optional): Max results (default: 10)

getNewRelicEntityRelationships

Get entity relationships.

Input:

  • entityGuid (required): New Relic entity GUID

Architecture

The extension follows a clean, modular architecture:

src/
├── extension.ts              # Main extension entry point
├── types.ts                  # TypeScript type definitions
├── helpers/
│   └── newrelicHelper.ts     # New Relic NerdGraph API client (with best practices)
├── tools/
│   ├── baseNewRelicTool.ts   # Base class for all tools
│   ├── logTools.ts           # Log-related tools (5 tools)
│   ├── entityTools.ts        # Entity-related tools (2 tools)
│   ├── dashboardTools.ts     # Dashboard tools (2 tools)
│   ├── metricsTools.ts       # Metrics & SLO tools (4 tools)
│   └── nrqlTools.ts          # NRQL execution command
├── utils/
│   ├── configLoader.ts       # Configuration management
│   ├── errorHandler.ts       # Error handling utilities
│   └── formatters.ts         # Output formatting helpers
└── tests/
    ├── testAllTools.ts            # Comprehensive test suite (9 tests)
    ├── testQueryLogs.ts
    ├── testGetErrorLogs.ts
    ├── testEntityTools.ts
    └── testNerdGraphIntegration.ts # NerdGraph best practices tests (8 tests)

NerdGraph Integration

This extension implements New Relic NerdGraph best practices:

  • ✅ Rate Limiting: 20 concurrent requests (under 25 limit)
  • ✅ Retry Logic: Exponential backoff for transient failures
  • ✅ GraphQL Variables: Secure query parameterization
  • ✅ Error Handling: Typed responses with structured errors
  • ✅ NRQL Escaping: Safe handling of special characters

See NERDGRAPH_INTEGRATION.md for complete documentation.

License

MIT

Support

For issues and feature requests, please contact the development team.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft