How to setup your own Basic Telemetry Lab with Cisco XR


In this article, we will be talking about setting up a basic Lab for testing Telemetry on a Cisco NC55XX router. Telemetry – “Tele” means remote, “metry” means metrics or measurements, together this word simply means to collect data/measurements remotely on a server. Telemetry is usually a PUSH model meaning the client will push data towards the server which is listening on a certain port and later that data is sanitized for further usage. We are achieving Dial-out in this very post.

Requirements:

  1. XR Router {I am using NCS55XX platform with version 7.0.1 in this article}
  2. A machine acting as a server

Make sure the connectivity between the above two works fine. I have the connectivity between the two under management VRF.

Let’s start with router configuration to check this:

There are 3 must done configuration on Router.

  1. Defining Destination group
    This will keep the information about how to reach the IP address of your server and under which encoding it must be sent, be it JSON or GPB {Google Protobuffer}.
  2. Defining Sensor group
    The sensor group are the actual data that you want to send to the server. For different components in the device, many different sensor paths are defined, say for interface information, mpls information, syslog configurations, etc. These sensor paths are present in the device as Yang schemas and these are the information that are actually pushed to the server. So, we can define whatever information we want to send under this.
  3. Defining Subscription group
    Subscription binds the above two configs together, say I have several servers and I want each server to listen to different information, so I can create subscription for one or more sensor path under one or more destination group which will get the details of that particular sensor. We can also define interval time for each request to be sent.

Lab setup:

NCS55XX telemetry config:

telemetry model-driven
  destination-group <Des-group name>
   vrf <vrf-name>
   address-family ipv4 <your-server-ip> port <listening-port>
   encoding json
   protocol tcp
 !
!
 
  sensor-group <any-name>
sensor-path Cisco-IOS-XR-pfi-im-cmd-oper:interfaces/interface-summary
!

 subscription <any-name>
sensor-group-id <sensor-group-name-defined-above> strict-timer
sensor-group-id <sensor-group-name-defined-above> sample-interval 30000
destination-id <the-des-group-name-you-defined-above>
!

The above configs shall be enough to put you router in the Dial out mode and the router will start sending out the information once you commit the above configuration.

The Server:

To setup a basic listener I have used python script. A normal socket which listens to the request.

import socket
import json
import string
HOST = 'XX.XX.XX.XX' #use ip address of your server ethernet interface
PORT = 57100         #any listening port 
BUFFER_SIZE = 8000

def server_socket():
    BUF=[]
    buffer=''
    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.bind((HOST,PORT))
        s.listen()
        while 1: # Accept connections from multiple clients
            print('Listening for client...')
            conn, addr = s.accept()
            print('Connection address:', addr)
            while 1: # Accept multiple messages from each client
                buffer=conn.recv(4096).decode('utf-8')
                BUF.append(buffer)
                print(buffer)
                if ('collection_end_time' in buffer):
                    print("****END OF ONE REQUEST****")
                    a=input("Do you want to keep the connection alive: Y/N")
                    if(a=='Y'):
                        continue
                    else:
                        conn.close()
                        break
            if a!='Y':
                break

        tele_data=''.join(BUF)
        tele_data[1:]
        print(tele_data)
        
server_socket()

The above code will print the output:

Python server

You can also use netcat to listen to this data, you can embed that command in python script using os library and can make use of nc to listen on the port.

More links:

https://www.cisco.com/c/en/us/td/docs/iosxr/asr9000/telemetry/b-telemetry-cg-asr9000-61x/b-telemetry-cg-asr9000-61x_chapter_010.html#id_36445

https://www.cisco.com/c/en/us/td/docs/iosxr/ncs5500/telemetry/b-telemetry-cg-ncs5500-62x/b-telemetry-cg-ncs5500-62x_chapter_010.html#id_36203

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/prog/configuration/1610/b_1610_programmability_cg/model_driven_telemetry.html#id_86392