# Integrating CycleCloud Server Logs with Azure Log Analytics for Enhanced Monitoring on Azure Dashboard
# Introduction
In environments where direct access to the CycleCloud Server Portal is restricted, organizations need alternative methods to monitor and analyze server activity. This blog outlines a solution to transfer logs from CycleCloud Server to Log Analytics Workspace, enabling visualization on the Azure Portal Dashboard.
The VM core usage shown in upper-left corner of the CycleCloud Server Portal as below. We will export the data from from the CycleCloud Server logs and transferred to the Log Analytics Workspace for visualization.
# Prerequisites
Before implementing this solution, ensure you have the following:
- A Python environment (Python 3.12 is used in this example).
- Log Analytics Workspace ID and Shared Key to facilitate data transfer to Log Analytics Workspace. We can obtain these details from the Azure Portal.
# Implementations
- Verify CycleCloud Server Command
First, confirm that you can retrieve the necessary information from the CycleCloud Server using the appropriate commands. The output should look something like this:
1 | sudo /opt/cycle_server/cycle_server execute --format json 'select MachineType, count(*) as MachineCount, sum(CoreCount) as CoreCount from cloud.instancesession where ClusterName == "CLUSTERNAME" group by MachineType' |
Sample output data shown as below:
1 | [ { |
- Python Script to Transfer Logs
Next, write a Python script to send CycleCloud Server logs to Log Analytics Workspace. Save this script to /home/azureuser/vm_core_usage_to_law.py
in my case.
1 | import base64 |
- Schedule Python Script
Finally, schedule the Python script to run at regular intervals using the cron
job scheduler. For example, to run the script every 1 minutes, add the following line to the crontab
file:
1 | * * * * * python3 /home/azureuser/vm_core_usage_to_law.py |
- Visualize Data on Azure Portal
After the script has run successfully, you can visualize the data on the Azure Portal Dashboard. Navigate to the Log Analytics Workspace and select the appropriate table to view the data with following kusto query:
1 | YourTableName_CL |
Resulting in a chart like this:
we can pin this kusto query to the Azure Portal Dashboard for real-time monitoring.
# Conclusion
By integrating CycleCloud Server logs with Azure Log Analytics, organizations can monitor server activity and visualize data on the Azure Portal Dashboard. This solution provides a convenient method to track server performance and resource utilization in real-time.
Special thanks to
Azure CycleCloud Engineering Team
for providing the inspiration for this blog post.
# Reference
- Cost and Usage Tracking - Azure CycleCloud