-
Notifications
You must be signed in to change notification settings - Fork 394
Add environment variable to support backend storage tag enrichment #1006
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
Changes from 3 commits
5d82d44
c9ec9ae
69d7021
c09d2a3
49b885b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,25 +4,41 @@ | |
# Copyright 2021 Datadog, Inc. | ||
|
||
|
||
import os | ||
import logging | ||
|
||
import os | ||
from concurrent.futures import as_completed | ||
|
||
from requests_futures.sessions import FuturesSession | ||
from logs.helpers import compress_logs | ||
from logs.exceptions import ScrubbingException | ||
|
||
from logs.exceptions import ScrubbingException | ||
from logs.helpers import compress_logs | ||
from settings import ( | ||
DD_USE_COMPRESSION, | ||
DD_COMPRESSION_LEVEL, | ||
DD_MAX_WORKERS, | ||
DD_FORWARDER_VERSION, | ||
DD_MAX_WORKERS, | ||
DD_USE_COMPRESSION, | ||
get_enrich_cloudwatch_tags, | ||
get_enrich_s3_tags, | ||
) | ||
|
||
logger = logging.getLogger() | ||
logger.setLevel(logging.getLevelName(os.environ.get("DD_LOG_LEVEL", "INFO").upper())) | ||
|
||
|
||
def get_dd_storage_tag_header(): | ||
storage_tag = "" | ||
|
||
if get_enrich_s3_tags(): | ||
storage_tag += "s3" | ||
|
||
if get_enrich_cloudwatch_tags(): | ||
if storage_tag != "": | ||
storage_tag += "," | ||
storage_tag += "cloudwatch" | ||
|
||
return storage_tag | ||
|
||
|
||
class DatadogHTTPClient(object): | ||
""" | ||
Client that sends a batch of logs over HTTP. | ||
|
@@ -37,6 +53,10 @@ class DatadogHTTPClient(object): | |
_HEADERS["DD-EVP-ORIGIN"] = "aws_forwarder" | ||
_HEADERS["DD-EVP-ORIGIN-VERSION"] = DD_FORWARDER_VERSION | ||
|
||
storage_tag = get_dd_storage_tag_header() | ||
if storage_tag != "": | ||
_HEADERS["DD-STORAGE-TAG"] = storage_tag | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe set the header key as a constant (now that I comment that I'd argue the other should be too) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's only used in one place. I don't think it worth it. We'll do some back and forth in code for something that is used at only one place. |
||
|
||
def __init__( | ||
self, host, port, no_ssl, skip_ssl_validation, api_key, scrubber, timeout=10 | ||
): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rephrase with something like
True by default. Enables S3 tag enrichment at intake time for logs coming from S3 buckets. Equivalent to
DD_FETCH_S3_TAG` once the logs are ingested in Datadog. This parameter requires Resource Collection to be enabled.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"at intake time" is a bit ambiguous, before or after intake? because it impacts billing.
"S3 tag" is also ambiguous, "S3 Bucket tag" is precise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I feel strongly about having a link to our documentation for resource collection.
For the other parts I don't mind keeping them as is, the key part that we want the reader to understand is that the tags will appear in the logs after they're ingested by Datadog, meaning they don't pay for the volume of the log the tag contribute to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revamped it with Claude