Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36203,7 +36203,8 @@ components:
type: object
ObservabilityPipelineEnrichmentTableProcessor:
description: The `enrichment_table` processor enriches logs using a static CSV
file or GeoIP database.
file, GeoIP database, or reference table. Exactly one of `file`, `geoip`,
or `reference_table` must be configured.
properties:
display_name:
$ref: '#/components/schemas/ObservabilityPipelineComponentDisplayName'
Expand All @@ -36224,6 +36225,8 @@ components:
targets.
example: source:my-source
type: string
reference_table:
$ref: '#/components/schemas/ObservabilityPipelineEnrichmentTableReferenceTable'
target:
description: Path where enrichment results should be stored in the log.
example: enriched.geoip
Expand All @@ -36246,6 +36249,34 @@ components:
type: string
x-enum-varnames:
- ENRICHMENT_TABLE
ObservabilityPipelineEnrichmentTableReferenceTable:
description: Uses a Datadog reference table to enrich logs.
properties:
app_key_key:
default: PROCESSOR_ENRICHMENT_TABLES_APP_KEY
description: Environment variable name containing the application key used
for reference table authentication.
type: string
columns:
description: List of column names to include from the reference table. If
not provided, all columns are included.
items:
type: string
nullable: true
type: array
key_field:
description: Path to the field in the log event to match against the reference
table.
example: log.user.id
type: string
table_id:
description: The unique identifier of the reference table.
example: 550e8400-e29b-41d4-a716-446655440000
type: string
required:
- key_field
- table_id
type: object
ObservabilityPipelineFieldValue:
description: Represents a static key-value pair used in various processors.
properties:
Expand Down
2 changes: 2 additions & 0 deletions src/datadogV2/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5316,6 +5316,8 @@ pub mod model_observability_pipeline_enrichment_table_file_schema_items_type;
pub use self::model_observability_pipeline_enrichment_table_file_schema_items_type::ObservabilityPipelineEnrichmentTableFileSchemaItemsType;
pub mod model_observability_pipeline_enrichment_table_geo_ip;
pub use self::model_observability_pipeline_enrichment_table_geo_ip::ObservabilityPipelineEnrichmentTableGeoIp;
pub mod model_observability_pipeline_enrichment_table_reference_table;
pub use self::model_observability_pipeline_enrichment_table_reference_table::ObservabilityPipelineEnrichmentTableReferenceTable;
pub mod model_observability_pipeline_enrichment_table_processor_type;
pub use self::model_observability_pipeline_enrichment_table_processor_type::ObservabilityPipelineEnrichmentTableProcessorType;
pub mod model_observability_pipeline_reduce_processor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::{Deserialize, Deserializer, Serialize};
use serde_with::skip_serializing_none;
use std::fmt::{self, Formatter};

