Exploring Catalyst Devops with practical example – Part 2
In the previous part, we learned about Zoho DevOps components […]
Published on March 1, 2024
In the previous part, we learned about Zoho DevOps components and created a cool full-stack sample project. In this part, we will integrate the components in our project to show how it looks and the benefits we can get from the Catalyst DevOps components. So, without any delay, let’s get started!
Integration of DevOps components
Let’s begin by gradually incorporating monitoring components into our project, step by step.
Monitoring
Logging
It serves as the cornerstone of a robust application. Even if we’re not actively keeping an eye on logs in real time, it’s crucial to store them for future reference. In Catalyst, the logging component is incredibly user-friendly. Since our project is built on Node.js, it seamlessly aligns with the logging capabilities it offers.
For those well-versed in JavaScript, the ubiquitous console.log() statement is likely a familiar tool. All it takes is to integrate this into your code and the output becomes visible through the Catalyst console. To pinpoint where you can access these logs, refer to the following here.
There are two main types of logs: access logs and application logs.
Access: It gives information about the external information of execution. For example, if you hit the endpoint, it will log the HTTP details for execution.
Application: It gives information about the internal application state. For example, if you want to make sure a specific function was run, you will see these logs.
Now, let’s add both of these logs to our project. We have made the following changes to our post function.
app.post("/expenses", (req, res) => {
///...Previous code
console.log(
`Invalid data: description's length: ${description.length} and amount is ${amount}`
);
res.status(400).json({ error: "Invalid data" });
}
});
Now, let us deploy the function again and send a wrong request to our function.
In our Catalyst logs dashboard, we get the following log for the access level.
As for the application level, we have the following logs:
As we have discussed above.
Application Alerts
Application alerts can be set for logs, cron jobs, and event listeners. Since we have implemented logs for our application, let us add alerts to our app. For the demonstration, we will add a warning to our application alerts if the amount entered is too big by the user. You can replace it with any logic.
app.post("/expenses", (req, res) => {
const { description, amount } = req.body;
console.log(description);
if (amount > 1000000) {
console.warn("Amount is too large");
}
// Same code below
I will add 3 entries with a big amount that satisfies our condition after the function is deployed.
The warn logs start appearing on the console. Let us now create an alert for this on our dashboard.
After adding your email, an alert will be created for the specific rule and you shall be notified after every hour!
To see the options in detail, you can see the documentation here.
Application Performance Monitoring and Metrics
A complete dashboard will be provided by Catalyst DevOps for in-detail monitoring. You can enable it on the Catalyst console and it looks like this is for our function!
More insights.
You do not have to do anything programmatically, everything is done by Catalyst. All you have to do is to enable it. Learn more here.
Metrics also work similarly which gives you an overview of different resources that are being used by your project.
GitHub Integration
In this part, we will integrate Catalyst with Github. Once you open the DevOps console, you will see the Git tab on the left.
Click on Integrate GitHub and you will be redirected to GitHub for the authorization process.
Once you are authenticated with Git, you will be redirected back to the console and you will be able to see all your GitHub repositories there.
Let us initialize git in our catalyst project on our machine with the following command (Make sure you have git installed in your machine)
git init
Push everything to your remote repository; make sure that the repository is not private. You will see your repository in the console. Now click on Deploy.
Now that your GitHub account is linked, you can push the changes to the repository. To synchronize these updates with Catalyst, simply click on the “Sync” button.
This eliminates the need for deploying from the command line, allowing multiple team members to collaborate seamlessly through version control. Let’s put this to the test!
This is how our function looks from the console.
We will make the following changes and deploy it to Git Hub.
Now, by clicking “Sync” on the console, this modification will automatically manifest in our function, bypassing the need for the catalyst deploy command.
Automation Testing.
To kickstart automation testing, our initial step is to enable it.
This component allows us to create different test cases and put them in test suites as well. Let’s create our first test case for the function.
We will be prompted to this view.
Here, we will click on Add Request. This allows us to put the API endpoint to be tested. It can be our serverless functions or even 3rd party ones. Paste the URL of your endpoint and choose your HTTP method. A test case also requires assertions, which are the conditions against which the result is compared. Here’s how our request and assertion tabs are structured.
You can add multiple assertions as per your needs. Save the test case, and click on run. If the test case passes and everything goes well, you will get the following results.
With this, you have learned to create a test case. Now to the automation part, Catalyst provides you with test plans that are dead simple to set up. Test plans run on specified intervals as specified hence automation the testing workflow.
It operates in conjunction with test suites, requiring you to create one. This can be easily accomplished from the Test Suite tab.
Now that we have a test suite, we can create our test plan.
With this, you are fully set with the automation testing!
Conclusion
We saw how you can integrate all the components of catalyst DevOps in your project. Even though the examples are simple they will put you on the right track to avail full benefits of the platform!