Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCI split data in different tables #11499

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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 @@ -53,6 +53,22 @@
process_events(stream_client, StreamOcid, cursor, limit, sentinel_connector, start_ts)
logging.info(f'Function finished. Sent events {sentinel_connector.successfull_sent_events_number}.')


def determine_log_type(event):
event_type = event.get("type", "default")
if event_type == "com.oraclecloud.loadbalancer.access" or event_type == "com.oraclecloud.loadbalancer.error" or event_type == "com.oraclecloud.loadbalancer.waf":
return "OCI_LoadBalancerLogs"
# elif event_type == "com.oraclecloud.loadbalancer.error":
# return "OCI_LoadBalancerLogs"
Comment on lines +64 to +65

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
elif event_type == "com.oraclecloud.audit":
return "OCI_AuditLogs"
elif event_type == "com.oraclecloud.virtualNetwork.ListRouteTables" or event_type == "com.oraclecloud.virtualNetwork.ListNetworkSecurityGroupSecurityRules" or event_type == "com.oraclecloud.virtualNetwork.GetSubnet" or event_type == "com.oraclecloud.virtualNetwork.ListSubnets" or event_type == "com.oraclecloud.virtualNetwork.ListSecurityLists":
return "OCI_VirtualNetworkLogs"
elif event_type == "com.oraclecloud.compute.instance":
return "OCI_ComputeInstanceLogs"
else:
return "OCI_Logs" # Default log type

def parse_key(key_input):
try:
begin_line = re.search(r'-----BEGIN [A-Z ]+-----', key_input).group()
Expand Down Expand Up @@ -127,6 +143,8 @@
#if event != 'ok' and event != 'Test':
event = json.loads(event)
if "data" in event:
# Determine table based on event type
log_type = determine_log_type(event)
if "request" in event["data"] and event["type"] != "com.oraclecloud.loadbalancer.access":
if event["data"]["request"] is not None and "headers" in event["data"]["request"]:
event["data"]["request"]["headers"] = json.dumps(event["data"]["request"]["headers"])
Expand All @@ -143,6 +161,7 @@
if event["data"]["stateChange"] is not None and "current" in event["data"]["stateChange"] :
event["data"]["stateChange"]["current"] = json.dumps(
event["data"]["stateChange"]["current"])
sentinel.log_type = log_type
sentinel.send(event)

sentinel.flush()
Expand Down
Binary file not shown.