Skip to content

Instantly share code, notes, and snippets.

@tobz
Created April 13, 2022 13:04
Show Gist options
  • Save tobz/74de9bf2d3334c20a85347b61f31fe0c to your computer and use it in GitHub Desktop.
Save tobz/74de9bf2d3334c20a85347b61f31fe0c to your computer and use it in GitHub Desktop.
/// A period of time.
#[derive(Clone, Serialize, Deserialize)]
pub struct SpecialDuration(u64);
/// Controls the batching behavior of events.
#[derive(Clone)]
#[configurable_component]
pub struct BatchConfig {
/// The maximum number of events in a batch before it is flushed.
max_events: Option<u64>,
/// The maximum number of bytes in a batch before it is flushed.
max_bytes: Option<u64>,
/// The maximum amount of time a batch can exist before it is flushed.
timeout: Option<SpecialDuration>,
}
/// A sink for sending events to the `simple` service.
#[derive(Clone)]
#[configurable_component]
pub struct SimpleSinkConfig {
/// The endpoint to send events to.
endpoint: String,
batch: BatchConfig,
/// The tags to apply to each event.
tags: HashMap<String, String>,
}
/// Collection of various sinks available in Vector.
#[derive(Clone)]
#[configurable_component]
pub enum SinkConfig {
/// Simple sink.
Simple(SimpleSinkConfig),
}
/// Global options for configuring Vector.
#[derive(Clone)]
#[configurable_component]
pub struct GlobalOptions {
/// The data directory where Vector will store state.
data_dir: Option<String>,
}
/// The overall configuration for Vector.
#[derive(Clone)]
#[configurable_component]
pub struct VectorConfig {
global: GlobalOptions,
/// Any configured sinks.
sinks: Vec<SinkConfig>,
}
{
"$ref": "#/definitions/VectorConfig",
"definitions": {
"GlobalOptions": {
"description": "Global options for configuring Vector.",
"type": "object",
"properties": {
"data_dir": {
"description": "The data directory where Vector will store state.",
"type": [
"string",
"null"
]
}
}
},
"BatchConfig": {
"description": "Controls the batching behavior of events.",
"type": "object",
"properties": {
"max_events": {
"description": "The maximum number of events in a batch before it is flushed.",
"type": [
"number",
"null"
],
"maximum": 9007199254740992.0,
"minimum": 0.0
},
"max_bytes": {
"description": "The maximum number of bytes in a batch before it is flushed.",
"type": [
"number",
"null"
],
"maximum": 9007199254740992.0,
"minimum": 0.0
},
"timeout": {
"description": "The maximum amount of time a batch can exist before it is flushed.",
"type": [
"number",
"null"
],
"maximum": 9007199254740992.0,
"minimum": 0.0
}
}
},
"SimpleSinkConfig": {
"description": "A sink for sending events to the `simple` service.",
"type": "object",
"required": [
"batch",
"endpoint",
"tags"
],
"properties": {
"endpoint": {
"description": "The endpoint to send events to.",
"type": "string"
},
"batch": {
"$ref": "#/definitions/BatchConfig"
},
"tags": {
"description": "The tags to apply to each event.",
"type": "object",
"additionalProperties": {
"description": "The tags to apply to each event.",
"type": "string"
}
}
}
},
"SinkConfig": {
"description": "Any configured sinks.",
"oneOf": [
{
"$ref": "#/definitions/SimpleSinkConfig"
}
]
},
"VectorConfig": {
"description": "The overall configuration for Vector.",
"type": "object",
"required": [
"global",
"sinks"
],
"properties": {
"global": {
"$ref": "#/definitions/GlobalOptions"
},
"sinks": {
"description": "Any configured sinks.",
"type": "array",
"items": {
"$ref": "#/definitions/SinkConfig"
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment