Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.ranger.metrics.source.RangerAdminMetricsSourceContextEnricher;
import org.apache.ranger.metrics.source.RangerAdminMetricsSourceDenyConditions;
import org.apache.ranger.metrics.source.RangerAdminMetricsSourceGds;
import org.apache.ranger.metrics.source.RangerAdminMetricsSourcePolicyMasking;
import org.apache.ranger.metrics.source.RangerAdminMetricsSourcePolicyResourceAccess;
import org.apache.ranger.metrics.source.RangerAdminMetricsSourcePolicyRowFiltering;
Expand Down Expand Up @@ -72,6 +73,9 @@ public class RangerAdminMetricsWrapper {
@Autowired
private RangerAdminMetricsSourceSummary summarySource;

@Autowired
private RangerAdminMetricsSourceGds gdsSource;

@PostConstruct
public void init() {
LOG.info("===>> RangerAdminMetricsWrapper.init()");
Expand Down Expand Up @@ -100,6 +104,9 @@ public void init() {
//Source: Summary
sourceWrappers.add(new RangerMetricsSourceWrapper("RangerAdminMetricsSourceSummary", "Summary in Ranger Admin", context, summarySource));

//Source: Gds
sourceWrappers.add(new RangerMetricsSourceWrapper("RangerAdminMetricsSourceGds", "Gds in Ranger Admin", context, gdsSource));

rangerMetricsSystemWrapper.init(context, sourceWrappers, Collections.emptyList());
} catch (Exception e) {
LOG.error("RangerAdminMetricsWrapper: Exception occured while initializing Metric Starter:", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ public Map<String, Long> getSummary() {
//policies
ret.put("TotalPolicies", summaryPolicy.values().stream().mapToLong(Long::longValue).sum());

//securityzones
ret.put("TotalSecurityZones", daoMgr.getXXSecurityZoneDao().getAllCount());

//x_trx_log_v2
ret.put("TotalAdminAudits", daoMgr.getXXTrxLogV2().getAllCount());

Expand All @@ -187,4 +190,22 @@ public Map<String, Long> getSummary() {

return ret;
}

public Map<String, Long> getGdsMetrics() {
Map<String, Long> ret = new HashMap<>();

//x_gds_dataset
ret.put("Dataset", daoMgr.getXXGdsDataset().getAllCount());

//x_gds_data_share
ret.put("DataShare", daoMgr.getXXGdsDataShare().getAllCount());

//x_gds_shared_resource
ret.put("SharedResource", daoMgr.getXXGdsSharedResource().getAllCount());

//x_gds_project
ret.put("Project", daoMgr.getXXGdsProject().getAllCount());

return ret;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.ranger.metrics.source;

import org.apache.ranger.metrics.RangerMetricsFetcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class RangerAdminMetricsSourceGds extends RangerAdminMetricsSourceBase {
@Autowired
private RangerMetricsFetcher rangerMetricsFetcher;

public RangerAdminMetricsSourceGds() {
super("admin", "Gds");
}

@Override
protected void refresh() {
Map<String, Long> gdsMetrics = rangerMetricsFetcher.getGdsMetrics();

addMetricEntries("GdsCount", gdsMetrics);
}
}