aristanetworks / goarista

Fairly general building blocks used in Arista Go code and open-sourced for the benefit of all.
Apache License 2.0
206 stars 66 forks source link

ocprometheus fails with duplicated metrics with EOS 4.27 #67

Open freedge opened 2 years ago

freedge commented 2 years ago

Using latest goarista from master branch, EOS 4.27.4M, and a configuration like this:

metrics:

        - name: ocprometheus_bgp_peer_as_number  #No unit
          path: /Sysdb/routing/bgp/export/vrfBgpPeerInfoStatusEntryTable/(?P<vrf>.+)/bgpPeerInfoStatusEntry/(?P<name>.+)/bgpPeerAs
          help: BGP Peer  AS Number

ocprometheus fails with errors like this:

* collected metric "ocprometheus_bgp_peer_as_number" { label:<name:"name" value:"192.168.247.17" > label:<name:"vrf" value:"default" > gauge:<value:0 > } was collected before with the same name and label values

This used to work so far with EOS <= 4.26.6M :

ocprometheus_bgp_peer_as_number{name="10.64.226.33/bgpPeerSessionStatus",vrf="default"} 1234
ocprometheus_bgp_peer_as_number{name="10.64.226.35/bgpPeerSessionStatus",vrf="default"} 1234
ocprometheus_bgp_peer_as_number{name="192.168.247.19/bgpPeerSessionStatus",vrf="default"} 64850
ocprometheus_bgp_peer_as_number{name="192.168.248.19/bgpPeerSessionStatus",vrf="default"} 64850

It looks like the name "(?P.+)" used to match "10.64.226.33/bgpPeerSessionStatus", but now it only constructs a label with the first part before the first "/"

freedge commented 2 years ago

workaround for my use case is to replace

path: /Sysdb/routing/bgp/export/vrfBgpPeerInfoStatusEntryTable/(?P<vrf>.+)/bgpPeerInfoStatusEntry/(?P<name>.+)/bgpPeerAs

with

path: /Sysdb/routing/bgp/export/vrfBgpPeerInfoStatusEntryTable/(?P<vrf>.+)/bgpPeerInfoStatusEntry/(?P<name>.+)/bgpPeerSessionStatus/bgpPeerAs

so a single bgpPeerAs is found and there is no path included in "name".