-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add support for dynamic index in OpenSearch exporter #40530
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Shenoy Pratik <[email protected]>
Signed-off-by: Shenoy Pratik <[email protected]>
Signed-off-by: Shenoy Pratik <[email protected]>
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.
Looks good, just minor non-blocking comments.
Signed-off-by: Paul Sebastian <[email protected]>
Signed-off-by: Shenoy Pratik <[email protected]>
Hi @andrzej-stencel, Thanks for review. We have made the abovementioned changes in this PR. Can you please take a look and help us merge this PR? Thanks again! |
|
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.
Thanks for providing this feature. I think the documentation can be improved as can be the performance impact in case the feature is not used.
errNamespaceNoValue = errors.New("namespace must be specified") | ||
errBulkActionInvalid = errors.New("bulk_action can either be `create` or `index`") | ||
errMappingModeInvalid = errors.New("mapping.mode is invalid") | ||
errLogsIndexInvalidPlaceholder = errors.New("logs_index cannot have two attribute or context key placeholders") |
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.
Can it be more than 2 attributes or placeholders for this message to be used?
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 see the message is not clear. Changed this to logs_index can only have one placeholder. 346f05a
startErr := indexer.start(l.client) | ||
if startErr != nil { | ||
return startErr | ||
} | ||
|
||
// Collect attributes from resource/log record | ||
attrs := collectAttributes(ld) |
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.
Can you not do that, if no LogsIndex
is set? You do not need the data structure in that case.
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.
Great catch. updated this line and moved it only if the logs_index config is set: 346f05a
Signed-off-by: Shenoy Pratik <[email protected]>
Signed-off-by: Shenoy Pratik <[email protected]>
Hi @andrzej-stencel @KarstenSchnitter, Please let me know if there are any other changes needed here. Thanks! |
Support for Dynamic Log Indexing in OpenSearch
This PR supports dynamic log index names using placeholders in the
logs_index
config. You can use any attribute or context key as a placeholder to construct index names dynamically per log record.logs_index
Placeholder:
%{key}
otel-logs-%{service.name}
orotel-logs-%{custom.label}
logs_index_fallback
is used (orunknown
if not set).If
logs_index
is not set, the exporter will use the default naming pattern:ss4o_{type}-{dataset}-{namespace}
(e.g.,ss4o_logs-default-namespace
). This ensures backward compatibility and a predictable index naming scheme.logs_index_time_format
You can append a time-formatted suffix to the index name using the
logs_index_time_format
option.logs_index_time_format
: If set, appends a time suffix to the resolved index name using the specified format (default is no suffix).yyyy
(4-digit year)yy
(2-digit year)MM
(2-digit month)dd
(2-digit day)HH
(2-digit hour, 24h)mm
(2-digit minute)ss
(2-digit second)-
,.
,_
,+
yyyy.MM.dd
→2024.06.07
yyyy-MM
→2024-06
yyMMdd
→240607
yyyy_MM_dd+HH
→2024_06_07+15
Link to tracking issue
#34746
#38595
Testing
Unit tests for parsing and rendering
logs_index
,logs_index_fallback
, andlogs_index_time_format
. Integration tests against a local OpenSearch instance to verify index names (including fallbacks and timestamp formatting).Documentation
Updated
exporter/opensearchexporter/README.md
Example Configuration