I'm using a log aggregation setup where sensitive data that is prepared for submission to loki is obfuscated with Promtail's Hash filter under consideration of a salt value.
I want to dispatch a query with Grafana to look for a specific value that would have been transformed in that way. Therefore I have to calculate what Promtail would derive from that value.
I assume I could reproduce the result on a current Ubuntu Desktop OS like this:
$ echo "Value of interest" | shasum -a 256 -
But how would I have to bring the salt value into the equation?
As can be seen here functions
HashandSha2Hashboth simply invoke hashing functions over simple concatenation of salt and input value:Note that the documentation proposes a configuration where value and salt are swapped, which must be considered if you followed it. Also, it must be ensured that no newline character is added when using
echo. Thus, using rhash in this example, the hash can be derived with:The "inner" consecutive quote characters only serve clarity, they could be omitted.