nrql2nerd 0.1.0 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/.tool-versions +1 -0
- data/README.md +68 -32
- data/exe/n2n +1 -0
- data/lib/nrql2nerd/client.rb +0 -2
- data/lib/nrql2nerd/version.rb +1 -1
- data/sig/nrql2nerd.rbs +17 -1
- metadata +8 -6
- data/exe/n2n +0 -40
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 864e8102fe2655a88a66b35f1d80106db00e01a6c8832c7c2eae0ccd7af4a800
|
|
4
|
+
data.tar.gz: '089d5ec6b3e31324d92a9fc67cae91139d519ed2d59d45755845e3468eb168cf'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5d320daf3d33ba69ef1e836ea14da7429b7ad15824f58ae9400066711e9c1a5eb49eb7c1be5a1f9384b7e89e14efe8503c767bc1f75921a925e63f63e1d700f0
|
|
7
|
+
data.tar.gz: 35286f227bdcd1e5a41b92a904a6abe059700b3a3b13ee620256ca16831e40fa7c7a6bd0828d9f30edf2163a4233d47892502b0a577efb0b789e9270371be1ed
|
data/.rspec
ADDED
data/.tool-versions
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby 3.4.8
|
data/README.md
CHANGED
|
@@ -1,59 +1,95 @@
|
|
|
1
1
|
# NRQL2Nerd
|
|
2
|
+
|
|
2
3
|
[](https://github.com/aladac/nrql2nerd/actions/workflows/main.yml)
|
|
3
4
|
[](https://badge.fury.io/rb/nrql2nerd)
|
|
5
|
+
[](https://github.com/rubocop/rubocop)
|
|
6
|
+
|
|
7
|
+
A lightweight Ruby gem for executing NRQL queries against New Relic's NerdGraph API. Skip the boilerplate and get straight to your data.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Simple, intuitive API for NRQL queries
|
|
12
|
+
- Works as a library or command-line tool
|
|
13
|
+
- Environment variable or explicit credential configuration
|
|
14
|
+
- Returns parsed JSON results ready for use
|
|
6
15
|
|
|
7
16
|
## Installation
|
|
8
17
|
|
|
9
|
-
|
|
18
|
+
Add to your Gemfile:
|
|
10
19
|
|
|
11
|
-
|
|
20
|
+
```ruby
|
|
21
|
+
gem "nrql2nerd"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or install directly:
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
```bash
|
|
27
|
+
gem install nrql2nerd
|
|
28
|
+
```
|
|
14
29
|
|
|
15
|
-
|
|
30
|
+
## Configuration
|
|
31
|
+
|
|
32
|
+
Set your New Relic credentials via environment variables:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
export NEW_RELIC_API_KEY="your-api-key"
|
|
36
|
+
export NEW_RELIC_ACCOUNT_ID="your-account-id"
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or pass them explicitly when creating a client.
|
|
16
40
|
|
|
17
41
|
## Usage
|
|
18
|
-
|
|
42
|
+
|
|
43
|
+
### As a Library
|
|
19
44
|
|
|
20
45
|
```ruby
|
|
21
|
-
|
|
46
|
+
require "nrql2nerd"
|
|
47
|
+
|
|
48
|
+
client = NRQL2Nerd::Client.new
|
|
49
|
+
results = client.run_query("SELECT count(*) FROM Transaction SINCE 1 hour ago")
|
|
22
50
|
|
|
23
|
-
# => [
|
|
24
|
-
# {
|
|
25
|
-
# "appId"=>12345,
|
|
26
|
-
# "message"=>"Some Message"
|
|
27
|
-
# ...
|
|
28
|
-
# }
|
|
29
|
-
#]
|
|
51
|
+
# => [{"count" => 42}]
|
|
30
52
|
```
|
|
31
|
-
|
|
53
|
+
|
|
54
|
+
With explicit credentials:
|
|
55
|
+
|
|
56
|
+
```ruby
|
|
57
|
+
client = NRQL2Nerd::Client.new(
|
|
58
|
+
api_key: "your-api-key",
|
|
59
|
+
account_id: "12345"
|
|
60
|
+
)
|
|
32
61
|
```
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
62
|
+
|
|
63
|
+
### Command Line
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Using environment variables
|
|
67
|
+
nrql2nerd -q "SELECT count(*) FROM Transaction SINCE 1 hour ago"
|
|
68
|
+
|
|
69
|
+
# With explicit credentials
|
|
70
|
+
nrql2nerd -q "SELECT * FROM Transaction LIMIT 10" \
|
|
71
|
+
--api-key your-api-key \
|
|
72
|
+
--account-id 12345
|
|
41
73
|
```
|
|
42
74
|
|
|
43
|
-
|
|
75
|
+
A shorter alias `n2n` is also available:
|
|
44
76
|
|
|
45
|
-
|
|
77
|
+
```bash
|
|
78
|
+
n2n -q "SELECT count(*) FROM PageView SINCE 1 day ago"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Development
|
|
46
82
|
|
|
47
|
-
|
|
83
|
+
```bash
|
|
84
|
+
bin/setup # Install dependencies
|
|
85
|
+
bundle exec rake # Run tests and linting
|
|
86
|
+
bin/console # Interactive prompt
|
|
87
|
+
```
|
|
48
88
|
|
|
49
89
|
## Contributing
|
|
50
90
|
|
|
51
|
-
Bug reports and pull requests are welcome on GitHub
|
|
91
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/aladac/nrql2nerd). Please follow the [code of conduct](https://github.com/aladac/nrql2nerd/blob/main/CODE_OF_CONDUCT.md).
|
|
52
92
|
|
|
53
93
|
## License
|
|
54
94
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
## Code of Conduct
|
|
58
|
-
|
|
59
|
-
Everyone interacting in the NRQL2Nerd project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/nrql2nerd/blob/main/CODE_OF_CONDUCT.md).
|
|
95
|
+
Available as open source under the [MIT License](https://opensource.org/licenses/MIT).
|
data/exe/n2n
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nrql2nerd
|
data/lib/nrql2nerd/client.rb
CHANGED
data/lib/nrql2nerd/version.rb
CHANGED
data/sig/nrql2nerd.rbs
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
module NRQL2Nerd
|
|
2
2
|
VERSION: String
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
class Error < StandardError
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class Client
|
|
8
|
+
@api_key: String
|
|
9
|
+
@account_id: String
|
|
10
|
+
|
|
11
|
+
def initialize: (?api_key: String?, ?account_id: String?) -> void
|
|
12
|
+
def graphql_nrql_query: (String query) -> String
|
|
13
|
+
def graphql_hash: (String query) -> Hash[Symbol, String]
|
|
14
|
+
def prepare_query: (String query) -> String
|
|
15
|
+
def client: () -> Net::HTTP
|
|
16
|
+
def uri: () -> URI::HTTPS
|
|
17
|
+
def make_query_request: (String query) -> Net::HTTPResponse
|
|
18
|
+
def run_query: (String query) -> Array[Hash[String, untyped]]?
|
|
19
|
+
end
|
|
4
20
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nrql2nerd
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Adam Ladachowski
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A tool to Send NRQL queries to New Relic API and get results in NerdGraph
|
|
14
14
|
format
|
|
@@ -20,7 +20,9 @@ executables:
|
|
|
20
20
|
extensions: []
|
|
21
21
|
extra_rdoc_files: []
|
|
22
22
|
files:
|
|
23
|
+
- ".rspec"
|
|
23
24
|
- ".rubocop.yml"
|
|
25
|
+
- ".tool-versions"
|
|
24
26
|
- CHANGELOG.md
|
|
25
27
|
- CODE_OF_CONDUCT.md
|
|
26
28
|
- LICENSE.txt
|
|
@@ -40,7 +42,7 @@ metadata:
|
|
|
40
42
|
source_code_uri: https://github.com/aladac/nrql2nerd/blob/main
|
|
41
43
|
changelog_uri: https://github.com/aladac/nrql2nerd/blob/main/CHANGELOG.md
|
|
42
44
|
rubygems_mfa_required: 'true'
|
|
43
|
-
post_install_message:
|
|
45
|
+
post_install_message:
|
|
44
46
|
rdoc_options: []
|
|
45
47
|
require_paths:
|
|
46
48
|
- lib
|
|
@@ -55,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
55
57
|
- !ruby/object:Gem::Version
|
|
56
58
|
version: '0'
|
|
57
59
|
requirements: []
|
|
58
|
-
rubygems_version: 3.5.
|
|
59
|
-
signing_key:
|
|
60
|
+
rubygems_version: 3.5.22
|
|
61
|
+
signing_key:
|
|
60
62
|
specification_version: 4
|
|
61
63
|
summary: Send NRQL queries to New Relic API and get results in NerdGraph format
|
|
62
64
|
test_files: []
|
data/exe/n2n
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
# frozen_string_literal: true
|
|
3
|
-
|
|
4
|
-
require "nrql2nerd"
|
|
5
|
-
require "optparse"
|
|
6
|
-
require "json"
|
|
7
|
-
|
|
8
|
-
options = {}
|
|
9
|
-
api_key = nil
|
|
10
|
-
account_id = nil
|
|
11
|
-
|
|
12
|
-
OptionParser.new do |opts|
|
|
13
|
-
opts.banner = "Usage: nrql2nerd [options]"
|
|
14
|
-
|
|
15
|
-
opts.on("-q", "--query QUERY", "NRQL query string") do |q|
|
|
16
|
-
options[:query] = q
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
opts.on("--api-key KEY", "New Relic API key") do |key|
|
|
20
|
-
api_key = key
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
opts.on("--account-id ID", "New Relic account ID") do |id|
|
|
24
|
-
account_id = id
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
opts.on("-h", "--help", "Prints this help") do
|
|
28
|
-
puts opts
|
|
29
|
-
exit
|
|
30
|
-
end
|
|
31
|
-
end.parse!
|
|
32
|
-
|
|
33
|
-
if options[:query]
|
|
34
|
-
client = NRQL2Nerd::Client.new(api_key: api_key, account_id: account_id)
|
|
35
|
-
result = client.run_query(options[:query])
|
|
36
|
-
puts JSON.pretty_generate(result)
|
|
37
|
-
else
|
|
38
|
-
puts "Error: Query is required. Use -q or --query to specify the NRQL query."
|
|
39
|
-
exit 1
|
|
40
|
-
end
|