# How to exclude XML & json key-value if key length is greater than 15 char and value length is greater than 100 char

**URL:** https://discuss.elastic.co/t/how-to-exclude-xml-json-key-value-if-key-length-is-greater-than-15-char-and-value-length-is-greater-than-100-char/270248
**Category:** Logstash
**Created:** [April 15, 2021, 2:11pm UTC](https://discuss.elastic.co/t/how-to-exclude-xml-json-key-value-if-key-length-is-greater-than-15-char-and-value-length-is-greater-than-100-char/270248 "2021-04-15T14:11:17Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [April 15, 2021, 2:57pm UTC](https://discuss.elastic.co/t/how-to-exclude-xml-json-key-value-if-key-length-is-greater-than-15-char-and-value-length-is-greater-than-100-char/270248/2 "2021-04-15T14:57:23Z")

</div>

This will be very similar to the [question](https://discuss.elastic.co/t/how-to-exclude-key-value-pair-from-kv-filter-if-key-size-greater-than-15-char/269566/2) you asked about filtering on just the key length

```
ruby {
    code => '
        event.to_hash.each { |k, v|
            if k.length > 15 and v.length > 100
                event.remove(k)
            end
        }
    '
}
```

---

_[View the full topic](https://discuss.elastic.co/t/how-to-exclude-xml-json-key-value-if-key-length-is-greater-than-15-char-and-value-length-is-greater-than-100-char/270248)._
