Skip to content
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 static label in metrics #36

Closed
ahmedaall opened this issue Aug 28, 2023 · 6 comments
Closed

Add static label in metrics #36

ahmedaall opened this issue Aug 28, 2023 · 6 comments

Comments

@ahmedaall
Copy link

Hi @thenodon :

Describe the bug
Is it possible to add static label in a class query :

BEFORE
aci_node_system_psu_status{aci="MY_FABRIC",fabric="MY_FABRIC",node_id="2",pod_id="1",psu_slot_id="6"} 1

AFTER
aci_node_system_psu_status{aci="MY_FABRIC",fabric="MY_FABRIC",node_id="2",pod_id="1",psu_slot_id="6" sensor_name="PDU"} 1

By static I mean that this label doesn't correspond any class attribut. It is like a custom label that is added to the config

@thenodon
Copy link
Member

@ahmedaall Just add staticlabels to the class query, for example:

class_queries:
  interface_info:
    class_name: l1PhysIf
    query_parameter: "?rsp-subtree=children&rsp-subtree-include=stats&rsp-subtree-class=ethpmPhysIf,eqptIngrBytes5min,eqptEgrBytes5min,eqptIngrDropPkts5min,eqptEgrDropPkts5min&query-target-filter=and(ne( l1PhysIf.adminSt, \"down\"))"
    metrics:
      - name: interface_oper_speed
        value_name: l1PhysIf.children.[ethpmPhysIf].attributes.operSpeed
        type: gauge
        help: The current operational speed of the interface, in bits per second.
        value_transform:
          'unknown': 0
          '100M': 100000000
          '1G': 1000000000
          '10G': 10000000000
          '25G': 25000000000
          '40G': 40000000000
          '100G': 100000000000
          '400G': 400000000000
    labels:
      #- property_name: l1PhysIf.attributes.id
      #  regex: "^(?P<id>.*)"
      - property_name: l1PhysIf.attributes.dn
        regex: "^topology/pod-(?P<podid>[1-9][0-9]*)/node-(?P<nodeid>[1-9][0-9].*)/sys/phys-\\[(?P<port>.+)\\]"
    staticlabels:
      - key: mystaticlabel
        value: mystaticvalue

@ahmedaall
Copy link
Author

@thenodon It works perfectly ! thank you

@thenodon
Copy link
Member

Great to hear.

@camrossi
Copy link
Contributor

I was looking for exactly this! Could we add it to the readme? :)

@thenodon
Copy link
Member

@camrossi yes we should. I will reopen this ticket so its added in next release.

@thenodon thenodon reopened this Nov 10, 2023
thenodon added a commit that referenced this issue Dec 2, 2023
@thenodon
Copy link
Member

thenodon commented Dec 9, 2023

This is fixed in commit a49070a branch issue_42 with an update to readme

@thenodon thenodon closed this as completed Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants