vector_vrl_functions/
lib.rs

1//! Central location for all VRL functions used in Vector.
2//!
3//! This crate provides a single source of truth for the complete set of VRL functions
4//! available throughout Vector, combining:
5//! - Standard VRL library functions (`vrl::stdlib::all`)
6//! - Vector-specific functions (`vector_vrl::secret_functions`)
7//! - Enrichment table functions (`enrichment::vrl_functions`)
8//! - DNS tap parsing functions (optional, with `dnstap` feature)
9
10#![deny(warnings)]
11
12use vrl::{compiler::Function, path::OwnedTargetPath};
13
14pub mod get_secret;
15pub mod remove_secret;
16pub mod set_secret;
17pub mod set_semantic_meaning;
18
19#[allow(clippy::large_enum_variant)]
20#[derive(Clone, Debug)]
21pub enum MetadataKey {
22    Legacy(String),
23    Query(OwnedTargetPath),
24}
25
26pub const LEGACY_METADATA_KEYS: [&str; 2] = ["datadog_api_key", "splunk_hec_token"];
27
28/// Returns Vector-specific secret functions.
29pub fn secret_functions() -> Vec<Box<dyn Function>> {
30    vec![
31        Box::new(set_semantic_meaning::SetSemanticMeaning) as _,
32        Box::new(get_secret::GetSecret) as _,
33        Box::new(remove_secret::RemoveSecret) as _,
34        Box::new(set_secret::SetSecret) as _,
35    ]
36}
37
38/// Returns all VRL functions available in Vector.
39#[allow(clippy::disallowed_methods)]
40pub fn all() -> Vec<Box<dyn Function>> {
41    let functions = vrl::stdlib::all()
42        .into_iter()
43        .chain(secret_functions())
44        .chain(enrichment::vrl_functions());
45
46    #[cfg(feature = "dnstap")]
47    let functions = functions.chain(dnstap_parser::vrl_functions());
48
49    #[cfg(feature = "vrl-metrics")]
50    let functions = functions.chain(vector_vrl_metrics::all());
51
52    functions.collect()
53}