feat(scorecard): add the ability to drill down into aggregated scorecard data - #2350
Conversation
|
Important This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior. Changed Packages
|
8398560 to
283d5e7
Compare
PR Compliance Guide 🔍(Compliance updated until commit bc10a2a)Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label Previous compliance checksCompliance check up to commit 64777b9
Compliance check up to commit 338421c
Compliance check up to commit a14730f
Compliance check up to commit 8dec549
Compliance check up to commit 9d3523a
Compliance check up to commit 1ec8035
Compliance check up to commit 8398560
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Latest suggestions up to bc10a2a
Previous suggestionsSuggestions up to commit 64777b9
Suggestions up to commit 338421c
Suggestions up to commit 8dec549
✅ Suggestions up to commit 8398560
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
56ff951 to
9d3523a
Compare
8dec549 to
a14730f
Compare
Eswaraiahsapram
left a comment
There was a problem hiding this comment.
Thanks @PatAKnight . I tested the endpoints, and they look good to me. The response also matches the Figma design.
@dzemanov / @imykhno , Could you please review this and share your +1 so we can proceed with the merge? Once this is merged, I can move forward with the frontend work and skip the dummy response implementation on the FE side.
/lgtm
endpoint - http://localhost:7007/api/scorecard/metrics/jira.open_issues/catalog/aggregations/entities?page=2&pageSize=1
Response
{
"metricId": "jira.open_issues",
"metricMetadata": {
"title": "Jira open blocking tickets",
"description": "Highlights the number of issues that are currently open in Jira.",
"type": "number"
},
"entities": [
{
"entityRef": "component:default/all-scorecards-service-different-owner",
"entityName": "all-scorecards-service-different-owner",
"entityKind": "Component",
"owner": "group:default/red-hat",
"metricValue": 0,
"timestamp": "2026-02-24T13:02:43.957Z",
"status": "success"
}
],
"pagination": {
"page": 2,
"pageSize": 1,
"total": 3,
"totalPages": 3
}
}
dzemanov
left a comment
There was a problem hiding this comment.
Looks great @PatAKnight, only have a couple of comments.
a14730f to
338421c
Compare
338421c to
64777b9
Compare
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
…g fetch Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
…ser credentials during catalog fetch Signed-off-by: Patrick Knight <pknight@redhat.com>
…a param Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
Signed-off-by: Patrick Knight <pknight@redhat.com>
5a598cc to
539e3f1
Compare
dzemanov
left a comment
There was a problem hiding this comment.
Thank you so much!
/lgtm
/approve
|
Eswaraiahsapram
left a comment
There was a problem hiding this comment.
Thanks @PatAKnight , 🎉
/lgtm
…ard data (redhat-developer#2350) * feat(scorecard): add the ability to drill down into aggregated scorecard data Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): add tests for drill down functionality Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): add docs for drill down functionality Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): normalize owners returned from catalog Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): ensure kind and owner are case insensitive Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): add changeset Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): remove indexes from migration Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): update report.api.md Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): ensure we do not bypass catalog conditional permissions Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): ensure we utilize users credentials for batch catalog fetch Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): add input validation to the new endpoint Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): remove getAuthorizedEntityRefs as we are utilizing user credentials during catalog fetch Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): remove ownedByMe in favor of passing owner array as a param Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): move entityName filtering to the database Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): move sorting down to the database layer Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): address sonarqube findings Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): logger full error but throw generic error Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): ensure we have accurate totals when filtering entities Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): handle some review suggestions Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): add ability to filter and sort by namespace Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): handle review comments Signed-off-by: Patrick Knight <pknight@redhat.com> * feat(scorecard): handle more review comments Signed-off-by: Patrick Knight <pknight@redhat.com> --------- Signed-off-by: Patrick Knight <pknight@redhat.com> Co-authored-by: Eswaraiah Sapram <esapram@redhat.com>



User description
Hey, I just made a Pull Request!
This PR adds the ability to drill down from aggregated scorecard KPIs to view the individual entities that contribute to the overall score. This enables managers and platform engineers to identify specific services impacting metrics and troubleshoot issues at the entity level.
Included is a new endpoint
GET /metrics/:metricId/catalog/aggregations/entitiesthat includes the ability to filter by status, owner, kind, and entity name. Theownerparameter accepts multiple values (e.g.,?owner=a&owner=b, up to 50) so that frontends can implement "owned by me" scoping by passing the user's ownership refs directly. The endpoint also includes the ability to sort by entity name, owner, kind, timestamp, and metric value. Finally, offset-based pagination has been included.I also added the
entity_kindandentity_ownercolumns to themetric_values table. This allows all filtering and sorting to be performed at the database level, keeping queries efficient even at large entity counts. All filters,ORDER BY, andLIMIT/OFFSETare pushed to the database so only the requested page of rows is ever fetched.The
entityNamefilter performs a case-insensitive substring search against the full entity reference (kind:namespace/name), rather than just the entity name, which keeps it consistent with how references are stored and avoids an additional column.I also batch-fetch from the catalog using
getEntitiesByRefsto ensure metadata is accurate and up-to-date. This call also serves as the per-row authorization gate — entities the user doesn't havecatalog.entity.readaccess to are returned asnullby the catalog and are excluded from the response.Which issue(s) does this PR fix
✔️ Checklist
Testing the changes
1. Get All Entities for a Metric (Default)
2. Get Second Page (if you have multiple pages)
3. Get More Results Per Page
4. Get Entities in Error State
5. Get Only Components
6. Get Only Systems (lowercase — filter is case-insensitive)
7. Get Entities Owned by Development Guests Team
8. Get Entities Owned by Guest User
9. Get Entities Owned by Multiple Teams (repeat the
ownerparam)10. Search for "scorecard" Services (substring match against full entity ref)
11. Search Using the Full Ref Format
12. Sort by Entity Name (Alphabetically)
13. Sort by Metric Value (Highest First)
14. Combine Filters — Team Errors Sorted by Metric Value
PR Type
Enhancement
Description
Add drill-down endpoint to view individual entities contributing to aggregated scorecard metrics
Implement database-level filtering by status, owner, and kind for optimal performance
Add entity metadata columns (
entity_kind,entity_owner) tometric_valuestable with indexesSupport application-level filtering by entity name, sorting, and pagination with comprehensive tests
Include batch catalog enrichment and graceful fallback when catalog metadata unavailable
Diagram Walkthrough
File Walkthrough
7 files
Add readEntityMetricsByStatus method for filtered entity metricsAdd entity_kind and entity_owner fields to metric typesImplement getEntityMetricDetails with filtering, sorting, paginationAdd GET endpoint for entity drill-down with permission checksPopulate entity_kind and entity_owner during metric collectionAdd EntityMetricDetail and EntityMetricDetailResponse typesPass logger to CatalogMetricService constructor1 files
Create migration to add entity_kind and entity_owner columns6 files
Add comprehensive tests for readEntityMetricsByStatus functionalityAdd tests for getEntityMetricDetails with filters and sortingAdd endpoint tests for entity drill-down with permissionsUpdate tests to verify entity metadata populationAdd mock for readEntityMetricsByStatus database methodAdd getMetric mock implementation to registry2 files
Add comprehensive documentation for drill-down endpointAdd changeset for drill-down feature release