New Relic CLI Skills
Quick Decision Tree
Performance issue reported? → apm/SKILL.md
Need to query data with NRQL? → nrql/SKILL.md
Recording a deployment? → deployments/SKILL.md
Alert management? → alerts/SKILL.md
Infrastructure/host issues? → infrastructure/SKILL.md
Agent not reporting? → diagnostics/SKILL.md
Setup & Auth
CODEBLOCK0
Common One-Liners
CODEBLOCK1
Entity Reference
Find entity GUIDs (needed for API calls and deployment markers):
CODEBLOCK2
Environment Variables
| Variable | Description |
|---|
| INLINECODE6 | User key (NRAK-...) |
| INLINECODE7 |
Numeric account ID |
|
NEW_RELIC_REGION |
US or
EU |
Sub-Skills
| Sub-skill | When to use |
|---|
apm/ | Performance triage, slow transactions, error analysis |
nrql/ |
Custom queries, dashboards, ad-hoc data exploration |
|
deployments/ | Mark releases, correlate deploys with performance |
|
alerts/ | Alert policies, conditions, notification channels |
|
infrastructure/ | Host metrics, CPU/memory, process monitoring |
|
diagnostics/ | Agent health, config validation, connectivity |
Scripts
Record a deployment event |
|
scripts/top-slow-transactions.sh | Find the 10 slowest transactions |
|
scripts/error-report.sh | Recent errors with stack traces |
References
New Relic CLI 技能
快速决策树
报告了性能问题? → apm/SKILL.md
需要使用 NRQL 查询数据? → nrql/SKILL.md
记录部署? → deployments/SKILL.md
告警管理? → alerts/SKILL.md
基础设施/主机问题? → infrastructure/SKILL.md
代理未报告数据? → diagnostics/SKILL.md
设置与认证
bash
安装(手动或包管理器)
macOS(Homebrew)
brew install newrelic-cli
或从以下地址手动下载发布包:
https://github.com/newrelic/newrelic-cli/releases
解压后,将 newrelic 二进制文件放入 PATH 环境变量,然后验证:
newrelic --version
配置配置文件
newrelic profile add \
--profile default \
--apiKey $NEW
RELICAPI_KEY \
--accountId $NEW
RELICACCOUNT_ID \
--region US # 或 EU
newrelic profile default --profile default
验证
newrelic profile list
常用单行命令
bash
按名称搜索实体
newrelic entity search --name my-app
运行 NRQL 查询
newrelic nrql query --accountId $NEW
RELICACCOUNT_ID \
--query SELECT average(duration) FROM Transaction WHERE appName=my-app SINCE 1 hour ago
记录部署
newrelic apm deployment create \
--applicationId
\
--revision v1.2.3 \
--description 功能:用户认证
运行诊断
newrelic diagnose run
实体参考
查找实体 GUID(API 调用和部署标记所需):
bash
列出所有 APM 应用
newrelic entity search --name --type APPLICATION --domain APM
获取特定实体详情
newrelic entity get --guid
列出所有主机
newrelic entity search --name --type HOST
环境变量
| 变量 | 描述 |
|---|
| NEWRELICAPIKEY | 用户密钥(NRAK-...) |
| NEWRELICACCOUNTID |
数字账户 ID |
| NEWRELICREGION | US 或 EU |
子技能
自定义查询、仪表盘、临时数据探索 |
| deployments/ | 标记发布、关联部署与性能 |
| alerts/ | 告警策略、条件、通知渠道 |
| infrastructure/ | 主机指标、CPU/内存、进程监控 |
| diagnostics/ | 代理健康、配置验证、连接性 |
脚本
记录部署事件 |
| scripts/top-slow-transactions.sh | 查找最慢的 10 个事务 |
| scripts/error-report.sh | 最近的错误及堆栈跟踪 |
参考资料