# HashXXmod

## Purpose

Generates a number which is mod of given string’s hash.

### hash32mod(literal_string, modulo) / hash32mod(literal_string, modulo, seed)

> Generates a number which is calculated on (32 bit hash of the given string % modulo)

>   - If modulo is not a valid number, then 0 is returned.

>   - If modulo is 0, then 0 is returned.

>   - Seed is an optional parameter with default = 0.

>   - If seed is not a valid unsigned number, then 0 is returned.

### hash64mod(literal_string, modulo) / hash64mod(literal_string, modulo, seed)

> Generates a number which is calculated on (64 bit hash of the given string % modulo)

>   - If modulo is not a valid number, then 0 is returned.

>   - If modulo is 0, then 0 is returned.

>   - Seed is an optional parameter with default = 0.

>   - If seed is not a valid unsigned number, then 0 is returned.

Warning

- Default hash implementation is non-crypto.

- To use xxhash enable compile time flag.

## Example

    module(load="fmhash")

    if (hash64mod($!msg!request_id, 100) <= 30) then {
     //send out
    }

See also

Hash based sampling

See also

Help with configuring/using `Rsyslog`:

- Mailing list - best route for general questions

- GitHub: rsyslog source project - detailed questions, reporting issues that are believed to be bugs with `Rsyslog`

- Stack Exchange (View, Ask) - experimental support from rsyslog community

See also

Contributing to `Rsyslog`:

- Source project: rsyslog project README.

- Documentation: rsyslog-doc project README

Copyright 2008-2020 Rainer Gerhards (Großrinderfeld), and Others.