github.com/Jeffail/benthos/v3@v3.65.0/template/test/log_and_drop.yaml (about) 1 name: log_and_drop 2 type: processor 3 categories: [ Utility ] 4 summary: A common lossy error handling pattern. 5 description: If a message has failed in a previous processor this one will log the error and the contents of the message and then drop it. This is a common pattern when working with data that isn't considered important. 6 7 fields: [] 8 9 mapping: | 10 root.catch = [ 11 { 12 "log": { 13 "level": "ERROR", 14 "fields": { 15 "content": "${! content() }" 16 }, 17 "message": "${! error() }" 18 } 19 }, 20 { 21 "bloblang": "root = deleted()" 22 } 23 ] 24 25 metrics_mapping: | 26 root = if this.has_suffix("1.dropped") { 27 this.replace("1.dropped", "dropped") 28 } else { deleted() } 29 30 tests: 31 - name: No fields 32 config: {} 33 expected: 34 catch: 35 - log: 36 level: ERROR 37 fields: 38 content: "${! content() }" 39 message: "${! error() }" 40 - bloblang: root = deleted()