Python wrapper scripts for Nerdgraph and REST API
-
Python 3.7
-
pip3 install requests
-
Download and unzip a release of nrpy project
The table below lists the scripts that can be used for different use cases.
No. | Use Case | Scripts |
---|
- | Update Tag value | entitytags --delTagValues "key:value" --addTags "key:value"
- | Dashboards |
- | Alerts AI |
- | CCU Consumption |
usage: entitytags.py [-h] --personalApiKey PERSONALAPIKEY [--delTagValues DELTAGVALUES] [--addTags ADDTAGS] [--rmAllInfraHostTags] [--getAllInfraHostTags]
Parameter | Note |
---|---|
personalApiKey | Personal API key of a user who can edit tags |
delTagValues | Tag Values to be deleted : owner:John |
addTags | Tags to be added : owner:Jack |
getAllInfraHostTags | pass to list all mutable tags for all infra hosts |
rmAllInfraHostTags | pass to delete all mutable tags for all infra hosts |
Supports two actions --download or --copy
usage: dashboards.py [-h] --fromAccount FROMACCOUNT --fromApiKey FROMAPIKEY --entityGuid ENTITYGUID [--download] [--copy] [--toAccount TOACCOUNT] [--toApiKey TOAPIKEY] [--toName TONAME]
Parameter | Note |
---|---|
fromAccount | Account from which dashboard is sourced |
fromApiKey | User API Key fromAccount |
entityGuid | entityGuid of dashboard (copy this from NR1 UI view metadata and tags option) |
download | Downloads the dashboard json to current directory accountId-dashboardName.json |
copy | Copies dashboard to options provided in following to... parameters |
toAccount | copy toAccount |
toApiKey | (optional) if not provided fromApiKey is used and assumed to work for toAccount |
toName | (optional) copy toName if not then copied as 'Copy of ' source dashboard name |
This script will generate a report of all conditions CCU consumption between the given SINCE
and UNTIL
date from all the accounts the user has access to.
Update the ccuconsumption.json
file with the following details:
nr_user_api_key
: User API keysince
: The start date for the report in the formatYYYY-MM-DDTHH:MM:SSZ
until
: The end date for the report in the formatYYYY-MM-DDTHH:MM:SSZ
Logs are stored in logs/nrpy.log Logging level can be set in nrpylogger.py. Default level for file and stdout is INFO
We encourage your contributions to improve nrpy! Keep in mind when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project. If you have any questions, or to execute our corporate CLA, required if your contribution is on behalf of a company, please drop us an email at opensource@newrelic.com.
A note about vulnerabilities
As noted in our security policy, New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.
If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through HackerOne.
nr-account-migration is licensed under the Apache 2.0 License.