Skip to content

Commit b7addc8

Browse files
RANGER-5553: Incorrect Tags count reported in SummaryTOTALTAGS metric from /service/metrics/json API
1 parent 3fd46db commit b7addc8

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

security-admin/src/main/java/org/apache/ranger/metrics/RangerMetricsFetcher.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class RangerMetricsFetcher {
5757

5858
private final HashMap<String, Long> summaryReusable = new HashMap<>();
5959
private final HashMap<Integer, Long> summaryPolicy = new HashMap<>();
60+
private final Map<Integer, Long> summaryTagPolicy = new HashMap<>();
6061

6162
public Long getGroupCount() {
6263
Long totalGroupCount = groupService.getAllGroupCount();
@@ -121,19 +122,21 @@ public Map<String, Long> getPolicyMetrics(Integer policyType) {
121122

122123
Map<String, Long> ret = new HashMap<>();
123124
long total = 0L;
125+
long totalTagPolicies = 0L;
124126

125127
for (Map.Entry<String, Long> entry : svcStore.getPolicyCountByTypeAndServiceType(policyType).entrySet()) {
126128
ret.put(entry.getKey(), entry.getValue());
127129

128130
total += entry.getValue();
129131

130132
if ("tag".equalsIgnoreCase(entry.getKey())) {
131-
summaryReusable.put("TotalTags", entry.getValue());
133+
totalTagPolicies += entry.getValue().longValue();
132134
}
133135
}
134136

135137
ret.put("Total", total);
136138
summaryPolicy.put(policyType, total);
139+
summaryTagPolicy.put(policyType, totalTagPolicies);
137140

138141
return ret;
139142
}
@@ -174,6 +177,9 @@ public Map<String, Long> getSummary() {
174177
//policies
175178
ret.put("TotalPolicies", summaryPolicy.values().stream().mapToLong(Long::longValue).sum());
176179

180+
//tag_policies
181+
ret.put("TotalTagPolicies", summaryTagPolicy.values().stream().mapToLong(Long::longValue).sum());
182+
177183
//roles
178184
ret.put("TotalRoles", daoMgr.getXXRole().getAllCount());
179185

@@ -192,6 +198,9 @@ public Map<String, Long> getSummary() {
192198
//x_policy_export_audit
193199
ret.put("TotalPluginDownloads", daoMgr.getXXPolicyExportAudit().getAllCount());
194200

201+
//x_tag
202+
ret.put("TotalTags", daoMgr.getXXTag().getAllCount());
203+
195204
return ret;
196205
}
197206

0 commit comments

Comments
 (0)