-
Notifications
You must be signed in to change notification settings - Fork 19
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
Scrape timestamp metrics as value #12
Comments
Hi @minefuto,
A value_calculation can make some simple calculations of the value. This example divide the value (value-string is a placeholder for the value) with 100. aci-exporter use https://github.com/Knetic/govaluate to execute the expression like "value / 100". In govaluate it is possible to create addtional "functions" that can be called, see https://github.com/Knetic/govaluate#functions. So it might be possible to create some additional functions for your use case. |
Thanks @thenodon, I want to detect link flap of ACI. class_queries:
interface_info:
class_name: interface_info
metrics:
- name: lastLinkStChg
value_name: ethpmPhysIf.attributes.lastLinkStChg
type: gauge
labels:
- property_name: ethpmPhysIf.attributes.dn
regex: "^topology/pod-(?P<podid>[1-9][0-9]*)/node-(?P<nodeid>[1-9][0-9]*)/sys/phys-\\[(?P<interface>[^\\]]+)\\]/" prometheus-rules.yml groups:
- name: alert
rules:
- alert: "interface flap"
expr: changes(aci_lastLinkStChg[5m]) > 0
for: 1m But example: |
I understand your use case and it make sense to understand flapping. I still think it could be done with https://github.com/Knetic/govaluate#functions.
The functions needs to be part of the parsing so a refactor of func valueReCalculation(...) needs to be done. I would be preferable that the govaluate function could be "loaded" at start up (reflection) to support custom function in additions to standard functions provided by aci-exporter. |
Thanks, I understand your idea. |
… to a timestamp. This is done in the aci-api toFloat function. Additional automated conversations could be added. The following config can be used to test: class_queries: interface_lastlink_st_chg_to_date: class_name: ethpmPhysIf metrics: - name: lastLinkStChg value_name: ethpmPhysIf.attributes.lastLinkStChg type: counter labels: # The field in the json used to parse the labels from - property_name: ethpmPhysIf.attributes.dn # The regex where the string enclosed in the P<xyz> is the label name regex: "^topology/pod-(?P<podid>[1-9][0-9]*)/node-(?P<nodeid>[1-9][0-9]*)/sys/phys-\\[(?P<interface>[^\\]]+)\\]/"
@minefuto please checkout branch issue_12 and test the fix. aci-export will now automatically convert date in rfc3339 format to a float. Hopefully all dates are in that format.
|
I confirmed it solves this issue. By the way, I found a problem in branch issue_12 that fails to
|
Thanks for the feedback and glad that it worked. Will fix the go.sum. |
* [Issue #12] When metrics values is a rfc3339 date, it will be convert to a timestamp. This is done in the aci-api toFloat function. Additional automated conversations could be added. The following config can be used to test: class_queries: interface_lastlink_st_chg_to_date: class_name: ethpmPhysIf metrics: - name: lastLinkStChg value_name: ethpmPhysIf.attributes.lastLinkStChg type: counter labels: # The field in the json used to parse the labels from - property_name: ethpmPhysIf.attributes.dn # The regex where the string enclosed in the P<xyz> is the label name regex: "^topology/pod-(?P<podid>[1-9][0-9]*)/node-(?P<nodeid>[1-9][0-9]*)/sys/phys-\\[(?P<interface>[^\\]]+)\\]/" * Update dependency of github.com/tidwall/gjson to v1.9.3 * Update dependency of github.com/tidwall/gjson to v1.9.3 * Update "Metrics transformations" for the rfc 3339 transformation
Is your feature request related to a problem? Please describe.
I want to scrape timestamp metrics as value(not label) from ACI such as modTs.
Describe the solution you'd like
I think aci-exporter need to translate from "2020-04-18T05:24:07.722+00:00" to unixtime.
Do you have any plans to add the above function?
Or is it already implemented?
The text was updated successfully, but these errors were encountered: