-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mutations such as mutiplication/division to allow exposing metrics in the proper units #3129
Comments
There's another issue somewhere for this. I prefer to add slowly what we need instead of using sprig, this is mostly because it is run on server side. |
@cyriltovena thanks for your response ! I suppose you are talking about: which are technically related, but they are more about LogQL than the metrics extraction. |
This issue has been automatically marked as stale because it has not had any activity in the past 30 days. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. |
not stale |
@cyriltovena I believe this feature was implemented via merged PR #3434 ? |
only for LogQL so far. |
Fixes grafana#3129 Signed-off-by: Cyril Tovena <[email protected]>
* Add sprig text/template function to template stage. Fixes #3129 Signed-off-by: Cyril Tovena <[email protected]> * nit. Signed-off-by: Cyril Tovena <[email protected]> * reset vendor file. Signed-off-by: Cyril Tovena <[email protected]>
Is your feature request related to a problem? Please describe.
Some logs contain valuable metric data Promtail is able aggregate and expose as Prometheus metrics already.
Unfortunately the data is not always in the proper format / unit to follow the best-practices and to use the Prometheus recommended base-units (https://prometheus.io/docs/practices/naming/#base-units).
So a field extracted from a log could contain milliseconds instead of seconds or bits insteads of bytes.
Describe the solution you'd like
It would be great to have a few mutations such as multiplication or / division available which can be applied to fields.
Potentially this would could be covered by the
template
(https://grafana.com/docs/loki/latest/clients/promtail/stages/template/#supported-functions) feature and go-template. But unfortunately there are not arithmetic functions allowed / implemented (yet):invalid template stage config: template: pipeline_template:1: function \"div\" not defined"
To not have to maintain a homegrown list of functions the Sprig library (http://masterminds.github.io/sprig/) could be added enabling more than enough magic to mutate things as required - i.e. use their
divf
onms
to becomeseconds
.Describe alternatives you've considered
This functionality cannot be covered by string manipulations such as the already available regex or the existing go template magic.
Additional context
The text was updated successfully, but these errors were encountered: