nrql

Crates.ionrql
lib.rsnrql
version0.1.0
created_at2025-12-07 17:01:17.876316+00
updated_at2025-12-07 17:01:17.876316+00
descriptionA CLI for executing NRQL queries against New Relic
homepage
repositoryhttps://github.com/caiges/nrql
max_upload_size
id1971909
size58,058
Caige Nichols (caiges)

documentation

README

nrql

CI Crates.io License: MIT

A CLI for executing NRQL queries against New Relic.

Installation

cargo install nrql

Or build from source:

cargo build --release
# Binary will be at target/release/nrql

Usage

# Set credentials via environment variables
export NEW_RELIC_API_KEY="your-api-key"
export NEW_RELIC_ACCOUNT_ID="your-account-id"

# Query any data type
nrql "SELECT * FROM Transaction SINCE 1 hour ago LIMIT 10"
nrql "SELECT * FROM Log WHERE level = 'ERROR' SINCE 30 minutes ago"
nrql "SELECT count(*) FROM Metric FACET metricName SINCE 1 day ago"
nrql "SELECT average(duration) FROM Transaction FACET name SINCE 1 week ago"

# Different output formats
nrql "SELECT * FROM Log LIMIT 5" -o table   # Default: formatted table
nrql "SELECT * FROM Log LIMIT 5" -o text    # Key-value pairs, one record at a time
nrql "SELECT * FROM Log LIMIT 5" -o json    # JSON output
nrql "SELECT * FROM Log LIMIT 5" -o csv     # CSV output

Options

Option Short Environment Variable Description
--api-key -k NEW_RELIC_API_KEY New Relic API key
--account-id -a NEW_RELIC_ACCOUNT_ID New Relic account ID
--output -o Output format: table, text, json, csv

Examples

# Application performance
nrql "SELECT average(duration), count(*) FROM Transaction FACET name SINCE 1 hour ago"

# Error analysis
nrql "SELECT * FROM TransactionError SINCE 1 day ago LIMIT 100"

# Infrastructure metrics
nrql "SELECT average(cpuPercent) FROM SystemSample FACET hostname SINCE 1 hour ago"

# Log analysis
nrql "FROM Log SELECT * WHERE level = 'ERROR' SINCE 30 minutes ago"

# Custom events
nrql "SELECT * FROM MyCustomEvent SINCE 1 week ago"

# Export to file
nrql "SELECT * FROM Transaction SINCE 1 day ago" -o csv > transactions.csv

Data Types

NRQL can query any data in your New Relic account:

  • Transaction - APM transaction data
  • TransactionError - Application errors
  • Log - Log data
  • Metric - Dimensional metrics
  • SystemSample - Infrastructure host metrics
  • ProcessSample - Process-level metrics
  • NetworkSample - Network metrics
  • ContainerSample - Container metrics
  • K8sContainerSample - Kubernetes container data
  • Custom events sent via the Event API
Commit count: 0

cargo fmt