Skip to content

Commit

Permalink
update: allow default uri as openobserve ingestion endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
taimingl authored and prabhatsharma committed Oct 21, 2024
1 parent 378e0db commit 9308824
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/sinks/openobserve.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use http::Uri;
use vector_lib::codecs::encoding::{FramingConfig, JsonSerializerConfig, SerializerConfig};
use vector_lib::configurable::configurable_component;

Expand All @@ -21,6 +22,7 @@ use crate::{
#[derive(Clone, Debug)]
pub struct OpenObserveConfig {
/// The OpenObserve endpoint to send data to.
#[serde(default = "default_endpoint")]
#[configurable(metadata(docs::examples = "http://localhost:5080/api/default/default/_json"))]
uri: UriSerde,

Expand Down Expand Up @@ -65,7 +67,7 @@ impl GenerateConfig for OpenObserveConfig {
fn generate_config() -> toml::Value {
toml::from_str(
r#"
endpoint = "http://localhost:5080/api/default/default/_json"
uri = "http://localhost:5080/api/default/default/_json"
Auth = "user: [email protected], password: your_ingestion_password"
encoding.codec = "json"
"#,
Expand All @@ -74,14 +76,21 @@ impl GenerateConfig for OpenObserveConfig {
}
}

fn default_endpoint() -> UriSerde {
UriSerde {
uri: Uri::from_static("http://localhost:5080/api/default/default/_json"),
auth: None,
}
}

#[async_trait::async_trait]
#[typetag::serde(name = "openobserve")]
impl SinkConfig for OpenObserveConfig {
async fn build(&self, cx: SinkContext) -> crate::Result<(VectorSink, Healthcheck)> {
let request = self.request.clone();

// OpenObserve supports native HTTP ingest endpoint. This configuration wraps
// the vector HTTP sink to provide official support for OpenObserve. This sink will
// the vector HTTP sink to provide official support for OpenObserve. This sink will
// allow maintaining the vector OpenObserve sink independent of the vector HTTP sink
// configuration and will allow to accomodate any future changes to the interface.
let http_sink_config = HttpSinkConfig {
Expand Down
9 changes: 6 additions & 3 deletions website/cue/reference/components/sinks/base/openobserve.cue
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,13 @@ base: components: sinks: openobserve: configuration: {
}
}
}
endpoint: {
uri: {
description: "The OpenObserve endpoint to send data to."
required: true
type: string: examples: ["http://localhost:5080/api/default/default/_json"]
required: false
type: string: {
default: "http://localhost:5080/api/default/default/_json"
examples: ["http://localhost:5080/api/default/default/_json"]
}
}
auth: {
description: "Authentication for OpenObserve."
Expand Down

0 comments on commit 9308824

Please sign in to comment.