vector/config/
dot_graph.rs

1use std::collections::HashMap;
2
3use vector_lib::configurable::configurable_component;
4
5/// Extra graph configuration
6///
7/// Configure output for component when generated with graph command
8#[configurable_component]
9#[configurable(metadata(docs::advanced))]
10#[derive(Clone, Debug, Default, Eq, PartialEq)]
11#[serde(deny_unknown_fields)]
12pub struct GraphConfig {
13    /// Node attributes to add to this component's node in resulting graph
14    ///
15    /// They are added to the node as provided
16    #[configurable(metadata(
17        docs::additional_props_description = "A single graph node attribute in graphviz DOT language.",
18        docs::examples = "example_node_options()"
19    ))]
20    #[serde(default)]
21    pub node_attributes: HashMap<String, String>,
22
23    /// Edge attributes to add to the edges linked to this component's node in resulting graph
24    ///
25    /// They are added to the edge as provided
26    #[configurable(metadata(
27        docs::additional_props_description = "A collection of graph edge attributes in graphviz DOT language, related to a single input component.",
28        docs::examples = "example_edges_options()"
29    ))]
30    #[serde(default)]
31    pub edge_attributes: HashMap<String, EdgeAttributes>,
32}
33
34#[configurable_component]
35#[configurable(metadata(docs::advanced))]
36#[derive(Clone, Debug, Default, Eq, PartialEq)]
37#[serde(deny_unknown_fields)]
38/// A collection of graph edge attributes in graphviz DOT language, related to a single input
39/// component.
40pub struct EdgeAttributes(
41    #[configurable(metadata(
42        docs::additional_props_description = "A single graph edge attribute in graphviz DOT language.",
43        docs::examples = "example_edge_options()"
44    ))]
45    pub HashMap<String, String>,
46);
47
48fn example_node_options() -> HashMap<String, String> {
49    HashMap::<_, _>::from_iter([
50        ("name".to_string(), "Example Node".to_string()),
51        ("color".to_string(), "red".to_string()),
52        ("width".to_string(), "5.0".to_string()),
53    ])
54}
55
56fn example_edges_options() -> HashMap<String, HashMap<String, String>> {
57    HashMap::<_, _>::from_iter([("example_input".to_string(), example_edge_options())])
58}
59
60fn example_edge_options() -> HashMap<String, String> {
61    HashMap::<_, _>::from_iter([
62        ("label".to_string(), "Example Edge".to_string()),
63        ("color".to_string(), "red".to_string()),
64        ("width".to_string(), "5.0".to_string()),
65    ])
66}