Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/julien4218/cross-account-query

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/julien4218/cross-account-query

  • v0.0.0-20230306175713-8e0a76f8b414
  • Source
  • Go
  • Socket score

Version published
Created
Source

cross-account-query

A command line tool that execute multiple NRQL query accross environment and accounts.

Base query fetches the initial dataset. Column queries adds scalar data for each row in the initial dataset.

Output is displayed as CSV

Config example:

base:
  api_key: env::NEW_RELIC_MY_API_KEY
  account_id: 123456789
  region: staging
  query: SELECT something with NRQL
  select_fields:
    - account_id:AccountID
    - customer_user_id:UserID
    - timestamp
    - timestamp:CopyDateUTC

columns:
  -
    api_key: env::NEW_RELIC_MY_API_KEY
    account_id: 987654321
    region: us
    query: SELECT something else with NRQL
    select_fields:
      - is_using_something_else:IsUsingSomethingElse

api_key should be stored as environment variable and referred in the config as env::MY_KEY_NAME

batch support

config column query can be executed in batch mode, which execute much faster instead of an N+1 execution plan to leverage batching, you'll want to do the following:

  • use the can_batch: true option
  • write the query using a WHERE clause in the form of ...WHERE field1 IN (data::my_field)... so that all the field values previously queried can be injected
  • add the replaced field in the query select, so the results can be merged with the previous results

For example:

base:
  api_key: env::NEW_RELIC_MY_API_KEY
  account_id: 123456789
  region: staging
  query: SELECT something with NRQL
  select_fields:
    - account_id:AccountID
    - customer_user_id:UserID
    - timestamp
    - timestamp:CopyDateUTC

columns:
  -
    api_key: env::NEW_RELIC_MY_API_KEY
    account_id: 987654321
    region: us
    can_batch: true
    query: FROM MyTable SELECT uniqueCount(1) as 'has_data', min(customer_user_id) as 'customer_user_id' WHERE customer_user_id in (data::customer_user_id) SINCE 1 week ago facet nrAccountId as 'account_id'
    select_fields:
      - is_using_something_else:IsUsingSomethingElse

Run

go test -v ./ ./...
go run . config.yml

FAQs

Package last updated on 06 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc