vector icon indicating copy to clipboard operation
vector copied to clipboard

feat(new encoding): add pretty json encoding

Open lsampras opened this issue 1 year ago • 6 comments
trafficstars

Adds a use_pretty_json field to json encoding codec this relies on the serde_json::to_writer_pretty implementation while using the same deserialization as plain json

Fixes : #20380

example

sources:
  dummy_logs:
    type: "demo_logs"
    format: "syslog"
    interval: 1
# Parse Syslog logs
# See the Vector Remap Language reference for more info: https://vrl.dev
transforms:
  parse_logs:
    type: "remap"
    inputs: ["dummy_logs"]
    source: |
      . = parse_syslog!(string!(.message))
# Print parsed logs to stdout
sinks:
  print:
    type: "console"
    inputs: ["parse_logs"]
    encoding:
      codec: "json"
      json:
        use_pretty_json: true

lsampras avatar Apr 26 '24 19:04 lsampras

CLA assistant check
All committers have signed the CLA.

bits-bot avatar Apr 26 '24 19:04 bits-bot

Also, I'm curious if you considered making this an optional parameter to the existing json codec rather than a separate codec. I think I could go either way on it so just curious if you considered it and what your thoughts were if so.

Hadn't considered adding a parameter to existing json codec, tbh I wasn't aware about the possibilty of adding more fields inside a codec...

lsampras avatar Apr 30 '24 07:04 lsampras

@jszwedko Can you take a look at this again? Should I be adding a field in the json codec instead of a new codec?

lsampras avatar May 02 '24 14:05 lsampras

Also, I'm curious if you considered making this an optional parameter to the existing json codec rather than a separate codec. I think I could go either way on it so just curious if you considered it and what your thoughts were if so.

Hadn't considered adding a parameter to existing json codec, tbh I wasn't aware about the possibilty of adding more fields inside a codec...

You can see an example with the AVRO codec: https://vector.dev/docs/reference/configuration/sinks/amqp/#encoding.avro

@jszwedko Can you take a look at this again? Should I be adding a field in the json codec instead of a new codec?

I'm having trouble coming up with super strong arguments either way but I think I have a slight preference to have it just be an option on the existing json codec since it is really just controlling "formatting" of an existing encoding. I could see us adding other formatting options to the other existing codecs where having pretty_json be its own codec would become more of an outlier. Do you think you that's something you might be able to take on? Apologies for not suggesting it sooner in the issue you had opened.

jszwedko avatar May 03 '24 18:05 jszwedko

@jszwedko Can you take a look at this again? Should I be adding a field in the json codec instead of a new codec?

I'm having trouble coming up with super strong arguments either way but I think I have a slight preference to have it just be an option on the existing json codec since it is really just controlling "formatting" of an existing encoding. I could see us adding other formatting options to the other existing codecs where having pretty_json be its own codec would become more of an outlier. Do you think you that's something you might be able to take on? Apologies for not suggesting it sooner in the issue you had opened.

+1 on adding a new option (vs introducing a new encoder).

Happy to help with implementation details if you get stuck. As Jesse mentioned, this https://github.com/vectordotdev/vector/blob/v0.37.1/lib/codecs/src/encoding/format/avro.rs#L42-L52 is a very good example.

pront avatar May 03 '24 19:05 pront

Regression Detector Results

Run ID: 1c54ce85-a4c3-4ae1-819d-1a6978db68bc Baseline: e1d1e851e71bd8c20f9c53a8340f0cdc3d0e7c12 Comparison: f74d488996530a2d5101ebad9f86335ce63e2ec9 Total CPUs: 7

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

No significant changes in experiment optimization goals

Confidence level: 90.00% Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
socket_to_socket_blackhole ingress throughput +2.31 [+2.22, +2.41]
splunk_hec_route_s3 ingress throughput +2.09 [+1.63, +2.56]
otlp_http_to_blackhole ingress throughput +1.94 [+1.81, +2.06]
otlp_grpc_to_blackhole ingress throughput +1.06 [+0.97, +1.15]
http_elasticsearch ingress throughput +0.98 [+0.89, +1.08]
datadog_agent_remap_blackhole_acks ingress throughput +0.26 [+0.17, +0.36]
http_to_http_noack ingress throughput +0.18 [+0.09, +0.28]
syslog_regex_logs2metric_ddmetrics ingress throughput +0.12 [+0.01, +0.23]
datadog_agent_remap_datadog_logs_acks ingress throughput +0.11 [+0.02, +0.19]
datadog_agent_remap_datadog_logs ingress throughput +0.08 [-0.02, +0.19]
syslog_log2metric_humio_metrics ingress throughput +0.05 [-0.12, +0.22]
http_to_http_json ingress throughput +0.02 [-0.05, +0.10]
splunk_hec_indexer_ack_blackhole ingress throughput -0.00 [-0.15, +0.14]
splunk_hec_to_splunk_hec_logs_acks ingress throughput -0.00 [-0.14, +0.13]
syslog_splunk_hec_logs ingress throughput -0.01 [-0.10, +0.08]
splunk_hec_to_splunk_hec_logs_noack ingress throughput -0.02 [-0.13, +0.09]
enterprise_http_to_http ingress throughput -0.08 [-0.13, -0.02]
syslog_humio_logs ingress throughput -0.09 [-0.23, +0.04]
http_to_http_acks ingress throughput -0.21 [-1.57, +1.15]
datadog_agent_remap_blackhole ingress throughput -0.25 [-0.35, -0.16]
syslog_log2metric_splunk_hec_metrics ingress throughput -0.29 [-0.45, -0.14]
http_to_s3 ingress throughput -0.32 [-0.60, -0.04]
syslog_loki ingress throughput -0.34 [-0.42, -0.27]
fluent_elasticsearch ingress throughput -0.42 [-0.90, +0.07]
http_text_to_http_json ingress throughput -0.44 [-0.58, -0.30]
syslog_log2metric_tag_cardinality_limit_blackhole ingress throughput -0.60 [-0.70, -0.49]
file_to_blackhole egress throughput -1.16 [-3.76, +1.44]

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

github-actions[bot] avatar May 08 '24 20:05 github-actions[bot]

@jszwedko Can you help here? I'm unable to understand the failure found the following logs in the actions

The image for the service you're trying to recreate has been removed. If you continue, volume data could be lost. Consider backing up your data before continuing.

lsampras avatar May 14 '24 09:05 lsampras

@jszwedko Can you help here? I'm unable to understand the failure found the following logs in the actions

The image for the service you're trying to recreate has been removed. If you continue, volume data could be lost. Consider backing up your data before continuing.

Ah, apologies, this was an issue in CI that was caused due to the Zookeeper and Kafka images disappearing. We resolved that in https://github.com/vectordotdev/vector/commit/3a115c517fe91f4c70eb8211b6dfdd1899adf07c. I'll requeue this.

jszwedko avatar May 20 '24 17:05 jszwedko

Regression Detector Results

Run ID: 9067f149-5284-4958-b8da-158176d237e4 Baseline: 911e63d4ee35c1de5082b6c2df6bc4ac0678ff31 Comparison: 62ec89f2f93b54e8d9362c3f118a8e54b05fac7c Total CPUs: 7

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

Significant changes in experiment optimization goals

Confidence level: 90.00% Effect size tolerance: |Δ mean %| ≥ 5.00%

perf experiment goal Δ mean % Δ mean % CI
syslog_humio_logs ingress throughput +5.29 [+5.14, +5.45]

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
syslog_humio_logs ingress throughput +5.29 [+5.14, +5.45]
syslog_splunk_hec_logs ingress throughput +2.67 [+2.55, +2.78]
syslog_log2metric_tag_cardinality_limit_blackhole ingress throughput +2.48 [+2.35, +2.61]
syslog_loki ingress throughput +2.43 [+2.33, +2.53]
syslog_regex_logs2metric_ddmetrics ingress throughput +2.34 [+2.20, +2.48]
syslog_log2metric_splunk_hec_metrics ingress throughput +1.93 [+1.75, +2.10]
http_text_to_http_json ingress throughput +1.75 [+1.62, +1.87]
syslog_log2metric_humio_metrics ingress throughput +1.64 [+1.45, +1.84]
splunk_hec_route_s3 ingress throughput +1.51 [+1.02, +2.01]
otlp_grpc_to_blackhole ingress throughput +1.30 [+1.21, +1.40]
http_to_http_acks ingress throughput +0.40 [-0.95, +1.76]
otlp_http_to_blackhole ingress throughput +0.33 [+0.21, +0.46]
http_to_http_noack ingress throughput +0.22 [+0.13, +0.31]
http_elasticsearch ingress throughput +0.04 [-0.04, +0.13]
http_to_http_json ingress throughput +0.02 [-0.05, +0.09]
splunk_hec_indexer_ack_blackhole ingress throughput -0.00 [-0.15, +0.14]
splunk_hec_to_splunk_hec_logs_acks ingress throughput -0.00 [-0.14, +0.14]
splunk_hec_to_splunk_hec_logs_noack ingress throughput -0.02 [-0.13, +0.09]
enterprise_http_to_http ingress throughput -0.10 [-0.19, -0.01]
socket_to_socket_blackhole ingress throughput -0.24 [-0.33, -0.15]
datadog_agent_remap_datadog_logs_acks ingress throughput -0.29 [-0.39, -0.19]
datadog_agent_remap_datadog_logs ingress throughput -0.37 [-0.48, -0.25]
http_to_s3 ingress throughput -0.38 [-0.66, -0.10]
datadog_agent_remap_blackhole_acks ingress throughput -0.83 [-0.95, -0.71]
file_to_blackhole egress throughput -0.92 [-3.41, +1.57]
datadog_agent_remap_blackhole ingress throughput -1.18 [-1.27, -1.10]
fluent_elasticsearch ingress throughput -2.60 [-3.08, -2.12]

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

github-actions[bot] avatar May 20 '24 18:05 github-actions[bot]

Regression Detector Results

Run ID: 8422c6c0-6d0a-4d60-9f99-9b1aef05aacd Baseline: 911e63d4ee35c1de5082b6c2df6bc4ac0678ff31 Comparison: c0df6c5c18197c77047492ac6c11c1c0fd1f00ad Total CPUs: 7

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

No significant changes in experiment optimization goals

Confidence level: 90.00% Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
syslog_log2metric_tag_cardinality_limit_blackhole ingress throughput +3.50 [+3.38, +3.62]
datadog_agent_remap_blackhole ingress throughput +3.01 [+2.87, +3.15]
syslog_loki ingress throughput +2.68 [+2.59, +2.77]
syslog_humio_logs ingress throughput +2.51 [+2.35, +2.67]
syslog_log2metric_humio_metrics ingress throughput +2.18 [+2.07, +2.29]
otlp_http_to_blackhole ingress throughput +2.17 [+2.02, +2.32]
syslog_log2metric_splunk_hec_metrics ingress throughput +1.80 [+1.61, +1.99]
file_to_blackhole egress throughput +1.20 [-1.28, +3.69]
syslog_splunk_hec_logs ingress throughput +1.19 [+1.08, +1.30]
http_to_http_acks ingress throughput +1.05 [-0.32, +2.42]
otlp_grpc_to_blackhole ingress throughput +0.54 [+0.45, +0.63]
datadog_agent_remap_datadog_logs ingress throughput +0.39 [+0.26, +0.52]
datadog_agent_remap_datadog_logs_acks ingress throughput +0.16 [+0.06, +0.26]
http_to_http_noack ingress throughput +0.16 [+0.07, +0.24]
datadog_agent_remap_blackhole_acks ingress throughput +0.12 [-0.01, +0.25]
http_to_http_json ingress throughput +0.03 [-0.05, +0.10]
splunk_hec_to_splunk_hec_logs_acks ingress throughput -0.00 [-0.14, +0.13]
splunk_hec_indexer_ack_blackhole ingress throughput -0.01 [-0.15, +0.14]
splunk_hec_to_splunk_hec_logs_noack ingress throughput -0.04 [-0.15, +0.08]
enterprise_http_to_http ingress throughput -0.14 [-0.22, -0.07]
socket_to_socket_blackhole ingress throughput -0.25 [-0.29, -0.22]
http_to_s3 ingress throughput -0.58 [-0.87, -0.30]
http_elasticsearch ingress throughput -0.65 [-0.74, -0.56]
syslog_regex_logs2metric_ddmetrics ingress throughput -0.71 [-0.85, -0.58]
splunk_hec_route_s3 ingress throughput -0.81 [-1.27, -0.34]
fluent_elasticsearch ingress throughput -0.81 [-1.29, -0.33]
http_text_to_http_json ingress throughput -1.02 [-1.20, -0.84]

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

