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 = iter_all_without_vrl_stdlib().chain(vrl::stdlib::all());
42    functions.collect()
43}
44
45/// Returns all VRL functions available only in Vector.
46pub fn all_without_vrl_stdlib() -> Vec<Box<dyn Function>> {
47    let functions = iter_all_without_vrl_stdlib();
48    functions.collect()
49}
50
51fn iter_all_without_vrl_stdlib() -> impl Iterator<Item = Box<dyn Function>> {
52    let functions = secret_functions()
53        .into_iter()
54        .chain(enrichment::vrl_functions());
55
56    #[cfg(feature = "dnstap")]
57    let functions = functions.chain(dnstap_parser::vrl_functions());
58
59    #[cfg(feature = "vrl-metrics")]
60    let functions = functions.chain(vector_vrl_metrics::all());
61
62    functions
63}