Skip to content

Commit 1d1e9f7

Browse files
brucegneuronull
andauthored
fix(datadog search): remove Datadog logs intake event structure assumption (#1003)
* fix(datadog search): remove Datadog logs intake event structure assumption * Fix typo * Fix typo again --------- Co-authored-by: neuronull <[email protected]>
1 parent eb5cc08 commit 1d1e9f7

File tree

3 files changed

+91
-81
lines changed

3 files changed

+91
-81
lines changed

changelog.d/1003.fix.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The assumption of a Datadog Logs-based intake event structure has been removed
2+
from the `match_datadog_query` function.

src/datadog/search/field.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,16 @@ pub enum Field {
3232
/// Reserved field that receives special treatment in Datadog.
3333
Reserved(String),
3434

35-
/// A facet -- i.e. started with `@`, transformed to `custom.*`
36-
Facet(String),
35+
/// An Attribute-- i.e. started with `@`.
36+
// In Datadog Log Search the `@` prefix is used to define a Facet for
37+
// attribute searching, and the event structure is assumed to have a
38+
// root level field "custom". In VRL we do not guarantee this event
39+
// structure so we are diverging a little from the DD Log Search
40+
// definition and implementation a bit here, by calling this "Attribute".
41+
//
42+
// Internally when we handle this enum variant, we attempt to parse the
43+
// string as a log path to obtain the value.
44+
Attribute(String),
3745

3846
/// Tag type - i.e. search in the `tags` field.
3947
Tag(String),
@@ -44,14 +52,14 @@ impl Field {
4452
match self {
4553
Self::Default(ref s) => s,
4654
Self::Reserved(ref s) => s,
47-
Self::Facet(ref s) => s,
55+
Self::Attribute(ref s) => s,
4856
Self::Tag(ref s) => s,
4957
}
5058
}
5159
}
5260

5361
/// Converts a field/facet name to the VRL equivalent. Datadog payloads have a `message` field
54-
/// (which is used whenever the default field is encountered. Facets are hosted on .custom.*.
62+
/// (which is used whenever the default field is encountered.
5563
pub fn normalize_fields<T: AsRef<str>>(value: T) -> Vec<Field> {
5664
let value = value.as_ref();
5765
if value.eq(grammar::DEFAULT_FIELD) {
@@ -61,8 +69,8 @@ pub fn normalize_fields<T: AsRef<str>>(value: T) -> Vec<Field> {
6169
.collect();
6270
}
6371

64-
let field = match value.replace('@', "custom.") {
65-
v if value.starts_with('@') => Field::Facet(v),
72+
let field = match value.replace('@', ".") {
73+
v if value.starts_with('@') => Field::Attribute(v),
6674
v if DEFAULT_FIELDS.contains(&v.as_ref()) => Field::Default(v),
6775
v if RESERVED_ATTRIBUTES.contains(&v.as_ref()) => Field::Reserved(v),
6876
v => Field::Tag(v),

0 commit comments

Comments
 (0)