Skip to content

Feat/legacy conditions rest fetcher#4

Merged
asomensari-es merged 8 commits into
mainfrom
feat/legacy-conditions-rest-fetcher
Jul 10, 2026
Merged

Feat/legacy conditions rest fetcher#4
asomensari-es merged 8 commits into
mainfrom
feat/legacy-conditions-rest-fetcher

Conversation

@asomensari-es

Copy link
Copy Markdown
Owner

Legacy Conditions can't be moved via Nerdgraph calls, they need to be recreated. This feature flags those legacy conditions

Adilson Somensari added 8 commits July 9, 2026 22:31
The NerdGraph WorkloadAccountStitchedFields.collection field takes a
guid: EntityGuid! argument, not id: Int!. The audit fetcher was storing
the numeric workload ID as asset_id; the cleanup deleter was trying to
look up the workload by that numeric ID which failed at runtime.

Fix: audit now stores wl.GUID as asset_id; cleanup passes the GUID
directly to collection(guid:), eliminating the broken numeric-ID lookup
step entirely.
…APIs)

service_levels: Replace two-phase entitySearch+entities approach with
actor.account.serviceLevels.serviceLevelIndicators. The original query
used ... on ServiceLevelIndicatorEntity which is not a valid NerdGraph
type — service level entities are ExternalEntity in entities(guids:)
and have no SLI-specific fields. The dedicated serviceLevels API
exposes entityGuid and events directly, with no inline fragment needed.

legacy_conditions: Remove fetcher entirely. The NerdGraph field
actor.account.alerts.conditions(policyId:) no longer exists on
AlertsAccountStitchedFields. Legacy (non-NRQL) alert conditions are
deprecated by New Relic and there is no NerdGraph replacement.
Since the NerdGraph API field for querying legacy (APM/Browser/Mobile
metric) conditions was removed, the tool can no longer scan them. Add
a static Finding per account with asset_type=legacy_condition that
surfaces in both the on-screen report and the CSV, advising users to
check policies manually and recreate any remaining conditions as NRQL.

Skippable with --skip legacy_conditions.
Large accounts hit the per-account timeout because three fetchers
independently paginate nrqlConditionsSearch (nrql_conditions,
disabled_conditions, uncovered_alert_policies). This eliminates one
of those redundant sweeps by merging nrql_conditions and
disabled_conditions into a single pass.

- Merge fetch_disabled_conditions into fetch_conditions: one scan
  now emits both hardcoded-ID findings and disabled-condition findings.
  --skip nrql_conditions suppresses both.
- Increase default --timeout from 5m to 15m.
- Print a "try --timeout 20m" hint in the report whenever any fetcher
  error contains "deadline exceeded".
…ssing NerdGraph paths

actor.account.serviceLevels does not exist, and ServiceLevelIndicatorEntity is
not a valid NerdGraph type. Switch to entitySearch with base tags fields and
extract entityGuid from the entity tag, which SLI entities expose natively.
Drop events WHERE clause scanning (not accessible via entity graph APIs).
…onfig

Replace the static legacy_conditions notice with a real fetcher that:
1. Lists all policies via NerdGraph policiesSearch
2. Calls GET /v2/alerts_conditions.json per policy via REST API v2
3. Emits findings for disabled conditions and hardcoded entity IDs

The same User API key (NRAK-...) works for both NerdGraph and REST v2.
Add RESTURL field to Region config; wire nrRESTClient in cmd/main.go.
Policies created via NerdGraph/NRQL are not registered in the REST API v2
and return 422 'Policy with ID X not found'. Treat 404 and 422 as no-op
(empty condition list) instead of an error.
…ng ones

Previously the fetcher only emitted findings for disabled conditions or
those with hardcoded entity IDs, silently skipping enabled conditions
with no entity references. Now every legacy condition gets a migration
notice (condition type + suggestion), with per-entity findings appended
when entity IDs are present.
@asomensari-es asomensari-es merged commit 4e9cb5d into main Jul 10, 2026
1 check passed
@asomensari-es asomensari-es deleted the feat/legacy-conditions-rest-fetcher branch July 10, 2026 15:26
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