# How to set up kafka output partition option: hash.hash or key?

**URL:** <https://discuss.elastic.co/t/how-to-set-up-kafka-output-partition-option-hash-hash-or-key/102311>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [September 29, 2017, 8:19pm UTC](https://discuss.elastic.co/t/how-to-set-up-kafka-output-partition-option-hash-hash-or-key/102311 "2017-09-29T20:19:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![filebeater](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/filebeater/32/18565_2.png) [@filebeater](https://discuss.elastic.co/u/filebeater)\
**Post date:** [September 29, 2017, 8:19pm UTC](https://discuss.elastic.co/t/how-to-set-up-kafka-output-partition-option-hash-hash-or-key/102311/1 "2017-09-29T20:19:23Z")

</div>

Hello,  
Can I set up kafka partitions as follows?  
partition: hash  
hash.hash to be combination of beat.hostname + source?  
key to be the same as beat.hostname + source?

I am wondering what should be the correct syntax for the above setting? I could not find an example.

thanks!  
yan

---

<div class="post-metadata">

**Author:** ![steffens](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steffens/32/79630_2.png) [@steffens](https://discuss.elastic.co/u/steffens)\
**Post date:** [October 4, 2017, 11:30am UTC](https://discuss.elastic.co/t/how-to-set-up-kafka-output-partition-option-hash-hash-or-key/102311/2 "2017-10-04T11:30:13Z")

</div>

There is a difference between key based and non-key based hashing. As you want to hash based on hostname and source, you want it to be not-key based (as key will become the kafka key, overwriting recent events).

e.g.

```auto
output.kafka:
  partition.hash:
    hash: ['source', 'beat.hostname']
    random: true # if false non-hashable events will be dropped

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 1, 2017, 11:30am UTC](https://discuss.elastic.co/t/how-to-set-up-kafka-output-partition-option-hash-hash-or-key/102311/3 "2017-11-01T11:30:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
