Skip to main content

Veeam API with Python as PowerBi Data Source

 

Veeam API  with Python as PowerBi Data Source

Power BI is a powerful business intelligence tool that allows users to visualize data and gain insights from it. While Power BI provides built-in data connectors to various sources, including SQL Server, Oracle, Excel, and others, it also supports using custom connectors to access data from various other sources.


Python is a popular programming language that is widely used in data analysis and machine learning. With the help of Python, you can connect to various data sources, clean and preprocess data, perform statistical analysis, and create visualizations.

By using Python as a data source for Power BI, you can leverage the powerful data manipulation and analysis capabilities of Python within Power BI's intuitive and user-friendly interface. In this blog post, we will explore how to use Python as a data source for Power BI, including connecting to Python scripts, transforming data from Veeam.

When it comes to using Python as a source for Power BI, pandas is an essential tool that can help , pandas can be used to read data from various file formats such as CSV, Excel, and JSON, and to connect to various databases such as MySQL, PostgreSQL, and SQL Server. Pandas provides a simple and efficient way to read, manipulate, and transform data in Python, making it an essential tool when working with data that will be passed to Power BI.

Pandas is then a Pre-requisite.

Let’s start:

I want to get all the latest backup sessions & their state from all backup servers , so I will use API to Veeam Enterprise Manager , I will call this API in Veeam RESTful API and transform it into a Pandas DataFrame.

In this Python code, the requests library is used to send HTTP requests to the Veeam enterprise Manager server, and the base64 library is used to encode the user credentials for authentication. The Pandas library is used to create an empty DataFrame with the required columns and to concatenate the retrieved data into the DataFrame.

The code starts by disabling SSL certificate validation warnings and setting the user credentials for authentication. The session key is obtained by sending a POST request to the sessionMngr API endpoint with the user credentials. The session key is then used in the headers for subsequent requests.

The URL is set to the BackupTaskSession API endpoint, and a GET request is sent to the URL with the session key in the headers. The XML response is parsed using the ElementTree library, and the data is retrieved using the iter() method. The retrieved data is then transformed and appended to the DataFrame.

Finally, the DataFrame is printed to the console. Which is then Imported into PowerBi as Data Source.

In PowerBi add a new Data Source , Search for Python As below :

We add the Python Code into PowerBi Source wizard.

Code can be found here :

Script will Run and Fetch the Data


You will then be presented with the Table from Panda Data Frame :


Here you can then Transform the Data to tables & reports.

The API in the script can be adapted to Veeam Backup & Replication , Veeam One , Veeam Backup for Office 365 and others….

Data Source allows to refresh so can automatically on schedule run the Python script and fetch the latest data to update tables & reports on dashboards.

Share your thoughts , comments.

Thanks for reading.

 

 

Comments