Calculates a secure hash of a field and uses that to match events as a filter. See hashRewrite() on how get hashes into events. Bits must be set to the value applied when the hash was stored in the event.

ParameterTypeRequiredDefault ValueDescription
bitsintegeroptional[a] 256 Hash algorithm output bits to keep. Must be a multiple of 8.
  Minimum8 
  Maximum512 
fieldstringoptional[a]   The name of the field to look for an exact match against. If not set then @rawstring is searched for a matching substring.
hashstringoptional[a] sha256 Hash algorithm to use for the match.
   Values
   sha256
   sha512
input[b]stringrequired   A constant value to hash and then apply as the search term.
saltstringrequired   The name of the secret salt to use.

[a] Optional parameters use their default value unless explicitly set.

[b] The parameter name input can be omitted.

Hide omitted argument names for this function

Show omitted argument names for this function

hashMatch() Syntax Examples

Filter events to only match those that have the value in the ssn field equal to the hash of 12345678

logscale
ssn =~ hashMatch("12345678", salt="salt1")

Filter events to only match those that have the value of the hash of 12345678 somewhere in @rawstring

logscale
hashMatch("12345678", salt="salt1")

hashMatch() Examples

Click + next to an example below to get the full details.

Match Events Containing Specific Hash Values

Match events containing a specific hashed value using the hashMatch() function

Query
logscale
hashMatch("12345678", salt="salt1")
Introduction

In this example, the hashMatch() function is used to find events where the value 12345678 appears in the event data as a hash created with the salt equal to salt1.

Example incoming data might look like this:

@timestamp@rawstring
2025-09-01T10:00:00ZUser logged in with hash:a1b2c3d4e5f6g7h8i9
2025-09-01T10:00:05ZFailed login attempt hash:f6e5d4c3b2a1
2025-09-01T10:00:10ZPassword reset requested hash:h9i8g7f6e5d4
Step-by-Step
  1. Starting with the source repository events.

  2. logscale
    hashMatch("12345678", salt="salt1")

    Filters events by checking if the hash of value 12345678 (created using the salt salt1) appears anywhere in the @rawstring field. The function creates the hash using the provided value and salt, then searches for this hash pattern in the event data.

  3. Event Result set.

Summary and Results

The query is used to filter events that contain a specific hashed value in their content.

This query is useful, for example, to search for specific sensitive values in logs where the values have been hashed for security purposes, such as finding events related to a specific user ID or account number that has been hashed in the logs.

Sample output from the incoming example data:

@timestamp@rawstring
2025-09-01T10:00:00ZUser logged in with hash:a1b2c3d4e5f6g7h8i9

Note that the salt value must match the one used when the original hash was created in the data. The function searches for the hash pattern anywhere in the event data.

This example shows how to search for hashed values anywhere in event data. For searching in specific fields, see Match Hashed Values in Specific Fields. To understand how to create searchable hashed data, see Hash Field Values Using hashRewrite() .

Match Hashed Values in Specific Fields

Match events where a field equals a hashed value using the hashMatch() function

Query
logscale
ssn =~ hashMatch("12345678", salt="salt1")
Introduction

In this example, the hashMatch() function is used to filter events where the ssn field matches the hash of a specific value, using a specified salt value for the hashing. A salt is a random string added to the data before hashing to make the hash more secure.

Note that the example uses the hashMatch() function with the comparison operator =~ to match against a specific field.

Example incoming data might look like this:

@timestampssnnameaction
2025-08-06T10:00:00Za1b2c3d4e5f6g7h8i9John Doelogin
2025-08-06T10:01:00Zj1k2l3m4n5o6p7q8r9Jane Smithlogout
2025-08-06T10:02:00Zx1y2z3a4b5c6d7e8f9Bob Wilsonlogin
2025-08-06T10:03:00Za1b2c3d4e5f6g7h8i9John Doeupdate
2025-08-06T10:04:00Zm1n2o3p4q5r6s7t8u9Alice Brownlogin
Step-by-Step
  1. Starting with the source repository events.

  2. logscale
    ssn =~ hashMatch("12345678", salt="salt1")

    Filters events where the ssn field value matches the hash of 12345678. The hashMatch() function creates a hash using the specified string and salt value (salt1), then compares it against the value in the ssn field.

    The salt parameter is required and should match the salt used when the original data was hashed.

  3. Event Result set.

Summary and Results

The query is used to find events where a hashed field matches an expected value without exposing the original sensitive data.

This query is useful, for example, to track specific user activities in logs where sensitive information like social security numbers are stored in hashed form for security compliance.

Sample output from the incoming example data:

@timestampssnnameaction
2025-08-06T10:00:00Za1b2c3d4e5f6g7h8i9John Doelogin
2025-08-06T10:03:00Za1b2c3d4e5f6g7h8i9John Doeupdate

Only events where the hashed value in ssn matches the hash of 12345678 are included in the results.

This example demonstrates searching for specific hashed values in a named field. For searching hashed values anywhere in event data, see Match Events Containing Specific Hash Values. To learn how to create hashed values that can be searched this way, see Hash Field Values Using hashRewrite() .