Git Product home page Git Product logo

Comments (7)

thenodon avatar thenodon commented on September 23, 2024 1

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.

thenodon avatar thenodon commented on September 23, 2024

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.

minefuto avatar minefuto commented on September 23, 2024

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.

thenodon avatar thenodon commented on September 23, 2024

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.

minefuto avatar minefuto commented on September 23, 2024

Thanks, I understand your idea.
It looks like a good.

from aci-exporter.

thenodon avatar thenodon commented on September 23, 2024

@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.

minefuto avatar minefuto commented on September 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.