nrql2nerd 0.1.0 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddaca5d74da000d97860a064875d2409877798267416701bc9fbb236ae14e2a5
4
- data.tar.gz: 672ed206989168c77f0fe1064c4696568e49d1b9476108969b63f63d457bc8ec
3
+ metadata.gz: 55cbb1993b307f9359b4807038edafe404b43e8dedbb5bffd4775d25b499bcaf
4
+ data.tar.gz: db521f81734c56040b140f59390211b40ab0ef1532b38d33203d76f3852722a5
5
5
  SHA512:
6
- metadata.gz: c01f9e36d7dfdfb08b75dbe25a410ecaed1ed58d12aead8bb83b4e6366c42df21e79fb5c9548740b375a50892eef8435aeb96d7376858b0eefdc7b3d4d303893
7
- data.tar.gz: d51dfe7b49a9f0de1f76b388ea3b4f11651982d173781665f7cf474ad0c622f51ad1e643118c53b93c51ad6decdb8b21c5fae4b46c5f1f633996301f32fdd519
6
+ metadata.gz: '0976bf74faa4920520e35ad12167698b4abb02af8aa6d5a1a78cbd238451561a2ef5f870030177f3f7667ace1793a2f7d99b688db409faa12bd9d216dae4156f'
7
+ data.tar.gz: daf3fd5ddbfe173b5fe30036b2a440282ee85b90d010ff9aa4ccb42ab14e1b33c2f7f39d21153ef75adb16fa076cdaa221e9577b4b71080373bcad64b662bed5
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --format documentation
3
+ --color
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
  [![Ruby](https://github.com/aladac/nrql2nerd/actions/workflows/main.yml/badge.svg)](https://github.com/aladac/nrql2nerd/actions/workflows/main.yml)
3
4
  [![Gem Version](https://badge.fury.io/rb/nrql2nerd.svg)](https://badge.fury.io/rb/nrql2nerd)
5
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](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
- This gem is a very simple lib which allows to directly execute `NRQL` queries on New Relic using the Nerd Graph API.
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
- Install the gem and add to the application's Gemfile by executing:
18
+ Add to your Gemfile:
10
19
 
11
- $ bundle add nrql2nerd
20
+ ```ruby
21
+ gem "nrql2nerd"
22
+ ```
23
+
24
+ Or install directly:
12
25
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
26
+ ```bash
27
+ gem install nrql2nerd
28
+ ```
14
29
 
15
- $ gem install nrql2nerd
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
- ### As a lib
42
+
43
+ ### As a Library
19
44
 
20
45
  ```ruby
21
- NRQL2Nerd.run_query("SELECT * from AjaxRequest where requestUrl like '%api%' LIMIT MAX")
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
- ### As a command line tool
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
- $ nrql2nerd "SELECT * from AjaxRequest where requestUrl like '%api%' LIMIT MAX"
34
- [
35
- {
36
- "appId"=>12345,
37
- "message"=>"Some Message"
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
- ## Development
75
+ A shorter alias `n2n` is also available:
44
76
 
45
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
77
+ ```bash
78
+ n2n -q "SELECT count(*) FROM PageView SINCE 1 day ago"
79
+ ```
80
+
81
+ ## Development
46
82
 
47
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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 at https://github.com/aladac/nrql2nerd. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/nrql2nerd/blob/main/CODE_OF_CONDUCT.md).
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
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
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
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NRQL2Nerd
4
- class Error < StandardError; end
5
-
6
4
  class Client
7
5
  def initialize(api_key: nil, account_id: nil)
8
6
  @api_key = ENV.fetch("NEW_RELIC_API_KEY", api_key)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NRQL2Nerd
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.3"
5
5
  end
data/sig/nrql2nerd.rbs CHANGED
@@ -1,4 +1,20 @@
1
1
  module NRQL2Nerd
2
2
  VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
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.0
4
+ version: 0.1.3
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: 2024-09-27 00:00:00.000000000 Z
11
+ date: 2026-02-03 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.16
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