How to write an Evobeat collector

Collecting data from systems using Python code is a great way to gather metrics. It provides flexibility to obtain information that is not always available in vendor management tools, and you can run the scripts against the entire infrastructure.

But how do you manage and present the data?

We often use the Elastic stack for this purpose, so we have written a Python framework to assist – Evobeat.

Say, for example, you want to collect some metrics from Arista switches. Start by cloning the Evobeat repo.

You will need to create a Python file in collectors/ and a YAML file in configs/.

Copy collectors/test_collector.py and configs/test_collector.yaml to new files.

You may have code already to connect to Arista switches, like below.

Evo1.PNG

This can be easily re-factored as a function called collect_data(config_data), as required by Evobeat.

Edit the YAML config file, changing parameters to suit your environment. The collector parameters can be any names you like as needed by you collector code, as long as they don’t overlap with mandatory and optional names.

Evo2.PNG

Then run the collector in test mode to verify your code, connection to elastic and devices.

Evo3.PNG

When debugged and tested, use run mode to collect data continuously every interval.

There are examples for Arista and Cisco ACI in the repo, together with a general network collector and more detailed “how to” guide.

As this is an open-source project, please submit a pull request if you would like to share a collector.