Skip to content

Commit 652d261

Browse files
add log source to the correlated and tagged dataset apis
1 parent 1e16987 commit 652d261

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

src/handlers/http/datasets.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use actix_web::http::StatusCode;
2222
use actix_web::{HttpRequest, HttpResponse, web};
2323
use serde::{Deserialize, Serialize};
2424

25+
use crate::event::format::LogSource;
2526
use crate::rbac::{self, Users, role::Action};
2627
use crate::utils::actix::extract_session_key_from_req;
2728
use crate::utils::get_tenant_id_from_request;
@@ -44,6 +45,7 @@ fn can_access_stream(req: &HttpRequest, stream_name: &str) -> bool {
4445
#[serde(rename_all = "camelCase")]
4546
struct CorrelatedDataset {
4647
name: String,
48+
log_source: LogSource,
4749
shared_tags: Vec<DatasetTag>,
4850
shared_labels: Vec<String>,
4951
}
@@ -99,8 +101,14 @@ pub async fn get_correlated_datasets(
99101
target_labels.intersection(&s_labels).cloned().collect();
100102

101103
if !shared_tags.is_empty() || !shared_labels.is_empty() {
104+
let log_source = s
105+
.get_log_source()
106+
.first()
107+
.map(|entry| entry.log_source_format.clone())
108+
.unwrap_or_default();
102109
correlated.push(CorrelatedDataset {
103110
name,
111+
log_source,
104112
shared_tags,
105113
shared_labels,
106114
});
@@ -111,6 +119,13 @@ pub async fn get_correlated_datasets(
111119
Ok(HttpResponse::Ok().json(correlated))
112120
}
113121

122+
#[derive(Debug, Serialize)]
123+
#[serde(rename_all = "camelCase")]
124+
struct TaggedDataset {
125+
name: String,
126+
log_source: LogSource,
127+
}
128+
114129
/// GET /api/v1/datasets/tags/{tag}
115130
/// Returns all datasets that have the specified tag.
116131
/// Results are filtered to only include datasets the caller is authorized to read.
@@ -136,7 +151,12 @@ pub async fn get_datasets_by_tag(
136151
continue;
137152
}
138153
if s.get_dataset_tags().contains(&tag) {
139-
matching.push(name);
154+
let log_source = s
155+
.get_log_source()
156+
.first()
157+
.map(|entry| entry.log_source_format.clone())
158+
.unwrap_or_default();
159+
matching.push(TaggedDataset { name, log_source });
140160
}
141161
}
142162
}

0 commit comments

Comments
 (0)