Skip to content

Deduplicate findings and separate governance from cost - #2026

Open
mamu0 wants to merge 8 commits into
mainfrom
feat-savemoney-finding-dedup
Open

Deduplicate findings and separate governance from cost#2026
mamu0 wants to merge 8 commits into
mainfrom
feat-savemoney-finding-dedup

Conversation

@mamu0

@mamu0 mamu0 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

What

Unifies findings from AZQR, Azure Advisor and the live-scan custom analyzers on a resourceId + recommendationId key, and separates governance/diagnostic observations from actual billable waste.

Why

The same waste (e.g. an unattached disk) could be reported once per source, inflating the report and making the FinOps signal noisy. Governance findings (missing tags, wrong location, ...) were also tagged category: "cost", suggesting a "saving" that doesn't exist and risking false dedup matches.

How

  • Finding gains an optional recommendationId, normalised onto a shared vocabulary: orphan.<resourceType> for orphaned resources (any source), advisor.<recommendationTypeId>, azqr.<recommendationId>.
  • New azure/finding-dedup.ts: foldDuplicateFinding collapses an incoming AZQR finding onto an already-collected one for the same resource, keeping max severity + the only available monetary estimate, and annotating the corroborating source (Also flagged by azqr as an orphaned resource.). Applied during ingestAzqrReport. Findings without a recommendationId (all custom sentence-level findings today) never participate - no guesswork dedup.
  • New azure/finding-category.ts: custom analyzer sentences about missing tags, unpreferred location, unsupported resource type, or a failed detail lookup are now operationalExcellence instead of cost.
  • The Azure Advisor Cost query (Category eq 'Cost') is unchanged - it remains the only source of estimatedMonthlySavings.

Testing

pnpm nx run-many -t test typecheck lint build format:check -p @pagopa/dx-savemoney @pagopa/dx-cli - all green, 186 tests in savemoney (+26).

Or local usage:

pnpm nx build @pagopa/dx-cli --skip-nx-cache
azqr scan --subscription-id 0000 --mask=false --json
node ./apps/cli/bin/index.js savemoney --azqr-report ./azqr_action_plan_xxxx_yy_zz_T123456.json --format lint > savemoney_result.md

Example result:

image

Resolves: CES-2193

@mamu0
mamu0 temporarily deployed to infra-dev-ci July 29, 2026 10:48 — with GitHub Actions Inactive
@mamu0
mamu0 temporarily deployed to bootstrapper-dev-ci July 29, 2026 10:48 — with GitHub Actions Inactive
@mamu0
mamu0 temporarily deployed to bootstrapper-prod-ci July 29, 2026 10:48 — with GitHub Actions Inactive
@mamu0
mamu0 temporarily deployed to infra-prod-ci July 29, 2026 10:48 — with GitHub Actions Inactive
@mamu0 mamu0 changed the title Deduplicate findings across sources and separate governance from cost Deduplicate findings and separate governance from cost Jul 29, 2026
@mamu0
mamu0 temporarily deployed to bootstrapper-prod-ci July 29, 2026 10:59 — with GitHub Actions Inactive
@mamu0
mamu0 temporarily deployed to infra-prod-ci July 29, 2026 10:59 — with GitHub Actions Inactive
@mamu0
mamu0 temporarily deployed to bootstrapper-dev-ci July 29, 2026 10:59 — with GitHub Actions Inactive
@mamu0
mamu0 temporarily deployed to infra-dev-ci July 29, 2026 10:59 — with GitHub Actions Inactive
@mamu0
mamu0 temporarily deployed to bootstrapper-prod-ci July 29, 2026 14:01 — with GitHub Actions Inactive
@mamu0
mamu0 temporarily deployed to infra-prod-ci July 29, 2026 14:01 — with GitHub Actions Inactive
@mamu0
mamu0 temporarily deployed to bootstrapper-dev-ci July 29, 2026 14:01 — with GitHub Actions Inactive
@mamu0
mamu0 temporarily deployed to infra-dev-ci July 29, 2026 14:01 — with GitHub Actions Inactive
@mamu0
mamu0 marked this pull request as ready for review July 29, 2026 14:05
@mamu0
mamu0 requested a review from a team as a code owner July 29, 2026 14:05
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