Project

nrql2nerd

0.0
The project is in a healthy, maintained state
A tool to Send NRQL queries to New Relic API and get results in NerdGraph format
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

nrql2nerd

NRQL2Nerd

Ruby Gem Version Ruby Style Guide

A lightweight Ruby gem for executing NRQL queries against New Relic's NerdGraph API.
Skip the boilerplate and get straight to your data.

Features

  • Simple, intuitive API for NRQL queries
  • Works as a library or command-line tool
  • Environment variable or explicit credential configuration
  • Returns parsed JSON results ready for use

Installation

Add to your Gemfile:

gem "nrql2nerd"

Or install directly:

gem install nrql2nerd

Configuration

Set your New Relic credentials via environment variables:

export NEW_RELIC_API_KEY="your-api-key"
export NEW_RELIC_ACCOUNT_ID="your-account-id"

Or pass them explicitly when creating a client.

Usage

As a Library

require "nrql2nerd"

client = NRQL2Nerd::Client.new
results = client.run_query("SELECT count(*) FROM Transaction SINCE 1 hour ago")

# => [{"count" => 42}]

With explicit credentials:

client = NRQL2Nerd::Client.new(
  api_key: "your-api-key",
  account_id: "12345"
)

Command Line

# Using environment variables
nrql2nerd -q "SELECT count(*) FROM Transaction SINCE 1 hour ago"

# With explicit credentials
nrql2nerd -q "SELECT * FROM Transaction LIMIT 10" \
  --api-key your-api-key \
  --account-id 12345

A shorter alias n2n is also available:

n2n -q "SELECT count(*) FROM PageView SINCE 1 day ago"

Development

bin/setup          # Install dependencies
bundle exec rake   # Run tests and linting
bin/console        # Interactive prompt

Contributing

Bug reports and pull requests are welcome on GitHub. Please follow the code of conduct.

License

Available as open source under the MIT License.