Skip to content

Commit b884ee7

Browse files
taisho6339pront
andauthored
chore(elasticsearch sink): Add documentation and tests about OpenSearch (#23603)
* Mention OpenSearch compatibility in the doc * Add OpenSearch config unit tests * cargo vdev fmt * Remove trailing spaces --------- Co-authored-by: Pavlos Rontidis <[email protected]>
1 parent b3d2641 commit b884ee7

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

src/sinks/elasticsearch/config.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,4 +690,70 @@ mod tests {
690690
assert_eq!(config.mode, ElasticsearchMode::Bulk);
691691
assert_eq!(config.bulk, BulkConfig::default());
692692
}
693+
694+
#[test]
695+
fn parse_opensearch_service_type_managed() {
696+
let config = toml::from_str::<ElasticsearchConfig>(
697+
r#"
698+
endpoints = [""]
699+
opensearch_service_type = "managed"
700+
"#,
701+
)
702+
.unwrap();
703+
assert_eq!(
704+
config.opensearch_service_type,
705+
OpenSearchServiceType::Managed
706+
);
707+
}
708+
709+
#[test]
710+
fn parse_opensearch_service_type_serverless() {
711+
let config = toml::from_str::<ElasticsearchConfig>(
712+
r#"
713+
endpoints = [""]
714+
opensearch_service_type = "serverless"
715+
auth.strategy = "aws"
716+
api_version = "auto"
717+
"#,
718+
)
719+
.unwrap();
720+
assert_eq!(
721+
config.opensearch_service_type,
722+
OpenSearchServiceType::Serverless
723+
);
724+
}
725+
726+
#[test]
727+
fn parse_opensearch_service_type_default() {
728+
let config = toml::from_str::<ElasticsearchConfig>(
729+
r#"
730+
endpoints = [""]
731+
"#,
732+
)
733+
.unwrap();
734+
assert_eq!(
735+
config.opensearch_service_type,
736+
OpenSearchServiceType::Managed
737+
);
738+
}
739+
740+
#[cfg(feature = "aws-core")]
741+
#[test]
742+
fn parse_opensearch_serverless_with_aws_auth() {
743+
let config = toml::from_str::<ElasticsearchConfig>(
744+
r#"
745+
endpoints = [""]
746+
opensearch_service_type = "serverless"
747+
auth.strategy = "aws"
748+
api_version = "auto"
749+
"#,
750+
)
751+
.unwrap();
752+
assert_eq!(
753+
config.opensearch_service_type,
754+
OpenSearchServiceType::Serverless
755+
);
756+
assert!(matches!(config.auth, Some(ElasticsearchAuthConfig::Aws(_))));
757+
assert_eq!(config.api_version, ElasticsearchApiVersion::Auto);
758+
}
693759
}

website/cue/reference/components/sinks/elasticsearch.cue

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ components: sinks: elasticsearch: {
7171
"""#,
7272
]
7373
warnings: []
74-
notices: []
74+
notices: [
75+
#"""
76+
This sink is compatible with OpenSearch, including both self-managed OpenSearch instances
77+
and Amazon OpenSearch Service. For OpenSearch Serverless, set `opensearch_service_type = "serverless"`
78+
and use AWS authentication.
79+
"""#,
80+
]
7581
}
7682

7783
configuration: generated.components.sinks.elasticsearch.configuration
@@ -160,6 +166,34 @@ components: sinks: elasticsearch: {
160166
"""
161167
}
162168

169+
opensearch_compatibility: {
170+
title: "OpenSearch Compatibility"
171+
body: """
172+
This sink is fully compatible with OpenSearch, which is an open-source fork of Elasticsearch.
173+
Vector can connect to:
174+
175+
- **Self-managed OpenSearch**: Use the same configuration as Elasticsearch with `opensearch_service_type = "managed"` (default)
176+
- **Amazon OpenSearch Service**: Configure AWS authentication and set `opensearch_service_type = "managed"`
177+
- **Amazon OpenSearch Serverless**: Set `opensearch_service_type = "serverless"` and use AWS authentication
178+
179+
All Elasticsearch sink features are supported with OpenSearch, including:
180+
- Bulk indexing and data streams
181+
- Authentication (Basic, AWS)
182+
- TLS/SSL encryption
183+
- Automatic API version detection
184+
- Compression and custom headers
185+
186+
Example configuration for OpenSearch:
187+
```toml
188+
[sinks.opensearch]
189+
type = "elasticsearch"
190+
endpoints = ["https://opensearch.example.com:9200"]
191+
opensearch_service_type = "managed"
192+
# ... other configuration options
193+
```
194+
"""
195+
}
196+
163197
aws_authentication: components._aws.how_it_works.aws_authentication
164198
}
165199
}

0 commit comments

Comments
 (0)