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

inputs.cisco_telemetry_gnmi and wildcard in path - measurement name always empty #5983

Closed
door7302 opened this issue Jun 12, 2019 · 4 comments · Fixed by #5986
Closed

inputs.cisco_telemetry_gnmi and wildcard in path - measurement name always empty #5983

door7302 opened this issue Jun 12, 2019 · 4 comments · Fixed by #5986
Labels
bug unexpected problem or unintended behavior
Milestone

Comments

@door7302
Copy link
Contributor

door7302 commented Jun 12, 2019

Relevant telegraf.conf:

# Send telegraf metrics to file(s)
[[outputs.file]]
  ## Files to write to, "stdout" is a specially handled file.
  files = ["/tmp/metrics.out"]
  data_format = "influx"


<!-- [Place config betweetn triple backticks '```'] -->
[[inputs.cisco_telemetry_gnmi]]
  ## Address and port of the GNMI GRPC server
  addresses = ["xxxx:57400"]

  ## define credentials
  username = "auto"
  password = "T3l3M!%eT5y!"

  ## GNMI encoding requested (one of: "proto", "json", "json_ietf")
  encoding = "json"

  ## redial in case of failures after
  redial = "10s"

  [[inputs.cisco_telemetry_gnmi.subscription]]
    ## Name of the measurement that will be emitted
    name = "trafficstats"

    #origin = "openconfig-interfaces"
    path = "/state/port[port-id=*]/ethernet/statistics"

    # Subscription mode (one of: "target_defined", "sample", "on_change") and interval
    subscription_mode = "sample"
    sample_interval = "30s"

    ## Suppress redundant transmissions when measured values are unchanged
    # suppress_redundant = false

    ## If suppression is enabled, send updates at least every X seconds anyway
    # heartbeat_interval = "60s"

System info:

Steps to reproduce:

I tried to use the inputs.cisco_telemetry_gnmi to collect telemetry data on Nokia SROS gNMI compliant router. But on Nokia we need to provide for some paths wildcard key for some elem :

"/state/port[port-id=*]/ethernet/statistics"

and therefore the measurement name is always empty because in line 346 :

   	if _, exists := c.aliases[name]; exists {
   		aliasPath = name
   	}

name is never match /state/port[port-id=*]/ethernet/statistics because here name is just an instance for each port and finally aliasPath is empty and measurement name is empty which triggers issue when output encoding is influx.

if might be interesting in line 113:

		if len(name) > 0 {
>>> here remove the key filter information from the provided path. 
>>> here path = "/state/port[port-id=*]/ethernet/statistics"
>>> before provisioning c.aliases remove all key filter from the path : 
>>> fix path to become : "/state/port/ethernet/statistics"
			c.aliases[path] = name
                 }

Expected behavior:

Actual behavior:

Additional info:

@door7302
Copy link
Contributor Author

FYI.

I use this current workaround to solve my issue.
from line 113 :

            if len(name) > 0 {
                        // remove key filtering within the path
                        reg := regexp.MustCompile(`(?s)\[(.*)\]`)
                        fixed_path := reg.ReplaceAllString(path , "")
                        c.aliases[fixed_path] = name
                }

Now I sent influx metrics with the right measurement name:

trafficstats,host=MUZTC840,path=/state/port/ethernet/statistics/ethernet-like-medium,port_id=2/1/1,source=nmtln201 ethernet_like_medium/frame_too_long="0" 1560361761044568011
trafficstats,host=MUZTC840,path=/state/port/ethernet/statistics,port_id=2/1/1,source=nmtln201 in_broadcast_packets="0",in_multicast_packets="3774122",in_unicast_packets="135359784262",in_errors=0,in_octets="62615102651306",in_utilization=139,out_broadcast_packets="3",out_multicast_packets="5762151",out_unicast_packets="253178822291",out_errors=0,out_octets="236156684371291",out_utilization=799,collisions="0",crc_align_errors="0",drop_events="0",fragments="0",jabbers="0",oversize_packets="0",undersize_packets="0",total_broadcast_packets="3",total_multicast_packets="9536273",total_octets="298771787022597",total_packets="388548142829" 1560361761044340113

@danielnelson danielnelson added the bug unexpected problem or unintended behavior label Jun 12, 2019
@danielnelson danielnelson added this to the 1.11.1 milestone Jun 12, 2019
@sbyx
Copy link
Contributor

sbyx commented Jun 13, 2019

You are correct I will provide patch in the coming days.
You should be able to define a custom alias for now as a workaround without needing to change the code. E.g. insert this below the line redial = "10s"

[inputs.cisco_telemetry_gnmi.aliases]
    trafficstats = "/state/port/ethernet/statistics"

@door7302
Copy link
Contributor Author

Thank you. I will test it. Otherwise, currently all is working fine with Nokia SROS.

@TechDawg
Copy link

TechDawg commented Nov 20, 2019

This is the only information I can find regarding telegraf in conjuntion with SROS & it was the answer I needed "path = "/state/port[port-id=*]/ethernet/statistics"", thanks! . Would be great if anyone has additional information to share.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants