diff --git a/changelog.d/20384_pretty_json_config.enhancement.md b/changelog.d/20384_pretty_json_config.enhancement.md new file mode 100644 index 0000000000000..002d2ce7e00b5 --- /dev/null +++ b/changelog.d/20384_pretty_json_config.enhancement.md @@ -0,0 +1,3 @@ +Add `pretty` option to json coded to output a prettified json format. + +authors: lsampras diff --git a/config/vector.yaml b/config/vector.yaml index fbc56f9de47f8..590c2aa9ba152 100644 --- a/config/vector.yaml +++ b/config/vector.yaml @@ -38,6 +38,8 @@ sinks: inputs: ["parse_logs"] encoding: codec: "json" + json: + pretty: true # Vector's GraphQL API (disabled by default) # Uncomment to try it out with the `vector top` command or diff --git a/lib/codecs/src/encoding/format/json.rs b/lib/codecs/src/encoding/format/json.rs index 3ea242b7eda5a..89fee329ddb6b 100644 --- a/lib/codecs/src/encoding/format/json.rs +++ b/lib/codecs/src/encoding/format/json.rs @@ -14,17 +14,33 @@ pub struct JsonSerializerConfig { /// metric. When set to `full`, all metric tags are exposed as separate assignments. #[serde(default, skip_serializing_if = "vector_core::serde::is_default")] pub metric_tag_values: MetricTagValues, + + /// Options for the JsonSerializer. + #[serde(default, rename = "json")] + pub options: JsonSerializerOptions, +} + +/// Options for the JsonSerializer. +#[crate::configurable_component] +#[derive(Debug, Clone, Default)] +pub struct JsonSerializerOptions { + /// Whether to use pretty JSON formatting. + #[serde(default)] + pub pretty: bool, } impl JsonSerializerConfig { /// Creates a new `JsonSerializerConfig`. - pub const fn new(metric_tag_values: MetricTagValues) -> Self { - Self { metric_tag_values } + pub const fn new(metric_tag_values: MetricTagValues, options: JsonSerializerOptions) -> Self { + Self { + metric_tag_values, + options, + } } /// Build the `JsonSerializer` from this configuration. - pub const fn build(&self) -> JsonSerializer { - JsonSerializer::new(self.metric_tag_values) + pub fn build(&self) -> JsonSerializer { + JsonSerializer::new(self.metric_tag_values, self.options.clone()) } /// The data type of events that are accepted by `JsonSerializer`. @@ -44,12 +60,16 @@ impl JsonSerializerConfig { #[derive(Debug, Clone)] pub struct JsonSerializer { metric_tag_values: MetricTagValues, + options: JsonSerializerOptions, } impl JsonSerializer { /// Creates a new `JsonSerializer`. - pub const fn new(metric_tag_values: MetricTagValues) -> Self { - Self { metric_tag_values } + pub const fn new(metric_tag_values: MetricTagValues, options: JsonSerializerOptions) -> Self { + Self { + metric_tag_values, + options, + } } /// Encode event and represent it as JSON value. @@ -68,15 +88,28 @@ impl Encoder for JsonSerializer { fn encode(&mut self, event: Event, buffer: &mut BytesMut) -> Result<(), Self::Error> { let writer = buffer.writer(); - match event { - Event::Log(log) => serde_json::to_writer(writer, &log), - Event::Metric(mut metric) => { - if self.metric_tag_values == MetricTagValues::Single { - metric.reduce_tags_to_single(); + if self.options.pretty { + match event { + Event::Log(log) => serde_json::to_writer_pretty(writer, &log), + Event::Metric(mut metric) => { + if self.metric_tag_values == MetricTagValues::Single { + metric.reduce_tags_to_single(); + } + serde_json::to_writer_pretty(writer, &metric) } - serde_json::to_writer(writer, &metric) + Event::Trace(trace) => serde_json::to_writer_pretty(writer, &trace), + } + } else { + match event { + Event::Log(log) => serde_json::to_writer(writer, &log), + Event::Metric(mut metric) => { + if self.metric_tag_values == MetricTagValues::Single { + metric.reduce_tags_to_single(); + } + serde_json::to_writer(writer, &metric) + } + Event::Trace(trace) => serde_json::to_writer(writer, &trace), } - Event::Trace(trace) => serde_json::to_writer(writer, &trace), } .map_err(Into::into) } @@ -191,6 +224,7 @@ mod tests { let bytes = serialize( JsonSerializerConfig { metric_tag_values: MetricTagValues::Full, + options: JsonSerializerOptions::default(), }, metric2(), ); @@ -206,6 +240,7 @@ mod tests { let bytes = serialize( JsonSerializerConfig { metric_tag_values: MetricTagValues::Single, + options: JsonSerializerOptions::default(), }, metric2(), ); @@ -236,4 +271,202 @@ mod tests { config.build().encode(input, &mut buffer).unwrap(); buffer.freeze() } + + mod pretty_json { + + use super::*; + use bytes::{Bytes, BytesMut}; + use chrono::{TimeZone, Timelike, Utc}; + use vector_core::event::{LogEvent, Metric, MetricKind, MetricValue, StatisticKind, Value}; + use vector_core::metric_tags; + use vrl::btreemap; + + fn get_pretty_json_config() -> JsonSerializerConfig { + JsonSerializerConfig { + options: JsonSerializerOptions { pretty: true }, + ..Default::default() + } + } + + #[test] + fn serialize_json_log() { + let event = Event::Log(LogEvent::from( + btreemap! {"x" => Value::from("23"),"z" => Value::from(25),"a" => Value::from("0"),}, + )); + let bytes = serialize(get_pretty_json_config(), event); + assert_eq!( + bytes, + r#"{ + "a": "0", + "x": "23", + "z": 25 +}"# + ); + } + #[test] + fn serialize_json_metric_counter() { + let event = Event::Metric( + Metric::new( + "foos", + MetricKind::Incremental, + MetricValue::Counter { value: 100.0 }, + ) + .with_namespace(Some("vector")) + .with_tags(Some( + metric_tags!("key2" => "value2","key1" => "value1","Key3" => "Value3",), + )) + .with_timestamp(Some( + Utc.with_ymd_and_hms(2018, 11, 14, 8, 9, 10) + .single() + .and_then(|t| t.with_nanosecond(11)) + .expect("invalid timestamp"), + )), + ); + let bytes = serialize(get_pretty_json_config(), event); + assert_eq!( + bytes, + r#"{ + "name": "foos", + "namespace": "vector", + "tags": { + "Key3": "Value3", + "key1": "value1", + "key2": "value2" + }, + "timestamp": "2018-11-14T08:09:10.000000011Z", + "kind": "incremental", + "counter": { + "value": 100.0 + } +}"# + ); + } + #[test] + fn serialize_json_metric_set() { + let event = Event::Metric(Metric::new( + "users", + MetricKind::Incremental, + MetricValue::Set { + values: vec!["bob".into()].into_iter().collect(), + }, + )); + let bytes = serialize(get_pretty_json_config(), event); + assert_eq!( + bytes, + r#"{ + "name": "users", + "kind": "incremental", + "set": { + "values": [ + "bob" + ] + } +}"# + ); + } + #[test] + fn serialize_json_metric_histogram_without_timestamp() { + let event = Event::Metric(Metric::new( + "glork", + MetricKind::Incremental, + MetricValue::Distribution { + samples: vector_core::samples![10.0 => 1], + statistic: StatisticKind::Histogram, + }, + )); + let bytes = serialize(get_pretty_json_config(), event); + assert_eq!( + bytes, + r#"{ + "name": "glork", + "kind": "incremental", + "distribution": { + "samples": [ + { + "value": 10.0, + "rate": 1 + } + ], + "statistic": "histogram" + } +}"# + ); + } + #[test] + fn serialize_equals_to_json_value() { + let event = Event::Log(LogEvent::from(btreemap! {"foo" => Value::from("bar")})); + let mut serializer = get_pretty_json_config().build(); + let mut bytes = BytesMut::new(); + serializer.encode(event.clone(), &mut bytes).unwrap(); + let json = serializer.to_json_value(event).unwrap(); + assert_eq!(bytes.freeze(), serde_json::to_string_pretty(&json).unwrap()); + } + #[test] + fn serialize_metric_tags_full() { + let bytes = serialize( + JsonSerializerConfig { + metric_tag_values: MetricTagValues::Full, + options: JsonSerializerOptions { pretty: true }, + }, + metric2(), + ); + assert_eq!( + bytes, + r#"{ + "name": "counter", + "tags": { + "a": [ + "first", + null, + "second" + ] + }, + "kind": "incremental", + "counter": { + "value": 1.0 + } +}"# + ); + } + #[test] + fn serialize_metric_tags_single() { + let bytes = serialize( + JsonSerializerConfig { + metric_tag_values: MetricTagValues::Single, + options: JsonSerializerOptions { pretty: true }, + }, + metric2(), + ); + assert_eq!( + bytes, + r#"{ + "name": "counter", + "tags": { + "a": "second" + }, + "kind": "incremental", + "counter": { + "value": 1.0 + } +}"# + ); + } + fn metric2() -> Event { + Event::Metric( + Metric::new( + "counter", + MetricKind::Incremental, + MetricValue::Counter { value: 1.0 }, + ) + .with_tags(Some( + metric_tags! ("a" => "first","a" => None,"a" => "second",), + )), + ) + } + fn serialize(config: JsonSerializerConfig, input: Event) -> Bytes { + let mut buffer = BytesMut::new(); + config.build().encode(input, &mut buffer).unwrap(); + buffer.freeze() + } + } } diff --git a/lib/codecs/src/encoding/format/mod.rs b/lib/codecs/src/encoding/format/mod.rs index e61f7cae0bb96..01317e243cca6 100644 --- a/lib/codecs/src/encoding/format/mod.rs +++ b/lib/codecs/src/encoding/format/mod.rs @@ -21,7 +21,7 @@ pub use self::csv::{CsvSerializer, CsvSerializerConfig}; pub use avro::{AvroSerializer, AvroSerializerConfig, AvroSerializerOptions}; use dyn_clone::DynClone; pub use gelf::{GelfSerializer, GelfSerializerConfig}; -pub use json::{JsonSerializer, JsonSerializerConfig}; +pub use json::{JsonSerializer, JsonSerializerConfig, JsonSerializerOptions}; pub use logfmt::{LogfmtSerializer, LogfmtSerializerConfig}; pub use native::{NativeSerializer, NativeSerializerConfig}; pub use native_json::{NativeJsonSerializer, NativeJsonSerializerConfig}; diff --git a/lib/k8s-e2e-tests/tests/vector-agent.rs b/lib/k8s-e2e-tests/tests/vector-agent.rs index e15b690ed74e6..49bd9a2439d29 100644 --- a/lib/k8s-e2e-tests/tests/vector-agent.rs +++ b/lib/k8s-e2e-tests/tests/vector-agent.rs @@ -993,6 +993,8 @@ async fn custom_selectors() -> Result<(), Box> { inputs: [kubernetes_logs] encoding: codec: json + json: + pretty: false "#}; let vector = framework @@ -1395,6 +1397,8 @@ async fn glob_pattern_filtering() -> Result<(), Box> { inputs: [kubernetes_logs] encoding: codec: json + json: + pretty: false "#}; let vector = framework diff --git a/src/components/validation/resources/event.rs b/src/components/validation/resources/event.rs index fa4564a6076c0..a0ec8d594bae4 100644 --- a/src/components/validation/resources/event.rs +++ b/src/components/validation/resources/event.rs @@ -5,6 +5,7 @@ use serde::Deserialize; use serde_json::Value; use snafu::Snafu; use tokio_util::codec::Encoder as _; +use vector_lib::codecs::encoding::format::JsonSerializerOptions; use crate::codecs::Encoder; use vector_lib::codecs::{ @@ -179,7 +180,11 @@ pub fn encode_test_event( } else { Encoder::::new( NewlineDelimitedEncoder::new().into(), - JsonSerializer::new(MetricTagValues::default()).into(), + JsonSerializer::new( + MetricTagValues::default(), + JsonSerializerOptions::default(), + ) + .into(), ) }; diff --git a/src/generate.rs b/src/generate.rs index 7445f90137410..c4032f0fde148 100644 --- a/src/generate.rs +++ b/src/generate.rs @@ -483,6 +483,9 @@ mod tests { [sinks.sink0.encoding] codec = "json" + [sinks.sink0.encoding.json] + pretty = false + [sinks.sink0.healthcheck] enabled = true @@ -520,6 +523,9 @@ mod tests { [sinks.sink0.encoding] codec = "json" + [sinks.sink0.encoding.json] + pretty = false + [sinks.sink0.healthcheck] enabled = true @@ -551,6 +557,9 @@ mod tests { [sinks.sink0.encoding] codec = "json" + [sinks.sink0.encoding.json] + pretty = false + [sinks.sink0.healthcheck] enabled = true @@ -575,6 +584,9 @@ mod tests { [sinks.sink0.encoding] codec = "json" + [sinks.sink0.encoding.json] + pretty = false + [sinks.sink0.healthcheck] enabled = true @@ -685,6 +697,8 @@ mod tests { type: console encoding: codec: json + json: + pretty: false healthcheck: enabled: true uri: null @@ -750,7 +764,10 @@ mod tests { "target": "stdout", "type": "console", "encoding": { - "codec": "json" + "codec": "json", + "json": { + "pretty": false + } }, "healthcheck": { "enabled": true, diff --git a/src/sinks/datadog/logs/config.rs b/src/sinks/datadog/logs/config.rs index f4a362c34f2f9..5a9f4431eb232 100644 --- a/src/sinks/datadog/logs/config.rs +++ b/src/sinks/datadog/logs/config.rs @@ -186,7 +186,7 @@ mod test { use crate::codecs::EncodingConfigWithFraming; use crate::components::validation::prelude::*; use vector_lib::{ - codecs::{JsonSerializerConfig, MetricTagValues}, + codecs::{encoding::format::JsonSerializerOptions, JsonSerializerConfig, MetricTagValues}, config::LogNamespace, }; @@ -209,7 +209,8 @@ mod test { let encoding = EncodingConfigWithFraming::new( None, - JsonSerializerConfig::new(MetricTagValues::Full).into(), + JsonSerializerConfig::new(MetricTagValues::Full, JsonSerializerOptions::default()) + .into(), config.encoding.clone(), ); diff --git a/src/sinks/http/config.rs b/src/sinks/http/config.rs index e025ab81b5a84..ccc9ace780046 100644 --- a/src/sinks/http/config.rs +++ b/src/sinks/http/config.rs @@ -308,6 +308,8 @@ impl SinkConfig for HttpSinkConfig { #[cfg(test)] mod tests { + use vector_lib::codecs::encoding::format::JsonSerializerOptions; + use super::*; use crate::components::validation::prelude::*; @@ -323,7 +325,11 @@ mod tests { method: HttpMethod::Post, encoding: EncodingConfigWithFraming::new( None, - JsonSerializerConfig::new(MetricTagValues::Full).into(), + JsonSerializerConfig::new( + MetricTagValues::Full, + JsonSerializerOptions::default(), + ) + .into(), Transformer::default(), ), auth: None, diff --git a/src/sinks/splunk_hec/logs/config.rs b/src/sinks/splunk_hec/logs/config.rs index 844d073245bad..d229e45691106 100644 --- a/src/sinks/splunk_hec/logs/config.rs +++ b/src/sinks/splunk_hec/logs/config.rs @@ -291,7 +291,7 @@ mod tests { use super::*; use crate::components::validation::prelude::*; use vector_lib::{ - codecs::{JsonSerializerConfig, MetricTagValues}, + codecs::{encoding::format::JsonSerializerOptions, JsonSerializerConfig, MetricTagValues}, config::LogNamespace, }; @@ -316,7 +316,11 @@ mod tests { sourcetype: None, source: None, encoding: EncodingConfig::new( - JsonSerializerConfig::new(MetricTagValues::Full).into(), + JsonSerializerConfig::new( + MetricTagValues::Full, + JsonSerializerOptions::default(), + ) + .into(), Transformer::default(), ), compression: Compression::default(), diff --git a/website/cue/reference/components/sinks/base/amqp.cue b/website/cue/reference/components/sinks/base/amqp.cue index 4e8756abec522..f6636096e5875 100644 --- a/website/cue/reference/components/sinks/base/amqp.cue +++ b/website/cue/reference/components/sinks/base/amqp.cue @@ -228,6 +228,16 @@ base: components: sinks: amqp: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/aws_cloudwatch_logs.cue b/website/cue/reference/components/sinks/base/aws_cloudwatch_logs.cue index 089e8b08cdbc8..214248b03ba3b 100644 --- a/website/cue/reference/components/sinks/base/aws_cloudwatch_logs.cue +++ b/website/cue/reference/components/sinks/base/aws_cloudwatch_logs.cue @@ -404,6 +404,16 @@ base: components: sinks: aws_cloudwatch_logs: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/aws_kinesis_firehose.cue b/website/cue/reference/components/sinks/base/aws_kinesis_firehose.cue index 10fbde2a50fba..d752b12153a25 100644 --- a/website/cue/reference/components/sinks/base/aws_kinesis_firehose.cue +++ b/website/cue/reference/components/sinks/base/aws_kinesis_firehose.cue @@ -383,6 +383,16 @@ base: components: sinks: aws_kinesis_firehose: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/aws_kinesis_streams.cue b/website/cue/reference/components/sinks/base/aws_kinesis_streams.cue index b725956698c9d..a683d120eb3be 100644 --- a/website/cue/reference/components/sinks/base/aws_kinesis_streams.cue +++ b/website/cue/reference/components/sinks/base/aws_kinesis_streams.cue @@ -383,6 +383,16 @@ base: components: sinks: aws_kinesis_streams: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/aws_s3.cue b/website/cue/reference/components/sinks/base/aws_s3.cue index 22cd5fe05c844..e04ba5e1c0451 100644 --- a/website/cue/reference/components/sinks/base/aws_s3.cue +++ b/website/cue/reference/components/sinks/base/aws_s3.cue @@ -492,6 +492,16 @@ base: components: sinks: aws_s3: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/aws_sns.cue b/website/cue/reference/components/sinks/base/aws_sns.cue index 80fdfd174727d..c4798bbe1e2cb 100644 --- a/website/cue/reference/components/sinks/base/aws_sns.cue +++ b/website/cue/reference/components/sinks/base/aws_sns.cue @@ -314,6 +314,16 @@ base: components: sinks: aws_sns: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/aws_sqs.cue b/website/cue/reference/components/sinks/base/aws_sqs.cue index aa19d564cfc27..88440bd495915 100644 --- a/website/cue/reference/components/sinks/base/aws_sqs.cue +++ b/website/cue/reference/components/sinks/base/aws_sqs.cue @@ -314,6 +314,16 @@ base: components: sinks: aws_sqs: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/azure_blob.cue b/website/cue/reference/components/sinks/base/azure_blob.cue index 6500fd4fe7a04..bc0afd1f92535 100644 --- a/website/cue/reference/components/sinks/base/azure_blob.cue +++ b/website/cue/reference/components/sinks/base/azure_blob.cue @@ -346,6 +346,16 @@ base: components: sinks: azure_blob: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/console.cue b/website/cue/reference/components/sinks/base/console.cue index 465669604aa88..1082c6a2a85eb 100644 --- a/website/cue/reference/components/sinks/base/console.cue +++ b/website/cue/reference/components/sinks/base/console.cue @@ -212,6 +212,16 @@ base: components: sinks: console: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/databend.cue b/website/cue/reference/components/sinks/base/databend.cue index 3b9b9ffe1a8b6..97611c0f75915 100644 --- a/website/cue/reference/components/sinks/base/databend.cue +++ b/website/cue/reference/components/sinks/base/databend.cue @@ -231,6 +231,16 @@ base: components: sinks: databend: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/file.cue b/website/cue/reference/components/sinks/base/file.cue index a84ac357af819..eb83f9673e973 100644 --- a/website/cue/reference/components/sinks/base/file.cue +++ b/website/cue/reference/components/sinks/base/file.cue @@ -232,6 +232,16 @@ base: components: sinks: file: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/gcp_chronicle_unstructured.cue b/website/cue/reference/components/sinks/base/gcp_chronicle_unstructured.cue index 99004dee9ac24..0354448a8ed81 100644 --- a/website/cue/reference/components/sinks/base/gcp_chronicle_unstructured.cue +++ b/website/cue/reference/components/sinks/base/gcp_chronicle_unstructured.cue @@ -281,6 +281,16 @@ base: components: sinks: gcp_chronicle_unstructured: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/gcp_cloud_storage.cue b/website/cue/reference/components/sinks/base/gcp_cloud_storage.cue index 7a8ff63ec1b6f..22b86cfe60cae 100644 --- a/website/cue/reference/components/sinks/base/gcp_cloud_storage.cue +++ b/website/cue/reference/components/sinks/base/gcp_cloud_storage.cue @@ -370,6 +370,16 @@ base: components: sinks: gcp_cloud_storage: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/gcp_pubsub.cue b/website/cue/reference/components/sinks/base/gcp_pubsub.cue index 1361b65080694..f132ee545598b 100644 --- a/website/cue/reference/components/sinks/base/gcp_pubsub.cue +++ b/website/cue/reference/components/sinks/base/gcp_pubsub.cue @@ -279,6 +279,16 @@ base: components: sinks: gcp_pubsub: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/http.cue b/website/cue/reference/components/sinks/base/http.cue index bc886fd29ec61..c28aa0a594e43 100644 --- a/website/cue/reference/components/sinks/base/http.cue +++ b/website/cue/reference/components/sinks/base/http.cue @@ -325,6 +325,16 @@ base: components: sinks: http: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/humio_logs.cue b/website/cue/reference/components/sinks/base/humio_logs.cue index 6c2658f532e23..5eb9352aa509e 100644 --- a/website/cue/reference/components/sinks/base/humio_logs.cue +++ b/website/cue/reference/components/sinks/base/humio_logs.cue @@ -278,6 +278,16 @@ base: components: sinks: humio_logs: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/kafka.cue b/website/cue/reference/components/sinks/base/kafka.cue index e6870a8515562..54cac4cdc33fb 100644 --- a/website/cue/reference/components/sinks/base/kafka.cue +++ b/website/cue/reference/components/sinks/base/kafka.cue @@ -267,6 +267,16 @@ base: components: sinks: kafka: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/loki.cue b/website/cue/reference/components/sinks/base/loki.cue index f935acc5bb8e4..6e406f81da836 100644 --- a/website/cue/reference/components/sinks/base/loki.cue +++ b/website/cue/reference/components/sinks/base/loki.cue @@ -327,6 +327,16 @@ base: components: sinks: loki: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/mqtt.cue b/website/cue/reference/components/sinks/base/mqtt.cue index a93de9aa10452..74c7cebc160c2 100644 --- a/website/cue/reference/components/sinks/base/mqtt.cue +++ b/website/cue/reference/components/sinks/base/mqtt.cue @@ -222,6 +222,16 @@ base: components: sinks: mqtt: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/nats.cue b/website/cue/reference/components/sinks/base/nats.cue index afd87e7d0f247..175089fdf9324 100644 --- a/website/cue/reference/components/sinks/base/nats.cue +++ b/website/cue/reference/components/sinks/base/nats.cue @@ -312,6 +312,16 @@ base: components: sinks: nats: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/papertrail.cue b/website/cue/reference/components/sinks/base/papertrail.cue index bff6fef8a2516..b3131ca8f635d 100644 --- a/website/cue/reference/components/sinks/base/papertrail.cue +++ b/website/cue/reference/components/sinks/base/papertrail.cue @@ -212,6 +212,16 @@ base: components: sinks: papertrail: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/pulsar.cue b/website/cue/reference/components/sinks/base/pulsar.cue index dd7e31eba9e28..9dc1adfe7e212 100644 --- a/website/cue/reference/components/sinks/base/pulsar.cue +++ b/website/cue/reference/components/sinks/base/pulsar.cue @@ -306,6 +306,16 @@ base: components: sinks: pulsar: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/redis.cue b/website/cue/reference/components/sinks/base/redis.cue index 27f2311522011..7b82723ab71c7 100644 --- a/website/cue/reference/components/sinks/base/redis.cue +++ b/website/cue/reference/components/sinks/base/redis.cue @@ -265,6 +265,16 @@ base: components: sinks: redis: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/socket.cue b/website/cue/reference/components/sinks/base/socket.cue index ed9622fa25366..0e0f0f604a293 100644 --- a/website/cue/reference/components/sinks/base/socket.cue +++ b/website/cue/reference/components/sinks/base/socket.cue @@ -224,6 +224,16 @@ base: components: sinks: socket: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/splunk_hec_logs.cue b/website/cue/reference/components/sinks/base/splunk_hec_logs.cue index 660fdd59b0029..c0f238141d084 100644 --- a/website/cue/reference/components/sinks/base/splunk_hec_logs.cue +++ b/website/cue/reference/components/sinks/base/splunk_hec_logs.cue @@ -328,6 +328,16 @@ base: components: sinks: splunk_hec_logs: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/webhdfs.cue b/website/cue/reference/components/sinks/base/webhdfs.cue index e570de139f4b4..75e2fcd19005f 100644 --- a/website/cue/reference/components/sinks/base/webhdfs.cue +++ b/website/cue/reference/components/sinks/base/webhdfs.cue @@ -278,6 +278,16 @@ base: components: sinks: webhdfs: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded. diff --git a/website/cue/reference/components/sinks/base/websocket.cue b/website/cue/reference/components/sinks/base/websocket.cue index aa4df23e6e8d3..13a9dd8eeadee 100644 --- a/website/cue/reference/components/sinks/base/websocket.cue +++ b/website/cue/reference/components/sinks/base/websocket.cue @@ -259,6 +259,16 @@ base: components: sinks: websocket: configuration: { required: false type: array: items: type: string: {} } + json: { + description: "Options for the JsonSerializer." + relevant_when: "codec = \"json\"" + required: false + type: object: options: pretty: { + description: "Whether to use pretty JSON formatting." + required: false + type: bool: default: false + } + } metric_tag_values: { description: """ Controls how metric tag values are encoded.