One of the main features of Gatling Enterprise is access to Gatling’s API, but what exactly is Gatling’s API? What does it have the ability to do? What tools can it connect with?
In this post we’re going to be looking at all of the above and learning how you can use the API available in Gatling Enterprise Cloud to supercharge your load testing strategy.
Wait, what’s an API?
API stands for Application Programming Interface and If you’re reading an article on how to use an API, you probably already know what they are and what they’re used for but here’s a short example:
Imagine you’re in a restaurant and you want to order some food. You tell the waiter what you want, and then the waiter goes to the kitchen and tells the chef what you ordered. The chef then makes the food, and the waiter brings it back to your table.
In this scenario, the waiter is like an API. It acts as a middleman between you and the chef, translating your request into something that the chef can understand. In the same way, an API acts as a middleman between different software applications, translating requests from one application into something that another application can understand.
So what’s on the menu for Gatling’s API?
We’ve got a few specials ready to go. Our first course, how to create an API token! Sorry for the restaurant puns, this is what happens when I write blog posts before lunch.
Connect and run Gatling Enterprise Cloud
Personally, I love the Gatling Enterprise Cloud UI and interface. It’s intuitive, has great visuals, rich data and has everything I personally need. However, I am not a developer and I know that many of our users prefer to live their lives and run their tests through a CLI. With Gatling’s API you can connect to Gatling Enterprise Cloud and create and run your simulations directly through your CLI. You can also get basic results, configure and update packages, and check basic information on your organization.
Looking for a full list of what you can do with the Gatling API? Check out our Swagger API documentation in the application. Just click on the Help Center and select it from the list. You’ll quickly get an idea of everything that’s possible with the API:
Creating an API token
Of course, the first step to using our API is to create an API token. You can do this by logging into Gatling Enterprise Cloud and going to the API Tokens tab in the side menu and following the prompts. Remember to copy your token when you create it as you can only see it at this time.
Using your token to connect a CLI and run a simulation
You’re all set! All you need to do now is run Gatling Enterprise, either from the Bundle or through Maven, Gradle or sbt and you’ll be able to upload and edit packages and create simulations directly from your CLI. There is some configuration to do locally in order to connect the API but you can find all of the details and steps to do that in our documentation here for Maven, Gradle, sbt, and the Gatling Bundle.
Here’s a quick example of a call with a curl that can help you start a simulation directly from your CLI:
curl -X 'POST' \ 'https://cloud.gatling.io/api/public/simulations/start?simulation=REDACTED' \ -H 'accept: application/json' \ -H 'authorization: API Token' \ -H 'Content-Type: application/json' \ -d '{ "extraSystemProperties": { "customProperty": "value" }, "extraEnvironmentVariables": { "customProperty": "value" }, "overrideHostsByPool": { "4a399023-d443-3a58-864f-3919760df78b": { "size": 1, "weight": 60 }, "c800b6d9-163b-3db7-928f-86c1470a9542": { "size": 1, "weight": 40 } } }'
Connect to a CI Tool
At Gatling we’re big CI/CD fans, if you regularly check this blog you’ll know that. You can find many posts on CI/CD benefits including a few I’ve written here and here. Now though, Gatling Enterprise Cloud is more connected with CI/CD than ever. This year we’ve already released two new integrations for some of the most popular tools on the market, Github Actions, and Gitlab CI. Combine those with our previous CI integrations, Jenkins, Teamcity, Bamboo and our CI script and you can easily connect Gatling with any CI tool on the market.
The heart of the connection with these CI tools? You guessed it, the Gatling API! Since the Gatling API allows you to run tests, you can connect it with your CI tool and use it to schedule tests or automatically test your builds with each deployment and receive the results in your CI tool.
If you’re interested in connecting a CI/CD tool check out our documentation here and simply follow the steps and you’ll be up and running in no time.
Use Gatling as a Grafana Datasource
We’re only going to touch on this briefly here as it could be its own full blog post but here are the basics. Grafana is a popular open-source data visualization and monitoring platform. It allows you to create beautiful, interactive dashboards and graphs that help you make sense of your data. It supports a wide range of data sources and has a large community of users who contribute to its development and maintenance. With Gatling Enterprise Cloud and the Gatling API (self-hosted as well), you can get all of your Gatling test results sent directly to Grafana.
One of the main benefits of integrating Gatling with Grafana is that it also allows you to connect to an APM. Another benefit of using Gatling as a Grafana datasource is that it allows you to combine load testing results with other data sources, such as log files or database queries. This can provide a more complete picture of your application’s performance and help you make informed decisions about how to optimize your system.
Looking to integrate Grafana with Gatling, you can find all the details in our documentation here.
Conclusion
Hopefully this has encouraged you to look into the Gatling API and how to use it in your load testing strategy. It’s at the heart of many of the core features of Gatling Enterprise in both our Cloud and Self-Hosted versions. If you have any questions about Gatling Enterprise Cloud or are looking to start a trial, please don’t hesitate to contact us at sales@gatling.io.
Until next time, happy testing.