Skip to content

Commit

Permalink
[INLONG-11499][Agent] By default, use the locally configured audit ad…
Browse files Browse the repository at this point in the history
…dress (apache#11500)
  • Loading branch information
justinwwhuang authored Nov 15, 2024
1 parent f493862 commit 8942f35
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class AgentConstants {

public static final String AUDIT_ENABLE = "audit.enable";
public static final boolean DEFAULT_AUDIT_ENABLE = true;
public static final String AUDIT_PROXY_ADDRESS = "audit.proxys";

public static final String AGENT_HISTORY_PATH = "agent.history.path";
public static final String DEFAULT_AGENT_HISTORY_PATH = ".history";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
import org.apache.inlong.audit.AuditOperator;
import org.apache.inlong.audit.entity.AuditComponent;

import java.util.HashSet;

import static org.apache.inlong.agent.constant.AgentConstants.AUDIT_ENABLE;
import static org.apache.inlong.agent.constant.AgentConstants.AUDIT_PROXY_ADDRESS;
import static org.apache.inlong.agent.constant.AgentConstants.DEFAULT_AUDIT_ENABLE;
import static org.apache.inlong.agent.constant.FetcherConstants.AGENT_MANAGER_ADDR;
import static org.apache.inlong.agent.constant.FetcherConstants.AGENT_MANAGER_AUTH_SECRET_ID;
Expand Down Expand Up @@ -67,8 +70,14 @@ public class AuditUtils {
public static void initAudit(AbstractConfiguration conf) {
IS_AUDIT = conf.getBoolean(AUDIT_ENABLE, DEFAULT_AUDIT_ENABLE);
if (IS_AUDIT) {
AuditOperator.getInstance().setAuditProxy(AuditComponent.AGENT, conf.get(AGENT_MANAGER_ADDR),
conf.get(AGENT_MANAGER_AUTH_SECRET_ID), conf.get(AGENT_MANAGER_AUTH_SECRET_KEY));
if (conf.hasKey(AUDIT_PROXY_ADDRESS)) {
HashSet<String> address = new HashSet<>();
address.add(conf.get(AUDIT_PROXY_ADDRESS));
AuditOperator.getInstance().setAuditProxy(address);
} else {
AuditOperator.getInstance().setAuditProxy(AuditComponent.AGENT, conf.get(AGENT_MANAGER_ADDR),
conf.get(AGENT_MANAGER_AUTH_SECRET_ID), conf.get(AGENT_MANAGER_AUTH_SECRET_KEY));
}
AuditOperator.getInstance().setLocalIP(conf.get(AgentConstants.AGENT_LOCAL_IP));
}
}
Expand Down
4 changes: 4 additions & 0 deletions inlong-agent/conf/agent.properties
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,7 @@ agent.prometheus.exporter.port=9080
############################
# whether to enable audit
audit.enable=true
# Audit proxy address
# By default, the audit address is obtained from the manager, and only in special circumstances do
# special addresses need to be specified through this configuration option
# audit.proxys=

0 comments on commit 8942f35

Please sign in to comment.