#LabelAgent replace_regex question

1 messages · Page 1 of 1 (latest)

unique moon
#

Hi all 🙂
Previously Rahul help me to integrate the "^igroup.initiators" from the "api/protocols/san/lun-maps" endpoint in a custom "lun.yaml" :

query:                      api/storage/luns
object:                     lun

counters:
  - ^^uuid
  - ^location.node.name     => node
  - ^location.qtree.name    => qtree
  - ^location.volume.name   => volume
  - ^name                   => path
  - ^status.state           => state
  - ^svm.name               => svm
  - space.size              => size
  - space.used              => size_used

endpoints:
  - query: api/protocols/san/lun-maps
    counters:
      - ^^lun.uuid              => uuid
      - ^igroup.initiators      => initiators

plugins:
  - MetricAgent:
      compute_metric:
        - size_used_percent PERCENT size_used size
  - LabelAgent:
      value_to_num:
        - new_status state online online `0`
    # There are two flavors of path names
    # /vol/volName/lunName
    # /vol/volName/lun401/lunName
      split_regex:
        - path `^/[^/]+/([^/]+)(?:/.*?|)/([^/]+)$` volume,lun

export_options:
  instance_keys:
    - lun
    - node
    - qtree
    - svm
    - volume
  instance_labels:
    - state
    - initiators```
I'd like to manipulate the initaitors label with a regexp to cut the last 37 char.
I've try to add this :

plugins:

  • MetricAgent:
    compute_metric:
    - size_used_percent PERCENT size_used size
  • LabelAgent:
    value_to_num:
    - new_status state online online 0

    There are two flavors of path names

    /vol/volName/lunName

    /vol/volName/lun401/lunName

    split_regex:
    - path ^/[^/]+/([^/]+)(?:/.*?|)/([^/]+)$ volume,lun
    replace_regex:
    - initiators instance_name (.+).{37}$ $1
    ...
    instance_labels:
    • state
    • initiators
    • instance_name```
      But my new label is empty.
      Clearly I failed, but, if you could point me out where, I'll be greatfull 🙂
lime rover
#

See if below works

name:                       Lun
query:                      api/storage/luns
object:                     lun

counters:
  - ^^uuid
  - ^location.node.name     => node
  - ^location.qtree.name    => qtree
  - ^location.volume.name   => volume
  - ^name                   => path
  - ^status.state           => state
  - ^svm.name               => svm
  - space.size              => size
  - space.used              => size_used

endpoints:
  - query: api/protocols/san/lun-maps
    counters:
      - ^^lun.uuid              => uuid
      - ^igroup.initiators      => initiators

plugins:
  - MetricAgent:
      compute_metric:
        - size_used_percent PERCENT size_used size
  - LabelAgent:
      value_to_num:
        - new_status state online online `0`
      # There are two flavors of path names
      # /vol/volName/lunName
      # /vol/volName/lun401/lunName
      split_regex:
        - path `^/[^/]+/([^/]+)(?:/.*?|)/([^/]+)$` volume,lun
        - initiators `^(.*)(.{37})$` instance_name,

export_options:
  instance_keys:
    - lun
    - node
    - qtree
    - svm
    - volume
  instance_labels:
    - state
    - initiators
    - instance_name
unique moon
#

I've just try it, and sadly, the label is still empty

lime rover
#

Can you share a sample initiators name from your environment?

unique moon
#

Sure :
initiators="act-devel01-wrk-003-e22ccb53-2ceb-4e54-b3e2-fa3e79f80f76"

lime rover
#

Thanks. Seems to work fine for me as attached. Could you share the template that you are currently using?

unique moon
#

Ok, just repast your code and I missed one changed I've made on my side...
I use : - ^igroup.name => initiators
And the original caode was : - ^igroup.initiators => initiators

So you're right, it works perfectly, my bad.
Thanks again for your precious help !