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

ECI-393 Add Networking and Policy Sub-Modules #20

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

sva91
Copy link
Contributor

@sva91 sva91 commented Dec 4, 2024

What

  • Add Networking Sub-Module for Log Forwarding Setup
  • Add Policy sub-module for Log Forwarding Setup
  • Includes the following two enhancements
  1. Show VCN and Subnet fields only if create_vcn is not selected.
  2. Do not show tenancy, region and compartment to reduce confusion

Why

  • Setting up infrastructure for log forwarding

Testing

@sva91 sva91 marked this pull request as ready for review December 4, 2024 20:23
@sva91 sva91 added the eci label Dec 4, 2024
@sva91 sva91 requested a review from a team December 5, 2024 21:57
@sva91 sva91 changed the title Sva91/log forwarding automation modules ECI-393 Add Networking and Policy Sub-Modules Dec 10, 2024
First, install the required dependencies listed in the `requirements.txt` file. You can do this using `pip`:

```sh
pip install -r requirements.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this should be done as a part of this PR but IMO it is not clear to customers where they should run this. eg cloud shell? IMO the docs we currently have could use more hand-holding, for example how does one create a boilerplate python function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the purpose of this project, this readme can be considered applicable only for developers who are making changes to the python function. That includes mostly the Datadog team, but if there are external contributors, they can benefit from these steps as well. These steps shouldn't be executed from within customer's OCI environment.

DD_SOURCE = "oracle_cloud" # Adding a source name.
DD_SERVICE = "OCI Logs" # Adding a service name.
DD_TIMEOUT = 10 * 60 # Adding a timeout for the Datadog API call.
DD_BATCH_SIZE = 1000 # Adding a batch size for the Datadog API call.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a max size that can be sent to DD logs endpoint? I see that this batch is 1000 logs but I'm curious if we might need to enforce a size in bytes that are sent via the API?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the max size for the batch size is 1000, as enforced by Datadog. Since, logs are compressed before calling API, I think the byte limit shouldn't be a problem. Here are the limits: https://docs.datadoghq.com/api/latest/logs/#send-logs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The byte limit of 5Mb is on uncompressed payload. Even if sent compressed, it is uncompressed on EvP intake and then evaluated for its size.

Ideally, we can control byte limit by ensuring not more than 5Mb sent through connector hub

return os.environ.get("DD_COMPRESS", "true").lower() == "true"


def _compress_payload(payload: list[dict]):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be good to have ther return type defined here so it's clear this can return two different types of data

This function receives the logging json and invokes the Datadog endpoint
for ingesting logs. https://docs.cloud.oracle.com/en-us/iaas/Content/Logging/Reference/top_level_logging_format.htm#top_level_logging_format
If this Function is invoked with more than one log the function go over
each log and invokes the Datadog endpoint for ingesting one by one.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the logs ingested one by one? It looks like they are ingested in batches of 1000?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are ingested in batches of 1000. When the function gets invoked, and if there are more than 1000 logs to be transmitted to Datadog, one function invocation will break them into batches of 1000, and make multiple API calls to datadog.

* Add Function App Module

* Add container registry login functionality

* reviewers comments

* add service user optionality

* ECI-394 Add function module and complete container registry module. (#22)

* build and push image

* Add function module

* uncomment accidental comments

* remove unnecessary code

* Update datadog-logs-oci-orm/modules/containerregistry/locals.tf
rheei and others added 15 commits January 13, 2025 12:08
ECI [OCI] include more log attributes and assign "DD_SOURCE" based on OCI service
* working draft commit

* Logging Module

* uncomment modules

* simplify file removal

* Rename Logging Module to ResourceDiscovery

* reviewer comments
ECI-395
ECI-453 [OCI] add redaction option for sensitive log fields
* prepare tuples for log forwarding

* Testing Issues resolution

* uncomment code

* rename data variable

* move log search outside compartment in logging module

* update output

* simplify resource creation

* Sva91/eci 397 handle audit log configs (#32)

* ECI-397 Add Audit Log Forwarding

* Uncomment audit log name

* reviewer comment

* ECI-398 Add connectorhub module (#35)

* ECI-398 Add connectorhub module

* fix bugs

* simplify audit log input

* uncomment modules

* Sva91/ECI-399 E2E logs private beta update stack (#36)

* modify as per updated requirements

* remove resource prefix from policy

* fix bug

* fix login issue

* Reviewer comments
ECI-399

* Reviewer comments

* reviewer comments
ECI-396
Copy link
Contributor

@kanishktripathi kanishktripathi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few comments. We can also discuss about the logging module

variable "datadog_tags" {
type = string
default = ""
description = "The tags to be sent with the logs. The tags should be in the format key1:value1,key2:value2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we checking if the tags are in correct format?

@@ -1,3 +1,9 @@
*.pyc
**/__pycache__/**
.idea/
**/.terraform/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to have this part merged now since it'll benefit anyone running terraform locally

@@ -0,0 +1,15 @@
#!/bin/bash

output_file="oci_logging_services.json"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on doing it through python where we have more flexibility like exception handling?

DD_SOURCE = "oracle_cloud" # Adding a source name.
DD_SERVICE = "OCI Logs" # Adding a service name.
DD_TIMEOUT = 10 * 60 # Adding a timeout for the Datadog API call.
DD_BATCH_SIZE = 1000 # Adding a batch size for the Datadog API call.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The byte limit of 5Mb is on uncompressed payload. Even if sent compressed, it is uncompressed on EvP intake and then evaluated for its size.

Ideally, we can control byte limit by ensuring not more than 5Mb sent through connector hub

echo "$response" > "$output_file"

# Output the response in a valid JSON map for Terraform's external data source
content=$(jq -c . < "$output_file") # Ensure the file's content is compact JSON
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the sample output of this be documented?

Also, it'll be more readable to use python for better handling and for exception handling. If not immediately but as a follow-up

while [ "$next_page" != "null" ]; do
if [ "$next_page" == "init" ]; then
# First query without next page token
response=$(oci search resource structured-search --query-text \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a trade-off between doing this search for single compartment or doing it for multiple compartments like:
(compartmentId = 'id1' || compartmentId = 'id2')
Can save on the API calls.

log_group_ids_string = join(",", [for lg in local.flat_log_groups : lg.id])
}

data "external" "logs_outside_compartment" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be good to explain the steps being done here and in the underlying script. The reason to fetch log resources for other compartments.

}

# Step 1: Fetch all compartments in the tenancy
data "oci_identity_compartments" "all_compartments" {
Copy link
Contributor

@kanishktripathi kanishktripathi Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this module runs for every logging compartment in a loop
in datadog-logs-oci-orm/main.tf, then is this step run every time? If yes, this can be minimized by running once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants