Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Convert New Relic NRQL queries to NerdGraph GraphQL

License

Notifications You must be signed in to change notification settings

saiden-dev/nrql2nerd

Repository files navigation

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.

About

Convert New Relic NRQL queries to NerdGraph GraphQL

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •