agentleFS
tkollehtkolleh/skills/newrelic-cli/SKILL.md

newrelic-cli

Skill1 starsChanged 3 months agoMITView on GitHub

Query and manage New Relic observability data using the newrelic CLI across all your organization's accounts. Trigger on: newrelic, nrql, apm, deployment marker, alert policy, observability query, error rate, throughput, latency, SLO/SLI.

  • Reads credentials
  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If the user names an environment (e.g.

    line 28
  2. Very specific:

    If they name a slot (e.g. "services", "envoy", "cardinal"), match against the slot field within the target environment.

    line 30
  3. Distinctive:

    If they give a numeric account ID, use it directly.

    line 32
  4. Very specific:

    If they name an alias (e.g.

    line 33
  5. Distinctive:

    Defaults: when no account is specified:

    line 35
  6. Very specific:

    Always confirm which account you resolved to before running the query, e.g.: "Querying Services Production ($ACCOUNT_ID)..."

    line 41
  7. Very specific:

    Resolve account: Read accounts.json, match environment/slot/alias.

    line 134
  8. Distinctive:

    Execute: Run via Bash and return results.

    line 137
  9. Distinctive:

    When a question spans multiple accounts (e.g.

    line 173
  10. Very specific:

    If newrelic is not installed, suggest: brew install newrelic-cli

    line 179
  11. Very specific:

    If authentication fails, check newrelic profile list and suggest newrelic profile add

    line 180
  12. Distinctive:

    If an account ID is ambiguous (e.g.

    line 182

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

What this skill does

Translates natural-language observability questions into newrelic CLI commands, resolving account names to numeric IDs automatically. It knows every New Relic account, which environment and service slot each belongs to, and which region (US/EU) to use.

Account resolution

A bundled accounts.json (sibling to this file) maps every New Relic account. Read it at the start of any task to resolve accounts.

Resolution rules

  1. If the user names an environment (e.g. "production", "test", "uk-prod"), match against the environment field.
  2. If they name a slot (e.g. "services", "envoy", "cardinal"), match against the slot field within the target environment.
  3. If they give a numeric account ID, use it directly.
  4. If they name an alias (e.g. "Acme_Corp_1", "My_Org"), match against the alias field.
  5. Defaults when no account is specified:
    • Service-specific queries (transactions, throughput, errors) -> $DEFAULT_SERVICES_ACCOUNT
    • General queries (infrastructure, custom events) -> $DEFAULT_MAIN_ACCOUNT

Always confirm which account you resolved to before running the query, e.g.: "Querying Services Production ($ACCOUNT_ID)..."

CLI command reference

NRQL queries

The most common operation. Always include --accountId and default to --format JSON for structured output.

newrelic nrql query --accountId <ID> --query '<NRQL>' --format JSON

Example patterns:

# Transaction throughput
newrelic nrql query --accountId $ACCOUNT_ID \
  --query "SELECT rate(count(*), 1 minute) FROM Transaction WHERE appName = 'my-service' TIMESERIES SINCE 1 hour ago" \
  --format JSON

# Error rate
newrelic nrql query --accountId $ACCOUNT_ID \
  --query "SELECT percentage(count(*), WHERE error IS true) FROM Transaction WHERE appName = 'my-service' SINCE 1 hour ago" \
  --format JSON

# P99 latency
newrelic nrql query --accountId $ACCOUNT_ID \
  --query "SELECT percentile(duration, 99) FROM Transaction WHERE appName = 'my-service' TIMESERIES SINCE 1 hour ago" \
  --format JSON

Entity search

Find applications, hosts, containers, and other entities.

newrelic entity search --name <NAME>
newrelic entity search --name <NAME> --domain APM --type APPLICATION
newrelic entity search --tag "environment:production"

Useful filters: --domain (APM, INFRA, BROWSER, SYNTH, etc.), --type (APPLICATION, HOST, CONTAINER, etc.), --tag, --alert-severity, --reporting.

APM operations

# Search for an application
newrelic apm application search --accountId <ID> --name <APP_NAME>

# Record a deployment
newrelic apm deployment create --applicationId <APP_ID> --revision <SHA>

Profile management

Profiles store API keys and default account IDs for repeated use.

newrelic profile list
newrelic profile add --name <PROFILE> --apiKey <KEY> --region <US|EU> --accountId <ID>
newrelic profile default --name <PROFILE>

NerdGraph (GraphQL)

For advanced queries not covered by built-in commands.

newrelic nerdgraph query '{ actor { user { email } } }'

Custom events

newrelic events post --accountId <ID> --event '{"eventType":"Deployment","revision":"abc123"}'

Environment variables

VariablePurpose
NEW_RELIC_API_KEYPersonal API key (NRAK-...)
NEW_RELIC_ACCOUNT_IDDefault account ID
NEW_RELIC_REGIONUS (default) or EU
NEW_RELIC_LICENSE_KEYLicense key (for posting events)

Workflow

  1. Parse intent: What does the user want to know or do?
  2. Resolve account: Read accounts.json, match environment/slot/alias.
  3. Build command: Construct the newrelic CLI invocation.
  4. Show the user: Display the resolved account and command before running.
  5. Execute: Run via Bash and return results.
  6. Interpret: Summarize the data in plain language -- highlight anomalies, trends, or notable values.

Common NRQL patterns

These patterns cover the most frequent observability questions:

-- Service health overview
SELECT count(*), average(duration), percentage(count(*), WHERE error IS true)
FROM Transaction WHERE appName = '{service}'
SINCE 1 hour ago

-- Top slow transactions
SELECT average(duration), count(*)
FROM Transaction WHERE appName = '{service}'
FACET name SINCE 1 hour ago LIMIT 10

-- Error breakdown
SELECT count(*) FROM TransactionError
WHERE appName = '{service}' FACET error.class SINCE 1 hour ago

-- Infrastructure (CPU/memory) -- use main account
SELECT average(cpuPercent), average(memoryUsedPercent)
FROM SystemSample WHERE hostname LIKE '%{service}%'
SINCE 1 hour ago TIMESERIES

-- Kafka consumer lag -- use services account
SELECT average(consumer.totalLag)
FROM KafkaOffsetSample WHERE consumerGroup LIKE '%{service}%'
FACET topic SINCE 1 hour ago

Multi-account queries

When a question spans multiple accounts (e.g. "compare prod vs test error rates"), run separate queries against each account and present the results side by side. Label each result clearly with the account name and environment.

Error handling

  • If newrelic is not installed, suggest: brew install newrelic-cli
  • If authentication fails, check newrelic profile list and suggest newrelic profile add
  • If an account ID is ambiguous (e.g. "services" without an environment), ask the user to clarify which environment

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.