Comments (7)
Thanks for the feedback and glad that it worked. Will fix the go.sum.
If you like to share your experience with aci-exporter, you can email me on [email protected]
from aci-exporter.
Hi @minefuto,
Can you provide the aci config, so I can se the query you are running.
When it comes to recalculate the value there is currently options as value_transform and value_calculation.
A value transform some string value to a float.
value_transform:
'unknown': 0
'down': 1
'up': 2
'link-up': 3
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.
value_calculation: "value / 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.
from aci-exporter.
Thanks @thenodon,
I think Knetic/govaluate only supported to transform from string
to Time
type.
Not supported from string
to unixtime(float
).
I want to detect link flap of ACI.
config.yaml
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 lastLinkStChg
cannot scraped because it is string
such as 2020-04-18T05:24:07.722+00:00
.
So aci-exporter should get lastLinkStChg
as a unixtime(float
).
example:
minefuto@0691f56
from aci-exporter.
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.
We could implement a govaluate function like date_to_unixtime(.....) and in your aci config have
class_queries:
interface_info:
class_name: interface_info
metrics:
- name: lastLinkStChg
value_name: ethpmPhysIf.attributes.lastLinkStChg
type: gauge
value_calculation: "date_to_unixtime(value, "rfc_3339")
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>[^\\]]+)\\]/"
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.
This is just my thought and I have not done any testing. Would be great to know if there are a general request for this functionality.
from aci-exporter.
Thanks, I understand your idea.
It looks like a good.
from aci-exporter.
@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.
Use the config like:
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>[^\\]]+)\\]/"
from aci-exporter.
I confirmed it solves this issue.
By the way, I found a problem in branch issue_12 that fails to go build
.
I think It should be updated go.sum
.
~/aci-exporter
❯ go version
go version go1.17.2 darwin/amd64
~/aci-exporter
❯ git switch issue_12
Branch 'issue_12' set up to track remote branch 'issue_12' from 'origin'.
Switched to a new branch 'issue_12'
~/aci-exporter
❯ go build
go: github.com/tidwall/[email protected]: missing go.sum entry; to add it:
go mod download github.com/tidwall/gjson
go: github.com/tidwall/[email protected]: missing go.sum entry; to add it:
go mod download github.com/tidwall/gjson
from aci-exporter.
Related Issues (16)
- Add load balancing between available apic's HOT 65
- ACI 5.2: Update login/logout API endpoints HOT 2
- Regex in value_transform HOT 10
- The prefix is not reflected in the # HELP and # TYPE lines HOT 2
- A way to convert the systemUpTime to seconds HOT 13
- Add a aci_up metric HOT 1
- It is possible to generate a metric file with empty # HELP and / or # TYPE lines HOT 2
- Labels should alway be lowercase HOT 5
- Implement concurrent requests call to the apic HOT 1
- value transformation do not work HOT 3
- static_binding_info: value_regex_transformation not working HOT 3
- label regex not executed on child class HOT 4
- Add static labels
- Exclude/include queries by fabric configuration
- Issue with query including an array of children HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aci-exporter.