Skip to content

Add --link flag for NR deep links#84

Merged
piekstra merged 2 commits intomainfrom
piekstra/nrql-deep-links
Mar 12, 2026
Merged

Add --link flag for NR deep links#84
piekstra merged 2 commits intomainfrom
piekstra/nrql-deep-links

Conversation

@piekstra
Copy link
Copy Markdown
Collaborator

@piekstra piekstra commented Mar 12, 2026

Summary

  • Add --link flag to nrq nrql command that generates a New Relic query builder deep link URL instead of executing the query. The URL opens the query builder with the NRQL query pre-populated and auto-executed.
  • Add --link flag to nrq entities search command that includes a New Relic entity redirect URL for each entity in the output.
  • Add unit tests for deep link URL generation.

Usage

# Generate a deep link for an NRQL query (does not execute the query)
nrq nrql --link "SELECT count(*) FROM Transaction SINCE 1 hour ago"

# Search entities with deep links included in output
nrq entities search "domain = 'APM'" --link

The --link flag also works with the nrql query subcommand and composes with --since/--until flags.

Test plan

  • go build ./... passes
  • go test ./... passes
  • Manually verify nrq nrql --link "SELECT 1" outputs a valid URL
  • Manually verify nrq entities search "domain = 'APM'" --link includes LINK column
  • Verify generated URLs open correctly in browser

Add a --link flag to the nrql and entities search commands that generates
clickable New Relic deep link URLs.

For nrql: when --link is passed, outputs a URL that opens the query builder
with the query pre-populated and auto-executed, instead of running the query.

For entities search: when --link is passed, includes an entity redirect URL
for each result in the output.
- Handle json.Marshal error instead of discarding it
- Use url.Values for consistent URL query parameter encoding
- URL-encode entity GUIDs with url.PathEscape to prevent path
  traversal from base64 special characters (/, ?, #)
- Move --link check before APIClient() so deep links only require
  an account ID, not a configured API key
- Add edge-case tests for unicode, newlines, and base64 special
  characters in GUIDs
@piekstra piekstra merged commit 7575efd into main Mar 12, 2026
2 checks passed
@piekstra piekstra deleted the piekstra/nrql-deep-links branch March 12, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant