diff --git a/examples/condition/meta/config.jsonnet b/examples/condition/meta/config.jsonnet index 3401049a..19028494 100644 --- a/examples/condition/meta/config.jsonnet +++ b/examples/condition/meta/config.jsonnet @@ -8,12 +8,12 @@ local sub = import '../../../substation.libsonnet'; { name: 'meta', transforms: [ - sub.tf.test.message({ value: ["alice@brex.com","bob@brex.com"] }), + sub.tf.test.message({ value: ['alice@brex.com', 'bob@brex.com'] }), sub.tf.send.stdout(), ], // Asserts that the message is equal to 'true'. condition: sub.cnd.str.eq({ value: 'true' }), - } + }, ], transforms: [ // In real-world deployments, the match decision is typically used diff --git a/examples/condition/number/config.jsonnet b/examples/condition/number/config.jsonnet index 656276a4..cbbff57a 100644 --- a/examples/condition/number/config.jsonnet +++ b/examples/condition/number/config.jsonnet @@ -6,15 +6,15 @@ local sub = import '../../../substation.libsonnet'; { name: 'number', transforms: [ - sub.tf.test.message({ value: {"sourcePort":22,"bytes":20000} }), + sub.tf.test.message({ value: { sourcePort: 22, bytes: 20000 } }), sub.tf.send.stdout(), ], // Asserts that the conditional transforms were applied. condition: sub.cnd.all([ - sub.cnd.str.eq({ obj: {src: 'service'}, value: 'SSH' }), - sub.cnd.str.eq({ obj: {src: 'severity'}, value: 'high' }), - ]) - } + sub.cnd.str.eq({ obj: { src: 'service' }, value: 'SSH' }), + sub.cnd.str.eq({ obj: { src: 'severity' }, value: 'high' }), + ]), + }, ], transforms: [ sub.tf.meta.switch({ cases: [ diff --git a/examples/condition/string/config.jsonnet b/examples/condition/string/config.jsonnet index f8eefac1..6b7785da 100644 --- a/examples/condition/string/config.jsonnet +++ b/examples/condition/string/config.jsonnet @@ -6,15 +6,15 @@ local sub = import '../../../substation.libsonnet'; { name: 'string', transforms: [ - sub.tf.test.message({ value: {"action":"ACCEPT","vpcId":"vpc-2b3c4d5e"} }), + sub.tf.test.message({ value: { action: 'ACCEPT', vpcId: 'vpc-2b3c4d5e' } }), sub.tf.send.stdout(), ], // Asserts that the conditional transforms were applied. condition: sub.cnd.all([ - sub.cnd.str.eq({ obj: {src: 'outcome'}, value: 'Allow' }), - sub.cnd.str.eq({ obj: {src: 'priority'}, value: 'high' }), - ]) - } + sub.cnd.str.eq({ obj: { src: 'outcome' }, value: 'Allow' }), + sub.cnd.str.eq({ obj: { src: 'priority' }, value: 'high' }), + ]), + }, ], transforms: [ sub.tf.meta.switch({ cases: [ diff --git a/examples/transform/aggregate/sample/config.jsonnet b/examples/transform/aggregate/sample/config.jsonnet index a909965a..0904be2e 100644 --- a/examples/transform/aggregate/sample/config.jsonnet +++ b/examples/transform/aggregate/sample/config.jsonnet @@ -8,25 +8,25 @@ local sub = import '../../../../substation.libsonnet'; { name: 'sample', transforms: [ - sub.tf.test.message({ value: {"a":"b"}}), - sub.tf.test.message({ value: {"c":"d"}}), - sub.tf.test.message({ value: {"e":"f"}}), - sub.tf.test.message({ value: {"g":"h"}}), - sub.tf.test.message({ value: {"i":"j"}}), - sub.tf.test.message({ value: {"k":"l"}}), - sub.tf.test.message({ value: {"m":"n"}}), - sub.tf.test.message({ value: {"o":"p"}}), - sub.tf.test.message({ value: {"q":"r"}}), - sub.tf.test.message({ value: {"s":"t"}}), - sub.tf.test.message({ value: {"u":"v"}}), - sub.tf.test.message({ value: {"w":"x"}}), - sub.tf.test.message({ value: {"y":"z"}}), - sub.tf.test.message({ value: " "}), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { e: 'f' } }), + sub.tf.test.message({ value: { g: 'h' } }), + sub.tf.test.message({ value: { i: 'j' } }), + sub.tf.test.message({ value: { k: 'l' } }), + sub.tf.test.message({ value: { m: 'n' } }), + sub.tf.test.message({ value: { o: 'p' } }), + sub.tf.test.message({ value: { q: 'r' } }), + sub.tf.test.message({ value: { s: 't' } }), + sub.tf.test.message({ value: { u: 'v' } }), + sub.tf.test.message({ value: { w: 'x' } }), + sub.tf.test.message({ value: { y: 'z' } }), + sub.tf.test.message({ value: ' ' }), sub.tf.send.stdout(), ], // Asserts that the message is '{"c":"d"}'. condition: sub.cnd.num.len.greater_than({ value: 0 }), - } + }, ], transforms: [ // Events are aggregated into an array. This example has a sample diff --git a/examples/transform/aggregate/summarize/config.jsonnet b/examples/transform/aggregate/summarize/config.jsonnet index 762e2cf6..21c03040 100644 --- a/examples/transform/aggregate/summarize/config.jsonnet +++ b/examples/transform/aggregate/summarize/config.jsonnet @@ -8,33 +8,33 @@ local sub = import '../../../../substation.libsonnet'; { name: 'summarize', transforms: [ - sub.tf.test.message({ value: {"client":"10.1.1.2","server":"8.8.8.8","bytes":11,"timestamp":1674429049} }), - sub.tf.test.message({ value: {"client":"10.1.1.3","server":"8.8.4.4","bytes":20,"timestamp":1674429050} }), - sub.tf.test.message({ value: {"client":"10.1.1.2","server":"8.8.4.4","bytes":15,"timestamp":1674429051} }), - sub.tf.test.message({ value: {"client":"10.1.1.3","server":"8.8.8.8","bytes":8,"timestamp":1674429052} }), - sub.tf.test.message({ value: {"client":"10.1.1.2","server":"8.8.8.8","bytes":25,"timestamp":1674429053} }), - sub.tf.test.message({ value: {"client":"10.1.1.4","server":"1.2.3.4","bytes":2400,"timestamp":1674429054} }), - sub.tf.test.message({ value: {"client":"10.1.1.2","server":"8.8.4.4","bytes":23,"timestamp":1674429055} }), - sub.tf.test.message({ value: {"client":"10.1.1.3","server":"8.8.8.8","bytes":12,"timestamp":1674429056} }), - sub.tf.test.message({ value: {"client":"10.1.1.2","server":"8.8.4.4","bytes":18,"timestamp":1674429057} }), - sub.tf.test.message({ value: {"client":"10.1.1.3","server":"8.8.8.8","bytes":6,"timestamp":1674429058} }), - sub.tf.test.message({ value: {"client":"10.1.1.2","server":"8.8.4.4","bytes":23,"timestamp":1674429059} }), - sub.tf.test.message({ value: {"client":"10.1.1.3","server":"8.8.8.8","bytes":12,"timestamp":1674429060} }), - sub.tf.test.message({ value: {"client":"10.1.1.2","server":"8.8.4.4","bytes":18,"timestamp":1674429061} }), - sub.tf.test.message({ value: {"client":"10.1.1.3","server":"8.8.8.8","bytes":6,"timestamp":1674429062} }), - sub.tf.test.message({ value: {"client":"10.1.1.2","server":"8.8.8.8","bytes":11,"timestamp":1674429063} }), - sub.tf.test.message({ value: {"client":"10.1.1.3","server":"8.8.4.4","bytes":20,"timestamp":1674429064} }), - sub.tf.test.message({ value: {"client":"10.1.1.2","server":"8.8.4.4","bytes":15,"timestamp":1674429065} }), - sub.tf.test.message({ value: {"client":"10.1.1.3","server":"8.8.8.8","bytes":8,"timestamp":1674429066} }), - sub.tf.test.message({ value: {"client":"10.1.1.2","server":"8.8.8.8","bytes":25,"timestamp":1674429067} }), + sub.tf.test.message({ value: { client: '10.1.1.2', server: '8.8.8.8', bytes: 11, timestamp: 1674429049 } }), + sub.tf.test.message({ value: { client: '10.1.1.3', server: '8.8.4.4', bytes: 20, timestamp: 1674429050 } }), + sub.tf.test.message({ value: { client: '10.1.1.2', server: '8.8.4.4', bytes: 15, timestamp: 1674429051 } }), + sub.tf.test.message({ value: { client: '10.1.1.3', server: '8.8.8.8', bytes: 8, timestamp: 1674429052 } }), + sub.tf.test.message({ value: { client: '10.1.1.2', server: '8.8.8.8', bytes: 25, timestamp: 1674429053 } }), + sub.tf.test.message({ value: { client: '10.1.1.4', server: '1.2.3.4', bytes: 2400, timestamp: 1674429054 } }), + sub.tf.test.message({ value: { client: '10.1.1.2', server: '8.8.4.4', bytes: 23, timestamp: 1674429055 } }), + sub.tf.test.message({ value: { client: '10.1.1.3', server: '8.8.8.8', bytes: 12, timestamp: 1674429056 } }), + sub.tf.test.message({ value: { client: '10.1.1.2', server: '8.8.4.4', bytes: 18, timestamp: 1674429057 } }), + sub.tf.test.message({ value: { client: '10.1.1.3', server: '8.8.8.8', bytes: 6, timestamp: 1674429058 } }), + sub.tf.test.message({ value: { client: '10.1.1.2', server: '8.8.4.4', bytes: 23, timestamp: 1674429059 } }), + sub.tf.test.message({ value: { client: '10.1.1.3', server: '8.8.8.8', bytes: 12, timestamp: 1674429060 } }), + sub.tf.test.message({ value: { client: '10.1.1.2', server: '8.8.4.4', bytes: 18, timestamp: 1674429061 } }), + sub.tf.test.message({ value: { client: '10.1.1.3', server: '8.8.8.8', bytes: 6, timestamp: 1674429062 } }), + sub.tf.test.message({ value: { client: '10.1.1.2', server: '8.8.8.8', bytes: 11, timestamp: 1674429063 } }), + sub.tf.test.message({ value: { client: '10.1.1.3', server: '8.8.4.4', bytes: 20, timestamp: 1674429064 } }), + sub.tf.test.message({ value: { client: '10.1.1.2', server: '8.8.4.4', bytes: 15, timestamp: 1674429065 } }), + sub.tf.test.message({ value: { client: '10.1.1.3', server: '8.8.8.8', bytes: 8, timestamp: 1674429066 } }), + sub.tf.test.message({ value: { client: '10.1.1.2', server: '8.8.8.8', bytes: 25, timestamp: 1674429067 } }), sub.tf.send.stdout(), ], // Asserts that each message has the 'count' and 'bytes_total' fields. condition: sub.cnd.all([ - sub.cnd.num.len.greater_than({ obj: {src: 'count'}, value: 0 }), - sub.cnd.num.len.greater_than({ obj: {src: 'bytes_total'}, value: 0 }), - ]) - } + sub.cnd.num.len.greater_than({ obj: { src: 'count' }, value: 0 }), + sub.cnd.num.len.greater_than({ obj: { src: 'bytes_total' }, value: 0 }), + ]), + }, ], transforms: [ // Events are aggregated into arrays based on their client and server fields. diff --git a/examples/transform/array/extend/config.jsonnet b/examples/transform/array/extend/config.jsonnet index 1c3d8a53..22f65db4 100644 --- a/examples/transform/array/extend/config.jsonnet +++ b/examples/transform/array/extend/config.jsonnet @@ -6,12 +6,12 @@ local sub = import '../../../../substation.libsonnet'; { name: 'extend', transforms: [ - sub.tf.test.message({ value: {"a":[1,2],"z":[3,4]} }), + sub.tf.test.message({ value: { a: [1, 2], z: [3, 4] } }), sub.tf.send.stdout(), ], // Asserts that 'a' contains 4 elements. - condition: sub.cnd.num.len.eq({ obj: {src: 'a'}, value: 4 }), - } + condition: sub.cnd.num.len.eq({ obj: { src: 'a' }, value: 4 }), + }, ], transforms: [ // Append the value of `z` to `a` (using the `-1` array index). diff --git a/examples/transform/array/flatten/config.jsonnet b/examples/transform/array/flatten/config.jsonnet index b2d3a954..b7ffb6e6 100644 --- a/examples/transform/array/flatten/config.jsonnet +++ b/examples/transform/array/flatten/config.jsonnet @@ -6,12 +6,12 @@ local sub = import '../../../../substation.libsonnet'; { name: 'extend', transforms: [ - sub.tf.test.message({ value: {"a":[1,2,[3,4]]} }), + sub.tf.test.message({ value: { a: [1, 2, [3, 4]] } }), sub.tf.send.stdout(), ], // Asserts that 'a' contains 4 elements. - condition: sub.cnd.num.len.eq({ obj: {src: 'a'}, value: 4 }), - } + condition: sub.cnd.num.len.eq({ obj: { src: 'a' }, value: 4 }), + }, ], transforms: [ // Flatten by copying the value and chaining GJSON's `@flatten` operator. diff --git a/examples/transform/array/flatten_deep/config.jsonnet b/examples/transform/array/flatten_deep/config.jsonnet index 7ff36dc9..82bfe7d2 100644 --- a/examples/transform/array/flatten_deep/config.jsonnet +++ b/examples/transform/array/flatten_deep/config.jsonnet @@ -6,12 +6,12 @@ local sub = import '../../../../substation.libsonnet'; { name: 'extend', transforms: [ - sub.tf.test.message({ value: {"a":[1,2,[3,4,[5,6]]]} }), + sub.tf.test.message({ value: { a: [1, 2, [3, 4, [5, 6]]] } }), sub.tf.send.stdout(), ], // Asserts that 'a' contains 6 elements. - condition: sub.cnd.num.len.eq({ obj: {src: 'a'}, value: 6 }), - } + condition: sub.cnd.num.len.eq({ obj: { src: 'a' }, value: 6 }), + }, ], transforms: [ // Flatten by copying the value and chaining GJSON's `@flatten` operator diff --git a/examples/transform/array/group/config.jsonnet b/examples/transform/array/group/config.jsonnet index 65426ea1..007684d3 100644 --- a/examples/transform/array/group/config.jsonnet +++ b/examples/transform/array/group/config.jsonnet @@ -9,7 +9,7 @@ local files_key = 'meta files'; { name: 'group', transforms: [ - sub.tf.test.message({ value: {"file_name":["foo.txt","bar.html"],"file_type":["text/plain","text/html"],"file_size":[100,500]} }), + sub.tf.test.message({ value: { file_name: ['foo.txt', 'bar.html'], file_type: ['text/plain', 'text/html'], file_size: [100, 500] } }), sub.tf.send.stdout(), ], // Asserts that each element in the array contains these keys: @@ -25,8 +25,8 @@ local files_key = 'meta files'; sub.cnd.num.len.greater_than({ obj: { src: 'file_name' }, value: 0 }), sub.cnd.num.len.greater_than({ obj: { src: 'file_extension' }, value: 0 }), ], - }) - } + }), + }, ], transforms: [ // Copy the object to metadata, where it is grouped. diff --git a/examples/transform/enrich/http_secret/config.jsonnet b/examples/transform/enrich/http_secret/config.jsonnet index 3b3d77ff..f8995e9b 100644 --- a/examples/transform/enrich/http_secret/config.jsonnet +++ b/examples/transform/enrich/http_secret/config.jsonnet @@ -1,16 +1,26 @@ // This example shows how to use the `utility_secret` transform to // retrieve a secret and reference it in a subsequent transform. +// +// Test this example using the substation CLI: +// SUBSTATION_EXAMPLE_URL=https://www.gutenberg.org/files/2701/old/moby10b.txt substation test config.jsonnet local sub = import '../../../../substation.libsonnet'; // The secret is retrieved from the environment variable named // `SUBSTATION_EXAMPLE_URL` and referenced in subsequent transforms using // the ID value `ENV_VAR`. -// -// Run this on the local system as an example: -// export SUBSTATION_EXAMPLE_URL=https://www.gutenberg.org/files/2701/old/moby10b.txt local secret = sub.secrets.environment_variable({ id: 'ENV_VAR', name: 'SUBSTATION_EXAMPLE_URL' }); { + tests: [ + { + name: 'http_secret', + transforms: [ + // An empty message is sufficient for this test. + sub.tf.test.message(), + ], + condition: sub.cnd.num.len.gt({ value: 0 }), + }, + ], // The `utility_secret` transform retrieves the secret from the environment // variable and keeps it in memory. The `enrich_http_get` transform references // the secret using the ID value `ENV_VAR`. In this example, the secret is the diff --git a/examples/transform/enrich/http_secret/data.json b/examples/transform/enrich/http_secret/data.json deleted file mode 100644 index 0967ef42..00000000 --- a/examples/transform/enrich/http_secret/data.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/transform/enrich/kvstore_csv/config.jsonnet b/examples/transform/enrich/kvstore_csv/config.jsonnet index 87811726..47153d46 100644 --- a/examples/transform/enrich/kvstore_csv/config.jsonnet +++ b/examples/transform/enrich/kvstore_csv/config.jsonnet @@ -14,12 +14,12 @@ local kv = sub.kv_store.csv_file({ file: 'kv.csv', column: 'product' }); { name: 'kvstore_csv', transforms: [ - sub.tf.test.message({ value: {"product":"churro"} }), + sub.tf.test.message({ value: { product: 'churro' } }), sub.tf.send.stdout(), ], // Asserts that the message contains product info. condition: sub.cnd.num.len.gt({ object: { source_key: 'info' }, value: 0 }), - } + }, ], transforms: [ // The CSV file KV store returns the entire row minus the key column. diff --git a/examples/transform/enrich/kvstore_json/config.jsonnet b/examples/transform/enrich/kvstore_json/config.jsonnet index 0cc5a1ec..bb56d207 100644 --- a/examples/transform/enrich/kvstore_json/config.jsonnet +++ b/examples/transform/enrich/kvstore_json/config.jsonnet @@ -11,12 +11,12 @@ local kv = sub.kv_store.json_file({ file: 'kv.json' }); { name: 'kvstore_json', transforms: [ - sub.tf.test.message({ value: {"product":"churro"} }), + sub.tf.test.message({ value: { product: 'churro' } }), sub.tf.send.stdout(), ], // Asserts that the message contains product info. condition: sub.cnd.num.len.gt({ object: { source_key: 'price' }, value: 0 }), - } + }, ], transforms: [ sub.tf.enrich.kv_store.item.get({ diff --git a/examples/transform/enrich/kvstore_set_add/config.jsonnet b/examples/transform/enrich/kvstore_set_add/config.jsonnet index fe70453b..9d7452fb 100644 --- a/examples/transform/enrich/kvstore_set_add/config.jsonnet +++ b/examples/transform/enrich/kvstore_set_add/config.jsonnet @@ -11,17 +11,17 @@ local mem = sub.kv_store.memory(); { name: 'kvstore_set_add', transforms: [ - sub.tf.test.message({ value: {"date": "2021-01-01","customer":"alice@brex.com","order":"pizza"} }), - sub.tf.test.message({ value: {"date": "2021-01-01","customer":"bob@brex.com","order":"burger"} }), - sub.tf.test.message({ value: {"date": "2021-01-03","customer":"bob@brex.com","order":"pizza"} }), - sub.tf.test.message({ value: {"date": "2021-01-07","customer":"alice@brex.com","order":"pizza"} }), - sub.tf.test.message({ value: {"date": "2021-01-07","customer":"bob@brex.com","order":"burger"} }), - sub.tf.test.message({ value: {"date": "2021-01-13","customer":"alice@brex.com","order":"pizza"} }), + sub.tf.test.message({ value: { date: '2021-01-01', customer: 'alice@brex.com', order: 'pizza' } }), + sub.tf.test.message({ value: { date: '2021-01-01', customer: 'bob@brex.com', order: 'burger' } }), + sub.tf.test.message({ value: { date: '2021-01-03', customer: 'bob@brex.com', order: 'pizza' } }), + sub.tf.test.message({ value: { date: '2021-01-07', customer: 'alice@brex.com', order: 'pizza' } }), + sub.tf.test.message({ value: { date: '2021-01-07', customer: 'bob@brex.com', order: 'burger' } }), + sub.tf.test.message({ value: { date: '2021-01-13', customer: 'alice@brex.com', order: 'pizza' } }), sub.tf.send.stdout(), ], // Asserts that each message is not empty. condition: sub.cnd.num.len.gt({ value: 0 }), - } + }, ], transforms: [ // Each order is stored in memory indexed by the customer's email diff --git a/examples/transform/enrich/mmdb/config.jsonnet b/examples/transform/enrich/mmdb/config.jsonnet index 5a717502..d3ce76b6 100644 --- a/examples/transform/enrich/mmdb/config.jsonnet +++ b/examples/transform/enrich/mmdb/config.jsonnet @@ -7,19 +7,19 @@ local asn = sub.kv_store.mmdb({ file: 'https://gist.github.com/jshlbrd/59641ccc7 { name: 'mmdb-cloudflare', transforms: [ - sub.tf.test.message({ value: {"ip":"1.1.1.1"} }), + sub.tf.test.message({ value: { ip: '1.1.1.1' } }), ], // Asserts that the message contains ASN info. - condition: sub.cnd.str.eq({ obj: {src: 'asn.autonomous_system_organization'}, value: 'CLOUDFLARENET' }), + condition: sub.cnd.str.eq({ obj: { src: 'asn.autonomous_system_organization' }, value: 'CLOUDFLARENET' }), }, { name: 'mmdb-google', transforms: [ - sub.tf.test.message({ value: {"ip":"8.8.8.8"} }), + sub.tf.test.message({ value: { ip: '8.8.8.8' } }), ], // Asserts that the message contains ASN info. - condition: sub.cnd.str.eq({ obj: {src: 'asn.autonomous_system_organization'}, value: 'GOOGLE' }), - } + condition: sub.cnd.str.eq({ obj: { src: 'asn.autonomous_system_organization' }, value: 'GOOGLE' }), + }, ], transforms: [ sub.tf.enrich.kv_store.item.get({ object: { source_key: 'ip', target_key: 'asn' }, kv_store: asn }), diff --git a/examples/transform/enrich/urlscan/config.jsonnet b/examples/transform/enrich/urlscan/config.jsonnet index c7c7c4fe..0aa8bd9b 100644 --- a/examples/transform/enrich/urlscan/config.jsonnet +++ b/examples/transform/enrich/urlscan/config.jsonnet @@ -1,10 +1,22 @@ // This example shows how to make scan requests and retrieve // results using the urlscan API (https://urlscan.io/docs/api/). +// +// Test this example using the substation CLI: +// URLSCAN_API_KEY=xx substation test config.jsonnet local sub = import '../../../../substation.libsonnet'; local headers = { 'API-Key': '${SECRET:URLSCAN}', 'Content-Type': 'application/json' }; { + tests: [ + { + name: 'urlscan', + transforms: [ + sub.tf.test.message({ value: { url: 'https://www.brex.com/' } }), + ], + condition: sub.cnd.str.eq({ object: { source_key: 'task.domain' }, value: 'www.brex.com' }), + }, + ], transforms: [ // Retrieve the urlscan API key from the secrets store. // (Never put a secret directly into a configuration.) diff --git a/examples/transform/enrich/urlscan/data.json b/examples/transform/enrich/urlscan/data.json deleted file mode 100644 index 0315fbab..00000000 --- a/examples/transform/enrich/urlscan/data.json +++ /dev/null @@ -1 +0,0 @@ -{"url":"https://www.brex.com/"} diff --git a/examples/transform/format/zip/config.jsonnet b/examples/transform/format/zip/config.jsonnet index a88a365f..172549db 100644 --- a/examples/transform/format/zip/config.jsonnet +++ b/examples/transform/format/zip/config.jsonnet @@ -15,7 +15,7 @@ local sub = import '../../../../substation.libsonnet'; ], // Asserts that each message is not empty. condition: sub.cnd.num.len.gt({ value: 0 }), - } + }, ], transforms: [ // Unzip the file. The contents of each file in the Zip file are diff --git a/examples/transform/meta/crash_program/config.jsonnet b/examples/transform/meta/crash_program/config.jsonnet index 858a04f5..8df3a7f7 100644 --- a/examples/transform/meta/crash_program/config.jsonnet +++ b/examples/transform/meta/crash_program/config.jsonnet @@ -8,6 +8,16 @@ local sub = import '../../../../substation.libsonnet'; local key = 'c'; { + tests: [ + // This test should result in a config error if the program crashed. + { + name: 'crash_program', + transforms: [ + sub.tf.test.message({ value: { a: 'b' } }), + ], + condition: sub.cnd.num.len.gt({ value: 0 }), + }, + ], transforms: [ // This simulates a transform that may not produce an output. sub.tf.meta.switch({ cases: [ diff --git a/examples/transform/meta/crash_program/data.json b/examples/transform/meta/crash_program/data.json deleted file mode 100644 index b6e81411..00000000 --- a/examples/transform/meta/crash_program/data.json +++ /dev/null @@ -1 +0,0 @@ -{"a":"b"} diff --git a/examples/transform/meta/crash_program/stdout.txt b/examples/transform/meta/crash_program/stdout.txt deleted file mode 100644 index a093b4e1..00000000 --- a/examples/transform/meta/crash_program/stdout.txt +++ /dev/null @@ -1 +0,0 @@ -panic: main: transform b3a47dd1-f67ef52a: transform produced no output diff --git a/examples/transform/meta/default_value/config.jsonnet b/examples/transform/meta/default_value/config.jsonnet index 77719789..4eeda314 100644 --- a/examples/transform/meta/default_value/config.jsonnet +++ b/examples/transform/meta/default_value/config.jsonnet @@ -5,12 +5,12 @@ local sub = import '../../../../substation.libsonnet'; { name: 'default_value', transforms: [ - sub.tf.test.message({ value: {"a":"b"} }), + sub.tf.test.message({ value: { a: 'b' } }), sub.tf.send.stdout(), ], // Asserts that 'z' exists. - condition: sub.cnd.num.len.greater_than({ obj: {src: 'z'}, value: 0 }), - } + condition: sub.cnd.num.len.greater_than({ obj: { src: 'z' }, value: 0 }), + }, ], transforms: [ sub.tf.object.insert({ object: { target_key: 'z' }, value: true }), diff --git a/examples/transform/meta/each_in_array/config.jsonnet b/examples/transform/meta/each_in_array/config.jsonnet index 3de8710f..db4333b0 100644 --- a/examples/transform/meta/each_in_array/config.jsonnet +++ b/examples/transform/meta/each_in_array/config.jsonnet @@ -8,7 +8,7 @@ local sub = import '../../../../substation.libsonnet'; { name: 'each_in_array', transforms: [ - sub.tf.test.message({ value: {"a":[{"b":1,"c":2},{"b":3,"c":4}]} }), + sub.tf.test.message({ value: { a: [{ b: 1, c: 2 }, { b: 3, c: 4 }] } }), sub.tf.send.stdout(), ], // Asserts that each object in the array 'a' has: @@ -17,11 +17,11 @@ local sub = import '../../../../substation.libsonnet'; condition: sub.cnd.meta.all({ object: { src: 'a' }, conditions: [ - sub.cnd.num.len.eq({ obj: {src: 'b'}, value: 0 }), - sub.cnd.str.eq({ obj: {src: 'z'}, value: 'true' }), + sub.cnd.num.len.eq({ obj: { src: 'b' }, value: 0 }), + sub.cnd.str.eq({ obj: { src: 'z' }, value: 'true' }), ], }), - } + }, ], transforms: [ sub.tf.meta.for_each({ diff --git a/examples/transform/meta/exactly_once_consumer/config.jsonnet b/examples/transform/meta/exactly_once_consumer/config.jsonnet index d2e52210..6e2f279b 100644 --- a/examples/transform/meta/exactly_once_consumer/config.jsonnet +++ b/examples/transform/meta/exactly_once_consumer/config.jsonnet @@ -10,18 +10,18 @@ local kv = sub.kv_store.memory(); { name: 'exactly_once_consumer', transforms: [ - sub.tf.test.message({ value: {"a":"b"} }), - sub.tf.test.message({ value: {"a":"b"} }), - sub.tf.test.message({ value: {"c":"d"} }), - sub.tf.test.message({ value: {"a":"b"} }), - sub.tf.test.message({ value: {"c":"d"} }), - sub.tf.test.message({ value: {"c":"d"} }), - sub.tf.test.message({ value: {"e":"f"} }), - sub.tf.test.message({ value: {"a":"b"} }), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { e: 'f' } }), + sub.tf.test.message({ value: { a: 'b' } }), ], // Asserts that each message is not empty. condition: sub.cnd.num.len.gt({ value: 0 }), - } + }, ], transforms: [ // If a message acquires a lock, then it is tagged for inspection. diff --git a/examples/transform/meta/exactly_once_producer/config.jsonnet b/examples/transform/meta/exactly_once_producer/config.jsonnet index f2660925..01051b0f 100644 --- a/examples/transform/meta/exactly_once_producer/config.jsonnet +++ b/examples/transform/meta/exactly_once_producer/config.jsonnet @@ -10,18 +10,18 @@ local kv = sub.kv_store.memory(); { name: 'exactly_once_producer', transforms: [ - sub.tf.test.message({ value: {"a":"b"} }), - sub.tf.test.message({ value: {"a":"b"} }), - sub.tf.test.message({ value: {"c":"d"} }), - sub.tf.test.message({ value: {"a":"b"} }), - sub.tf.test.message({ value: {"c":"d"} }), - sub.tf.test.message({ value: {"c":"d"} }), - sub.tf.test.message({ value: {"e":"f"} }), - sub.tf.test.message({ value: {"a":"b"} }), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { e: 'f' } }), + sub.tf.test.message({ value: { a: 'b' } }), ], // Asserts that each message is not empty. condition: sub.cnd.num.len.gt({ value: 0 }), - } + }, ], transforms: [ // This only prints messages that acquire a lock. Any message diff --git a/examples/transform/meta/exactly_once_system/config.jsonnet b/examples/transform/meta/exactly_once_system/config.jsonnet index 16529c09..2757aa3c 100644 --- a/examples/transform/meta/exactly_once_system/config.jsonnet +++ b/examples/transform/meta/exactly_once_system/config.jsonnet @@ -10,18 +10,18 @@ local kv = sub.kv_store.memory(); { name: 'exactly_once_producer', transforms: [ - sub.tf.test.message({ value: {"a":"b"} }), - sub.tf.test.message({ value: {"a":"b"} }), - sub.tf.test.message({ value: {"c":"d"} }), - sub.tf.test.message({ value: {"a":"b"} }), - sub.tf.test.message({ value: {"c":"d"} }), - sub.tf.test.message({ value: {"c":"d"} }), - sub.tf.test.message({ value: {"e":"f"} }), - sub.tf.test.message({ value: {"a":"b"} }), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { e: 'f' } }), + sub.tf.test.message({ value: { a: 'b' } }), ], // Asserts that each message is not empty. condition: sub.cnd.num.len.gt({ value: 0 }), - } + }, ], transforms: [ // All messages are locked before being sent through other transform diff --git a/examples/transform/meta/execution_time/config.jsonnet b/examples/transform/meta/execution_time/config.jsonnet index c49ea3b1..69f6c67f 100644 --- a/examples/transform/meta/execution_time/config.jsonnet +++ b/examples/transform/meta/execution_time/config.jsonnet @@ -10,11 +10,11 @@ local dest = { type: 'aws_cloudwatch_embedded_metrics' }; { name: 'execution_time', transforms: [ - sub.tf.test.message({ value: {"a":"b"} }), + sub.tf.test.message({ value: { a: 'b' } }), ], // Asserts that each message is not empty. condition: sub.cnd.num.len.gt({ value: 0 }), - } + }, ], transforms: [ // The `meta_metric_duration` transform measures the execution time of diff --git a/examples/transform/meta/retry_with_backoff/config.jsonnet b/examples/transform/meta/retry_with_backoff/config.jsonnet index c35b3c18..d9635cb7 100644 --- a/examples/transform/meta/retry_with_backoff/config.jsonnet +++ b/examples/transform/meta/retry_with_backoff/config.jsonnet @@ -17,11 +17,11 @@ local cnd = sub.cnd.all([ { name: 'retry_with_backoff', transforms: [ - sub.tf.test.message({ value: {"a":"b"} }), + sub.tf.test.message({ value: { a: 'b' } }), ], // Asserts that the target key 'c' exists. condition: sub.cnd.num.len.greater_than({ object: { source_key: key }, value: 1 }), - } + }, ], transforms: [ sub.tf.meta.retry({ diff --git a/examples/transform/number/clamp/config.jsonnet b/examples/transform/number/clamp/config.jsonnet index d9209bf5..72956274 100644 --- a/examples/transform/number/clamp/config.jsonnet +++ b/examples/transform/number/clamp/config.jsonnet @@ -16,7 +16,7 @@ local sub = import '../../../../substation.libsonnet'; sub.cnd.num.greater_than({ value: -1 }), sub.cnd.num.less_than({ value: 101 }), ]), - } + }, ], transforms: [ sub.tf.number.maximum({ value: 0 }), diff --git a/examples/transform/number/max/config.jsonnet b/examples/transform/number/max/config.jsonnet index ed1f7647..6e906b54 100644 --- a/examples/transform/number/max/config.jsonnet +++ b/examples/transform/number/max/config.jsonnet @@ -15,7 +15,7 @@ local sub = import '../../../../substation.libsonnet'; ], // Asserts that each number is greater than -1. condition: sub.cnd.num.greater_than({ value: -1 }), - } + }, ], transforms: [ sub.tf.num.max({ value: 0 }), diff --git a/examples/transform/number/min/config.jsonnet b/examples/transform/number/min/config.jsonnet index c117ce68..b5ae1c22 100644 --- a/examples/transform/number/min/config.jsonnet +++ b/examples/transform/number/min/config.jsonnet @@ -15,7 +15,7 @@ local sub = import '../../../../substation.libsonnet'; ], // Asserts that each number is less than 1. condition: sub.cnd.num.less_than({ value: 1 }), - } + }, ], transforms: [ sub.tf.num.min({ value: 0 }), diff --git a/examples/transform/send/aux_transforms/config.jsonnet b/examples/transform/send/aux_transforms/config.jsonnet index eae9a327..bc642b6d 100644 --- a/examples/transform/send/aux_transforms/config.jsonnet +++ b/examples/transform/send/aux_transforms/config.jsonnet @@ -5,6 +5,27 @@ local sub = import '../../../../substation.libsonnet'; { + tests: [ + { + name: 'aux_transforms', + transforms: [ + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { e: 'f' } }), + sub.tf.test.message({ value: { g: 'h' } }), + sub.tf.test.message({ value: { i: 'j' } }), + sub.tf.test.message({ value: { k: 'l' } }), + sub.tf.test.message({ value: { m: 'n' } }), + sub.tf.test.message({ value: { o: 'p' } }), + sub.tf.test.message({ value: { q: 'r' } }), + sub.tf.test.message({ value: { s: 't' } }), + sub.tf.test.message({ value: { u: 'v' } }), + sub.tf.test.message({ value: { w: 'x' } }), + sub.tf.test.message({ value: { y: 'z' } }), + ], + condition: sub.cnd.num.len.gt({ value: 0 }), + }, + ], transforms: [ // By default all data is buffered before it is sent. sub.tf.send.stdout({ diff --git a/examples/transform/send/aux_transforms/data.jsonl b/examples/transform/send/aux_transforms/data.jsonl deleted file mode 100644 index d101df01..00000000 --- a/examples/transform/send/aux_transforms/data.jsonl +++ /dev/null @@ -1,13 +0,0 @@ -{"a":"b"} -{"c":"d"} -{"e":"f"} -{"g":"h"} -{"i":"j"} -{"k":"l"} -{"m":"n"} -{"o":"p"} -{"q":"r"} -{"s":"t"} -{"u":"v"} -{"w":"x"} -{"y":"z"} diff --git a/examples/transform/send/aux_transforms/stdout.txt b/examples/transform/send/aux_transforms/stdout.txt deleted file mode 100644 index 3358032f..00000000 --- a/examples/transform/send/aux_transforms/stdout.txt +++ /dev/null @@ -1,26 +0,0 @@ -{"a":"b"} -{"c":"d"} -{"e":"f"} -{"g":"h"} -{"i":"j"} -{"k":"l"} -{"m":"n"} -{"o":"p"} -{"q":"r"} -{"s":"t"} -{"u":"v"} -{"w":"x"} -{"a":"b","transformed_by":"send_stdout"} -{"c":"d","transformed_by":"send_stdout"} -{"e":"f","transformed_by":"send_stdout"} -{"g":"h","transformed_by":"send_stdout"} -{"i":"j","transformed_by":"send_stdout"} -{"k":"l","transformed_by":"send_stdout"} -{"m":"n","transformed_by":"send_stdout"} -{"o":"p","transformed_by":"send_stdout"} -{"q":"r","transformed_by":"send_stdout"} -{"s":"t","transformed_by":"send_stdout"} -{"u":"v","transformed_by":"send_stdout"} -{"w":"x","transformed_by":"send_stdout"} -{"y":"z","transformed_by":"send_stdout"} -{"y":"z"} diff --git a/examples/transform/send/batch/config.jsonnet b/examples/transform/send/batch/config.jsonnet index f2f32c57..ec6a5583 100644 --- a/examples/transform/send/batch/config.jsonnet +++ b/examples/transform/send/batch/config.jsonnet @@ -4,6 +4,27 @@ local sub = import '../../../../substation.libsonnet'; { + tests: [ + { + name: 'aux_transforms', + transforms: [ + sub.tf.test.message({ value: { a: 'b', group_id: 1 } }), + sub.tf.test.message({ value: { c: 'd', group_id: 2 } }), + sub.tf.test.message({ value: { e: 'f', group_id: 1 } }), + sub.tf.test.message({ value: { g: 'h', group_id: 2 } }), + sub.tf.test.message({ value: { i: 'j', group_id: 1 } }), + sub.tf.test.message({ value: { k: 'l', group_id: 2 } }), + sub.tf.test.message({ value: { m: 'n', group_id: 1 } }), + sub.tf.test.message({ value: { o: 'p', group_id: 2 } }), + sub.tf.test.message({ value: { q: 'r', group_id: 1 } }), + sub.tf.test.message({ value: { s: 't', group_id: 2 } }), + sub.tf.test.message({ value: { u: 'v', group_id: 1 } }), + sub.tf.test.message({ value: { w: 'x', group_id: 2 } }), + sub.tf.test.message({ value: { y: 'z', group_id: 1 } }), + ], + condition: sub.cnd.num.len.gt({ value: 0 }), + }, + ], transforms: [ sub.tf.object.copy({ object: { source_key: '@pretty' } }), // Each object is organized by the value retrieved from the `group_id` key. diff --git a/examples/transform/send/batch/data.jsonl b/examples/transform/send/batch/data.jsonl deleted file mode 100644 index 40196852..00000000 --- a/examples/transform/send/batch/data.jsonl +++ /dev/null @@ -1,13 +0,0 @@ -{"a":"b","group_id":1} -{"c":"d","group_id":2} -{"e":"f","group_id":1} -{"g":"h","group_id":2} -{"i":"j","group_id":1} -{"k":"l","group_id":2} -{"m":"n","group_id":1} -{"o":"p","group_id":2} -{"q":"r","group_id":1} -{"s":"t","group_id":2} -{"u":"v","group_id":1} -{"w":"x","group_id":2} -{"y":"z","group_id":1} diff --git a/examples/transform/send/batch/stdout.txt b/examples/transform/send/batch/stdout.txt deleted file mode 100644 index 183cb9c0..00000000 --- a/examples/transform/send/batch/stdout.txt +++ /dev/null @@ -1,64 +0,0 @@ -{ - "a": "b", - "group_id": 1 -} - -{ - "e": "f", - "group_id": 1 -} - -{ - "i": "j", - "group_id": 1 -} - -{ - "m": "n", - "group_id": 1 -} - -{ - "q": "r", - "group_id": 1 -} - -{ - "u": "v", - "group_id": 1 -} - -{ - "y": "z", - "group_id": 1 -} - -{ - "c": "d", - "group_id": 2 -} - -{ - "g": "h", - "group_id": 2 -} - -{ - "k": "l", - "group_id": 2 -} - -{ - "o": "p", - "group_id": 2 -} - -{ - "s": "t", - "group_id": 2 -} - -{ - "w": "x", - "group_id": 2 -} diff --git a/examples/transform/send/datadog/data.jsonl b/examples/transform/send/datadog/data.jsonl deleted file mode 100644 index d101df01..00000000 --- a/examples/transform/send/datadog/data.jsonl +++ /dev/null @@ -1,13 +0,0 @@ -{"a":"b"} -{"c":"d"} -{"e":"f"} -{"g":"h"} -{"i":"j"} -{"k":"l"} -{"m":"n"} -{"o":"p"} -{"q":"r"} -{"s":"t"} -{"u":"v"} -{"w":"x"} -{"y":"z"} diff --git a/examples/transform/send/splunk/data.jsonl b/examples/transform/send/splunk/data.jsonl deleted file mode 100644 index d101df01..00000000 --- a/examples/transform/send/splunk/data.jsonl +++ /dev/null @@ -1,13 +0,0 @@ -{"a":"b"} -{"c":"d"} -{"e":"f"} -{"g":"h"} -{"i":"j"} -{"k":"l"} -{"m":"n"} -{"o":"p"} -{"q":"r"} -{"s":"t"} -{"u":"v"} -{"w":"x"} -{"y":"z"} diff --git a/examples/transform/send/sumologic/data.jsonl b/examples/transform/send/sumologic/data.jsonl deleted file mode 100644 index d101df01..00000000 --- a/examples/transform/send/sumologic/data.jsonl +++ /dev/null @@ -1,13 +0,0 @@ -{"a":"b"} -{"c":"d"} -{"e":"f"} -{"g":"h"} -{"i":"j"} -{"k":"l"} -{"m":"n"} -{"o":"p"} -{"q":"r"} -{"s":"t"} -{"u":"v"} -{"w":"x"} -{"y":"z"} diff --git a/examples/transform/test/config_test/config.jsonnet b/examples/transform/test/config_test/config.jsonnet new file mode 100644 index 00000000..7fa7eb7d --- /dev/null +++ b/examples/transform/test/config_test/config.jsonnet @@ -0,0 +1,26 @@ +local sub = import '../../../../substation.libsonnet'; + +{ + tests: [ + { + // Every test should have a unique name. + name: 'my_passing_test', + // Generates the test message '{"a": true}' which + // is run through the configured transforms and + // then checked against the condition. + transforms: [ + sub.tf.test.message({ value: { a: true } }), + ], + // Checks if key 'x' == 'true'. + condition: sub.cnd.all([ + sub.cnd.str.eq({ object: { source_key: 'x' }, value: 'true' }), + ]), + }, + ], + // These transforms process the test message and the result + // is checked against the condition. + transforms: [ + // Copies the value of key 'a' to key 'x'. + sub.tf.obj.cp({ object: { source_key: 'a', target_key: 'x' } }), + ], +} diff --git a/examples/transform/time/str_conversion/config.jsonnet b/examples/transform/time/str_conversion/config.jsonnet index 3db00c3a..5ab554d1 100644 --- a/examples/transform/time/str_conversion/config.jsonnet +++ b/examples/transform/time/str_conversion/config.jsonnet @@ -6,12 +6,12 @@ local sub = import '../../../../substation.libsonnet'; { name: 'str_conversion', transforms: [ - sub.tf.test.message({ value: {"time":"2024-01-01T01:02:03.123Z"}}), + sub.tf.test.message({ value: { time: '2024-01-01T01:02:03.123Z' } }), sub.tf.send.stdout(), ], // Asserts that the time value is equal to the expected value. - condition: sub.cnd.str.eq({ obj: {src: 'time'}, value: '2024-01-01T01:02:03' }), - } + condition: sub.cnd.str.eq({ obj: { src: 'time' }, value: '2024-01-01T01:02:03' }), + }, ], // Substation uses Go's pattern-based time format (https://gobyexample.com/time-formatting-parsing) // to convert time values to and from strings. All time values in the system are in epoch / Unix format diff --git a/examples/transform/utility/generate_ctrl/config.jsonnet b/examples/transform/utility/generate_ctrl/config.jsonnet index 63f453df..74be6e73 100644 --- a/examples/transform/utility/generate_ctrl/config.jsonnet +++ b/examples/transform/utility/generate_ctrl/config.jsonnet @@ -9,24 +9,24 @@ local sub = import '../../../../substation.libsonnet'; { name: 'generate_ctrl', transforms: [ - sub.tf.test.message({ value: {"a":"b"}}), - sub.tf.test.message({ value: {"c":"d"}}), - sub.tf.test.message({ value: {"e":"f"}}), - sub.tf.test.message({ value: {"g":"h"}}), - sub.tf.test.message({ value: {"i":"j"}}), - sub.tf.test.message({ value: {"k":"l"}}), - sub.tf.test.message({ value: {"m":"n"}}), - sub.tf.test.message({ value: {"o":"p"}}), - sub.tf.test.message({ value: {"q":"r"}}), - sub.tf.test.message({ value: {"s":"t"}}), - sub.tf.test.message({ value: {"u":"v"}}), - sub.tf.test.message({ value: {"w":"x"}}), - sub.tf.test.message({ value: {"y":"z"}}), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { e: 'f' } }), + sub.tf.test.message({ value: { g: 'h' } }), + sub.tf.test.message({ value: { i: 'j' } }), + sub.tf.test.message({ value: { k: 'l' } }), + sub.tf.test.message({ value: { m: 'n' } }), + sub.tf.test.message({ value: { o: 'p' } }), + sub.tf.test.message({ value: { q: 'r' } }), + sub.tf.test.message({ value: { s: 't' } }), + sub.tf.test.message({ value: { u: 'v' } }), + sub.tf.test.message({ value: { w: 'x' } }), + sub.tf.test.message({ value: { y: 'z' } }), sub.tf.send.stdout(), ], // Asserts that the number of objects in each array is less than 3. - condition: sub.cnd.num.len.less_than({ obj: {src: '@this'}, value: 3 }), - } + condition: sub.cnd.num.len.less_than({ obj: { src: '@this' }, value: 3 }), + }, ], transforms: [ sub.tf.utility.control({ batch: { count: 2 } }), diff --git a/examples/transform/utility/message_bytes/config.jsonnet b/examples/transform/utility/message_bytes/config.jsonnet index e3e9d462..fe586351 100644 --- a/examples/transform/utility/message_bytes/config.jsonnet +++ b/examples/transform/utility/message_bytes/config.jsonnet @@ -10,23 +10,23 @@ local dest = { type: 'aws_cloudwatch_embedded_metrics' }; { name: 'message_bytes', transforms: [ - sub.tf.test.message({ value: {"a":"b"}}), - sub.tf.test.message({ value: {"c":"d"}}), - sub.tf.test.message({ value: {"e":"f"}}), - sub.tf.test.message({ value: {"g":"h"}}), - sub.tf.test.message({ value: {"i":"j"}}), - sub.tf.test.message({ value: {"k":"l"}}), - sub.tf.test.message({ value: {"m":"n"}}), - sub.tf.test.message({ value: {"o":"p"}}), - sub.tf.test.message({ value: {"q":"r"}}), - sub.tf.test.message({ value: {"s":"t"}}), - sub.tf.test.message({ value: {"u":"v"}}), - sub.tf.test.message({ value: {"w":"x"}}), - sub.tf.test.message({ value: {"y":"z"}}), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { e: 'f' } }), + sub.tf.test.message({ value: { g: 'h' } }), + sub.tf.test.message({ value: { i: 'j' } }), + sub.tf.test.message({ value: { k: 'l' } }), + sub.tf.test.message({ value: { m: 'n' } }), + sub.tf.test.message({ value: { o: 'p' } }), + sub.tf.test.message({ value: { q: 'r' } }), + sub.tf.test.message({ value: { s: 't' } }), + sub.tf.test.message({ value: { u: 'v' } }), + sub.tf.test.message({ value: { w: 'x' } }), + sub.tf.test.message({ value: { y: 'z' } }), ], // Asserts that each message is not empty. condition: sub.cnd.num.len.gt({ value: 0 }), - } + }, ], transforms: [ // If the transform is configured first, then the metric reflects diff --git a/examples/transform/utility/message_count/config.jsonnet b/examples/transform/utility/message_count/config.jsonnet index f12c6cf9..1bc6fc04 100644 --- a/examples/transform/utility/message_count/config.jsonnet +++ b/examples/transform/utility/message_count/config.jsonnet @@ -10,23 +10,23 @@ local dest = { type: 'aws_cloudwatch_embedded_metrics' }; { name: 'message_count', transforms: [ - sub.tf.test.message({ value: {"a":"b"}}), - sub.tf.test.message({ value: {"c":"d"}}), - sub.tf.test.message({ value: {"e":"f"}}), - sub.tf.test.message({ value: {"g":"h"}}), - sub.tf.test.message({ value: {"i":"j"}}), - sub.tf.test.message({ value: {"k":"l"}}), - sub.tf.test.message({ value: {"m":"n"}}), - sub.tf.test.message({ value: {"o":"p"}}), - sub.tf.test.message({ value: {"q":"r"}}), - sub.tf.test.message({ value: {"s":"t"}}), - sub.tf.test.message({ value: {"u":"v"}}), - sub.tf.test.message({ value: {"w":"x"}}), - sub.tf.test.message({ value: {"y":"z"}}), + sub.tf.test.message({ value: { a: 'b' } }), + sub.tf.test.message({ value: { c: 'd' } }), + sub.tf.test.message({ value: { e: 'f' } }), + sub.tf.test.message({ value: { g: 'h' } }), + sub.tf.test.message({ value: { i: 'j' } }), + sub.tf.test.message({ value: { k: 'l' } }), + sub.tf.test.message({ value: { m: 'n' } }), + sub.tf.test.message({ value: { o: 'p' } }), + sub.tf.test.message({ value: { q: 'r' } }), + sub.tf.test.message({ value: { s: 't' } }), + sub.tf.test.message({ value: { u: 'v' } }), + sub.tf.test.message({ value: { w: 'x' } }), + sub.tf.test.message({ value: { y: 'z' } }), ], // Asserts that each message is not empty. condition: sub.cnd.num.len.gt({ value: 0 }), - } + }, ], transforms: [ // If the transform is configured first, then the count reflects diff --git a/examples/transform/utility/message_freshness/config.jsonnet b/examples/transform/utility/message_freshness/config.jsonnet index 473075b1..ca1a0c00 100644 --- a/examples/transform/utility/message_freshness/config.jsonnet +++ b/examples/transform/utility/message_freshness/config.jsonnet @@ -18,11 +18,11 @@ local dest = { type: 'aws_cloudwatch_embedded_metrics' }; { name: 'message_freshness', transforms: [ - sub.tf.test.message({ value: {"timestamp":1724299266000000000}}), + sub.tf.test.message({ value: { timestamp: 1724299266000000000 } }), ], // Asserts that the message is not empty. condition: sub.cnd.num.len.gt({ value: 0 }), - } + }, ], transforms: [ sub.transform.utility.metric.freshness({