An interactive command line interface for querying NRQL data.
Project description
An interactive command line interface for querying New Relic Insights event data.
About
The New Relic Insights query API is a REST API for querying Insights event data. After you supply a standard NRQL query via HTTPS request, the query API returns a JSON response for parsing.
To use the API, you need a query key. You can have multiple query keys, and any query key can be used to initiate any Insights API query. If you have multiple systems querying Insights or different data destinations, New Relic recommends you use multiple query keys to enhance data security.
To create a new query key:
Go to insights.newrelic.com > Manage data > API keys.
Select the plus icon next to the Query keys heading.
Enter a short description of the key.
Select Save your notes.
You will also need make note of your New Relic Account ID. To find the account ID for your New Relic account:
Sign in to rpm.newrelic.com.
In the URL bar, copy the number after the /accounts/ portion of the URL: https://rpm.newrelic.com/accounts/ACCOUNT_ID/
Installation
nrql-cli is available on the Python Package Index (PyPI) at https://pypi.python.org/pypi/nrql-cli
You can install nrql-cli using pip.
pip install nrql-cli
Export your Query API key and Account ID as environment variables:
export NR_API_KEY='YOUR_API_KEY'
export NR_ACCOUNT_ID='YOUR_ACCOUNT_ID'
Then, run:
nrql
This command will start the program and you can start querying your data!
Alternatively, you can run in Docker. You will need to update the Dockerfile with your API key and account id and then run:
docker build -f Dockerfile -t nrql-cli .
docker run --rm -it nrql-cli
Usage
usage: nrql [-h] [--region {EU,US}] [--env ENV] [--verbose] optional arguments: -h, --help show this help message and exit --region {EU,US}, --r {EU,US} Pass this flag to set your region (EU or US) By default the region is set to US. --env ENV, --e ENV Environment handler. --verbose, --v Pass this flag if you want the whole response.
Managing multiple accounts
If you wish to easily switch between your New Relic accounts, you can use the --env switch:
nrql --env PROD
By default, the program looks for the environment variables NR_API_KEY and NR_ACCOUNT_KEY.
If the env argument is not none, then the program appends the environment string to NR_API_KEY. For example:
NR_API_KEY_PROD
When naming your environment variables, ensure to follow this naming convention.
Support
Please note that this is offered for use as-is without warranty. You are free to use and modify as needed. It has been created for use with New Relic, but is not a supported product of New Relic
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for nrql_cli-1.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c31ccb81216583f7bd8ec54f4f3861074a67f1f733cf1cfb87c82b0e28460537 |
|
MD5 | c38c3519b8cba18ea905368352747bfb |
|
BLAKE2b-256 | ebc8c9c37df63490da0300923cdfaf288d7cbb76ceb4cb08bf2a9c8c16f2ecf2 |