b64dec
(logql template function) should automatically account for missing padding
#15547
Labels
b64dec
(logql template function) should automatically account for missing padding
#15547
Is your feature request related to a problem? Please describe.
While querying loki logs, I'd like to decode the jwt tokens written in my logs.
In my case, the base64 encoded payload of the jwt tokens do not have their padding.
This gives a
illegal base64 data at input byte ..
when trying to base64-decode withb64dec
.Describe the solution you'd like
The
b64dec
template function would be more useful if it automatically accounts for missing padding in the base64 encoded string.Describe alternatives you've considered
I could add missing padding myself as part of the logql query like this:
But it's preferable to not have to add missing padding ourselves.
Additional context
Formula for automatically adding missing padding while decoding a base64-encoded string
s
:b64decode(s + b'=' * (-len(s) % 4))
I am willing to submit a PR that overrides
b64dec
functionality in https://github.com/grafana/loki/blob/main/pkg/logql/log/fmt.go, if it is agreed to move forward in this direction!The text was updated successfully, but these errors were encountered: