-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Description
Hello - I'm parsing a log that has a HEX representation of an ASCII string somewhere in the line. For instance: thing=313241414242
, which decoded results in thing=12AABB
. I'd like to parse this string and report the decoded ASCII string back to prometheus as a label.
The grok configuration looks something like this:
- type: counter
name: thing_counter
help: Test thing counter
match: 'thing=(?<thing_hex>[0-9A-F]+)'
retention: 5m
path: 'thing.log'
labels:
host: 'thing_host'
thing: "{{- printf \"%s\" (hex.DecodeString .thing_hex) -}}"
I'm trying to use the DecodeString function from the hex package. However, when I try to start grok_exporter, it complains that:
Failed to load ...: invalid configuration: failed to read metric label thing_counter: error parsing thing template: template: thing:1: function "hex" not defined: don't forget to put a . (dot) in front of grok fields, otherwise it will be interpreted as a function.
I'm not skilled in go, nor its templating engine, but I learned I have to use FuncMap to pass the names of the functions that I need to the template. Any suggestions on how I can use FuncMap from within grok_exporter to be able to access hex.DecodeString?
Thanks
Metadata
Metadata
Assignees
Labels
No labels