/// The `enrichment_table` processor enriches logs using a static CSV file or GeoIP database.
/// The `enrichment_table` processor enriches logs using a static CSV file, GeoIP database, or reference table. Exactly one of `file`, `geoip`, or `reference_table` must be configured.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
Expand All @@ -29,6 +29,10 @@ pub struct ObservabilityPipelineEnrichmentTableProcessor {
/// A Datadog search query used to determine which logs this processor targets.
#[serde(rename = "include")]
pub include: String,
/// Uses a Datadog reference table to enrich logs.
#[serde(rename = "reference_table")]
pub reference_table:
Option<crate::datadogV2::model::ObservabilityPipelineEnrichmentTableReferenceTable>,
/// Path where enrichment results should be stored in the log.
#[serde(rename = "target")]
pub target: String,
Expand Down Expand Up @@ -57,6 +61,7 @@ impl ObservabilityPipelineEnrichmentTableProcessor {
geoip: None,
id,
include,
reference_table: None,
target,
type_,
additional_properties: std::collections::BTreeMap::new(),
Expand Down Expand Up @@ -85,6 +90,14 @@ impl ObservabilityPipelineEnrichmentTableProcessor {
self
}

pub fn reference_table(
mut self,
value: crate::datadogV2::model::ObservabilityPipelineEnrichmentTableReferenceTable,
) -> Self {
self.reference_table = Some(value);
self
}

pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
Expand Down Expand Up @@ -121,6 +134,9 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineEnrichmentTableProcessor {
> = None;
let mut id: Option<String> = None;
let mut include: Option<String> = None;
let mut reference_table: Option<
crate::datadogV2::model::ObservabilityPipelineEnrichmentTableReferenceTable,
> = None;
let mut target: Option<String> = None;
let mut type_: Option<
crate::datadogV2::model::ObservabilityPipelineEnrichmentTableProcessorType,
Expand Down Expand Up @@ -161,6 +177,13 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineEnrichmentTableProcessor {
"include" => {
include = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"reference_table" => {
if v.is_null() {
continue;
}
reference_table =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"target" => {
target = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
Expand Down Expand Up @@ -195,6 +218,7 @@ impl<'de> Deserialize<'de> for ObservabilityPipelineEnrichmentTableProcessor {
geoip,
id,
include,
reference_table,
target,
type_,
additional_properties,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.
use serde::de::{Error, MapAccess, Visitor};
use serde::{Deserialize, Deserializer, Serialize};
use serde_with::skip_serializing_none;
use std::fmt::{self, Formatter};

/// Uses a Datadog reference table to enrich logs.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct ObservabilityPipelineEnrichmentTableReferenceTable {
/// Environment variable name containing the application key used for reference table authentication.
#[serde(rename = "app_key_key")]
pub app_key_key: Option<String>,
/// List of column names to include from the reference table. If not provided, all columns are included.
#[serde(
rename = "columns",
default,
with = "::serde_with::rust::double_option"
)]
pub columns: Option<Option<Vec<String>>>,
/// Path to the field in the log event to match against the reference table.
#[serde(rename = "key_field")]
pub key_field: String,
/// The unique identifier of the reference table.
#[serde(rename = "table_id")]
pub table_id: String,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}

impl ObservabilityPipelineEnrichmentTableReferenceTable {
pub fn new(
key_field: String,
table_id: String,
) -> ObservabilityPipelineEnrichmentTableReferenceTable {
ObservabilityPipelineEnrichmentTableReferenceTable {
app_key_key: None,
columns: None,
key_field,
table_id,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}

pub fn app_key_key(mut self, value: String) -> Self {
self.app_key_key = Some(value);
self
}

pub fn columns(mut self, value: Option<Vec<String>>) -> Self {
self.columns = Some(value);
self
}

pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
) -> Self {
self.additional_properties = value;
self
}
}

impl<'de> Deserialize<'de> for ObservabilityPipelineEnrichmentTableReferenceTable {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct ObservabilityPipelineEnrichmentTableReferenceTableVisitor;
impl<'a> Visitor<'a> for ObservabilityPipelineEnrichmentTableReferenceTableVisitor {
type Value = ObservabilityPipelineEnrichmentTableReferenceTable;

fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("a mapping")
}

fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'a>,
{
let mut app_key_key: Option<String> = None;
let mut columns: Option<Option<Vec<String>>> = None;
let mut key_field: Option<String> = None;
let mut table_id: Option<String> = None;
let mut additional_properties: std::collections::BTreeMap<
String,
serde_json::Value,
> = std::collections::BTreeMap::new();
let mut _unparsed = false;

while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"app_key_key" => {
if v.is_null() {
continue;
}
app_key_key =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"columns" => {
columns = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"key_field" => {
key_field = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"table_id" => {
table_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
}
}
}
}
let key_field = key_field.ok_or_else(|| M::Error::missing_field("key_field"))?;
let table_id = table_id.ok_or_else(|| M::Error::missing_field("table_id"))?;

let content = ObservabilityPipelineEnrichmentTableReferenceTable {
app_key_key,
columns,
key_field,
table_id,
additional_properties,
_unparsed,
};

Ok(content)
}
}

deserializer.deserialize_any(ObservabilityPipelineEnrichmentTableReferenceTableVisitor)
}
}
Loading