github-actions[bot] avatar May 20 '24 19:05 github-actions[bot]

@jszwedko can you re-queue this for merge?

lsampras avatar Jun 10 '24 05:06 lsampras

Thanks for the bump @lsampras . I merged in master to fix the CI failure and requeued this.

jszwedko avatar Jun 10 '24 14:06 jszwedko

Regression Detector Results

Run ID: a4faaa9d-975f-46b6-979f-fbaa95635f4c Baseline: 2451cc0eaa2e070426185553474ac670204f9187 Comparison: 86f0a8840458dade9676a7581ca60cc95c6dad7d Total CPUs: 7

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

No significant changes in experiment optimization goals

Confidence level: 90.00% Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI
http_elasticsearch ingress throughput +1.83 [+1.77, +1.90]
datadog_agent_remap_datadog_logs_acks ingress throughput +0.99 [+0.91, +1.07]
fluent_elasticsearch ingress throughput +0.39 [-0.09, +0.86]
syslog_log2metric_humio_metrics ingress throughput +0.32 [+0.21, +0.43]
http_to_s3 ingress throughput +0.30 [+0.03, +0.58]
datadog_agent_remap_blackhole_acks ingress throughput +0.27 [+0.19, +0.36]
syslog_regex_logs2metric_ddmetrics ingress throughput +0.25 [+0.16, +0.34]
http_to_http_acks ingress throughput +0.20 [-1.17, +1.56]
syslog_log2metric_splunk_hec_metrics ingress throughput +0.16 [-0.01, +0.33]
otlp_grpc_to_blackhole ingress throughput +0.11 [+0.02, +0.20]
syslog_log2metric_tag_cardinality_limit_blackhole ingress throughput +0.11 [-0.01, +0.23]
http_to_http_noack ingress throughput +0.09 [-0.01, +0.19]
http_to_http_json ingress throughput +0.01 [-0.06, +0.09]
splunk_hec_indexer_ack_blackhole ingress throughput +0.00 [-0.15, +0.15]
splunk_hec_to_splunk_hec_logs_acks ingress throughput -0.00 [-0.14, +0.14]
file_to_blackhole egress throughput -0.00 [-2.51, +2.51]
splunk_hec_to_splunk_hec_logs_noack ingress throughput -0.05 [-0.17, +0.06]
enterprise_http_to_http ingress throughput -0.06 [-0.13, +0.01]
socket_to_socket_blackhole ingress throughput -0.12 [-0.19, -0.06]
datadog_agent_remap_datadog_logs ingress throughput -0.27 [-0.38, -0.16]
syslog_loki ingress throughput -0.30 [-0.35, -0.26]
http_text_to_http_json ingress throughput -0.32 [-0.43, -0.21]
syslog_splunk_hec_logs ingress throughput -0.39 [-0.45, -0.33]
datadog_agent_remap_blackhole ingress throughput -0.51 [-0.60, -0.42]
otlp_http_to_blackhole ingress throughput -0.89 [-1.02, -0.76]
syslog_humio_logs ingress throughput -1.27 [-1.40, -1.15]
splunk_hec_route_s3 ingress throughput -1.37 [-1.83, -0.92]

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

github-actions[bot] avatar Jun 10 '24 16:06 github-actions[bot]