Git Product home page Git Product logo

Comments (13)

thenodon avatar thenodon commented on June 27, 2024 1

With the above commit it's now possible to use named regex groups like this:

value_regex_transformation: "(?P<days>[0-9].*):(?P<hours>[[0-2][0-9]):(?P<minutes>[[0-6][0-9]):(?P<seconds>[[0-6][0-9])\\..*"
value_calculation: "days * 86400 + hours * 3600 + minutes * 60 + seconds"

from aci-exporter.

thenodon avatar thenodon commented on June 27, 2024 1

@JDA88 just so you know with latest commit on this branch golang is updated to 1.20

from aci-exporter.

thenodon avatar thenodon commented on June 27, 2024

Can you send me the complete configuration for the query including the config query type you are doing. The time format looks really strange 210:20:16:20.000. What are the different values?

from aci-exporter.

JDA88 avatar JDA88 commented on June 27, 2024

Configuration look like this (ignore the wrong naming it was a dirty test):

    queries:
      - node_health:
        class_name: topSystem
        query_parameter: "?rsp-subtree-include=health"
        metrics:
          -
            value_name: [email protected]
            value_calculation: "value / 100"
        labels:
          - property_name: topSystem.attributes.dn
            regex: "^topology/pod-(?P<podid>[1-9][0-9]*)/node-(?P<nodeid>[1-9][0-9]*)/sys"
          - property_name: topSystem.attributes.state
            regex: "^(?P<state>.*)"
          - property_name: topSystem.attributes.oobMgmtAddr
            regex: "^(?P<oobMgmtAddr>.*)"
          - property_name: topSystem.attributes.name
            regex: "^(?P<name>.*)"
          - property_name: topSystem.attributes.role
            regex: "^(?P<role>.*)"
          - property_name: topSystem.attributes.systemUpTime 
            regex: "^(?P<uptime>.*)"   

uptime goes to a label because the value is incompatible with a value.
The Cisco API documentation have example with this value: https://www.cisco.com/c/en/us/td/docs/switches/datacenter/aci/apic/sw/1-x/api/rest/b_APIC_RESTful_API_User_Guide/additional_examples.html

You also have a description in the Nexus documentation: https://pubhub.devnetcloud.com/media/dme-docs-9-3-5/docs/System/top:System/

systemUpTime scalar:Time The time (in seconds) since the system was booted. TIME FORMAT: %H:%M:%S 54:05:07:26.000

So the format is probably D:H:M:S in ACI...

from aci-exporter.

thenodon avatar thenodon commented on June 27, 2024

@JDA88 thanks for the feedback. That was a horrible time format, why not just use seconds. Maybe a feature request to Cisco. Do you know if this time format is used only in this object or if its a common time "type" in ACI universe?

from aci-exporter.

JDA88 avatar JDA88 commented on June 27, 2024

I kind of agree with the format been horrible for an API. They should at least expose it in both formats.

The scalar:Time is used by Cisco in different places (searching for it in google return some match like frequency for jobs etc.) but I have no idea if there is other useful scenario for the ACI exporter.
It's not that difficult to parse and convert to seconds, but I can’t do it at the prometheus level, it must be done at the exporter level.
You mention a feature request to Cisco? Do you have any idea of how to do this?

from aci-exporter.

thenodon avatar thenodon commented on June 27, 2024

@JDA88 I think its easier to fix it in the exporter than to ask for a change request from ACI. I also think this is functionality can be valuable for other use cases. I did not want to create some new specific transformation for this specific format, but instead build on the functionality that already exists related to value_regex_transformation and value_calculation. So instead of limit the functionality to a single value we can now have a configuration like this:

class_queries:
  issue22:
    class_name: topSystem
    query_parameter: "?rsp-subtree-include=health"
    metrics:
      - name: uptime
        #value_name: [email protected]
        value_name: topSystem.attributes.systemUpTime
        value_regex_transformation: "([0-9].*):([0-2][0-9]):([0-6][0-9]):([0-6][0-9])\\..*"
        value_calculation: "value1 * 86400 + value2 * 3600 + value3 * 60 + value4"
    labels:
      - property_name: topSystem.attributes.dn
        regex: "^topology/pod-(?P<podid>[1-9][0-9]*)/node-(?P<nodeid>[1-9][0-9]*)/sys"
      - property_name: topSystem.attributes.state
        regex: "^(?P<state>.*)"
      - property_name: topSystem.attributes.oobMgmtAddr
        regex: "^(?P<oobMgmtAddr>.*)"
      - property_name: topSystem.attributes.name
        regex: "^(?P<name>.*)"
      - property_name: topSystem.attributes.role
        regex: "^(?P<role>.*)"
      - property_name: topSystem.attributes.systemUpTime
        regex: "^(?P<uptime>.*)"

In the value_regex_transformation we have a regex that extract 4 values and in the value_calculation the values can be referenced as value1 to value4. The index will be according to the order they are matched in the regex.
If we just have one value, the existing way of reference the value using just value in the value_calculation will still work.
If there are errors in the regex or in the value_calculation, lets say try to reference value34 and it does not exist the aci-exporter will log that with information so its easy to find in the configuration file.
So with the above we now get the output:

curl -s 'http://localhost:9643/probe?target=cisco_sandbox&queries=issue22'
# HELP issue22 
# TYPE issue22 
aci_issue22{aci="ACI Fabric1",fabric="cisco_sandbox",name="leaf-1",nodeid="101",oobMgmtAddr="192.168.100.101",podid="1",role="leaf",state="in-service",uptime="07:19:59:33.000"} 676773
aci_issue22{aci="ACI Fabric1",fabric="cisco_sandbox",name="leaf-2",nodeid="102",oobMgmtAddr="192.168.100.102",podid="1",role="leaf",state="in-service",uptime="07:19:59:33.000"} 676773
aci_issue22{aci="ACI Fabric1",fabric="cisco_sandbox",name="spine-1",nodeid="201",oobMgmtAddr="192.0.2.5",podid="1",role="spine",state="in-service",uptime="07:19:59:33.000"} 676773
aci_issue22{aci="ACI Fabric1",fabric="cisco_sandbox",name="apic1",nodeid="1",oobMgmtAddr="192.168.100.10",podid="1",role="controller",state="in-service",uptime="07:19:59:35.000"} 676775
# HELP scrape_duration_seconds The duration, in seconds, of the last scrape of the fabric
# TYPE scrape_duration_seconds gauge
aci_scrape_duration_seconds{aci="ACI Fabric1",fabric="cisco_sandbox"} 3.109194926

from aci-exporter.

thenodon avatar thenodon commented on June 27, 2024

@JDA88 you can test the branch issue_22 to test the new feature. Please read the README.md and give feedback if anything is unclear.

from aci-exporter.

JDA88 avatar JDA88 commented on June 27, 2024

Thank you very much for this. I'll let you know when we get the opportunity to test this!

from aci-exporter.

thenodon avatar thenodon commented on June 27, 2024

@JDA88 would really like your feedback from your test on this before merging :)

from aci-exporter.

JDA88 avatar JDA88 commented on June 27, 2024

would really like your feedback from your test on this before merging :)

I'll do my best but our team are very busy this week and we won't probably be able to test before at the very least next week

from aci-exporter.

thenodon avatar thenodon commented on June 27, 2024

@JDA88 I understand. I think I merge with master and continue on the other issues you made. Can create a beta for testing instead.

from aci-exporter.

thenodon avatar thenodon commented on June 27, 2024

Merged in #27

from aci-exporter.

Related Issues (20)

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.