Skip to content

Commit

Permalink
added query
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSh committed Nov 3, 2022
1 parent cbe7151 commit 80787e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions x-pack/plugins/cloud_security_posture/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface FindingsEvaluation {

export interface Stats extends FindingsEvaluation {
postureScore: Score;
resourcesEvaluated: number;
}

export interface GroupedFindingsEvaluation extends FindingsEvaluation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const CloudSummarySection = ({
),
},
{
title: <CompactFormattedNumber number={123456} />,
title: <CompactFormattedNumber number={complianceData.stats.resourcesEvaluated} />,
description: i18n.translate(
'xpack.csp.dashboard.summarySection.counterCard.resourcesEvaluatedDescription',
{ defaultMessage: 'Resources Evaluated' }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export interface FindingsEvaluationsQueryResult {
passed_findings: {
doc_count: number;
};
resources_evaluated: {
value: number;
};
}

export const findingsEvaluationAggsQuery = {
Expand All @@ -33,6 +36,11 @@ export const findingsEvaluationAggsQuery = {
passed_findings: {
filter: { term: { 'result.evaluation': 'passed' } },
},
resources_evaluated: {
cardinality: {
field: 'resource.id',
},
},
};

export const getEvaluationsQuery = (
Expand All @@ -50,6 +58,7 @@ export const getEvaluationsQuery = (
export const getStatsFromFindingsEvaluationsAggs = (
findingsEvaluationsAggs: FindingsEvaluationsQueryResult
): ComplianceDashboardData['stats'] => {
const resourcesEvaluated = findingsEvaluationsAggs.resources_evaluated.value;
const failedFindings = findingsEvaluationsAggs.failed_findings.doc_count || 0;
const passedFindings = findingsEvaluationsAggs.passed_findings.doc_count || 0;
const totalFindings = failedFindings + passedFindings;
Expand All @@ -61,6 +70,7 @@ export const getStatsFromFindingsEvaluationsAggs = (
totalPassed: passedFindings,
totalFindings,
postureScore,
resourcesEvaluated,
};
};

Expand Down

0 comments on commit 80787e7

Please sign in to comment.