Charge your APIs Volume 9: Perfecting APIOps - API Monitoring with Checkly
5.7.2023 | 3 minutes of reading time
Over the past series of blog posts, we've been exploring the fascinating world of API Operations (APIOps), diving deep into Continuous Integration, Continuous Deployment, load testing, API diffing, and API Portals and Marketplaces. We've built a robust GitHub Actions workflow that incorporates these aspects to ensure efficient management of APIs. Today, we're turning our attention to an often-overlooked yet vital part of APIOps: API Monitoring, featuring Checkly as our monitoring tool of choice.
API Monitoring with Checkly
API Monitoring is crucial for maintaining service health and performance. Checkly is a robust and user-friendly monitoring service that allows for active monitoring of your APIs, ensuring they're performing optimally and alerting you of any anomalies or downtime.
Step 1: Integrating Checkly into Our Pipeline
First, we will add a new job to our pipeline to configure Checkly for our API. This job will run after the deploy-to-pam
job, setting up an API check in Checkly using the URL of our deployed API.
1monitor:
2 needs: deploy-to-pam
3 runs-on: ubuntu-latest
4 steps:
5 - uses: actions/checkout@v2
6 - name: Get API URL
7 run: |
8 echo "API_URL=$(yq e '.servers[0].url' ${{ inputs.spec-file }})" >> $GITHUB_ENV
9 echo "API_TITLE=$(yq e '.info.title' ${{ inputs.spec-file }})" >> $GITHUB_ENV
10 echo "API_VERSION=$(yq e '.info.version' ${{ inputs.spec-file }})" >> $GITHUB_ENV
11 echo "API_NAME='${API_TITLE} ${API_VERSION}'" >> $GITHUB_ENV
12 - name: Setup Checkly API Check
13 run: |
14 # Install HTTPie
15 sudo apt-get install httpie
16 # The command to setup the API check in Checkly
17 # will depend on Checkly's API or CLI
Step 2: Creating an API Check with Checkly
Let's assume that we have our API deployed at the URL extracted above. We want to ensure it's responding as expected. Here's an example of how you can use Checkly to set up a check for your API:
1echo '{"activated":true,"muted":false,"doubleCheck":true,"shouldFail":false,"locations":["eu-central-1"],"alertSettings":{"escalationType":"RUN_BASED","reminders":{"amount":0,"interval":5},"runBasedEscalation":{"failedRunThreshold":1}},"useGlobalAlertSettings":true,"groupId":null,"groupOrder":null,"runtimeId":null,"request":{"method":"GET","url":"$API_URL","skipSSL":false,"bodyType":"NONE"},"frequency":10,"tearDownSnippetId":null,"setupSnippetId":null,"localSetupScript":null,"localTearDownScript":null,"degradedResponseTime":10000,"maxResponseTime":20000,"name":"$API_NAME"}' | \ 2 http POST 'https://api.checklyhq.com/v1/checks/api?autoAssignAlerts=true' \ 3 Authorization:'Bearer ${{ secrets.CHECKLY_API_KEY }}' \ 4 accept:application/json \ 5 content-type:application/json \ 6 x-checkly-account:${{ secrets.CHECKLY_ACCOUNT_ID }}
This command creates a new API check in Checkly. The check will send a request to our API every 5 minutes and alert us if it doesn't get a successful response.
Conclusion: APIOps at First Sight
The integration of Checkly into our APIOps pipeline marks a significant milestone in our journey. From the first steps of setting up Continuous Integration to the continuous monitoring of our APIs' health, we've built an end-to-end workflow that takes an API from development to deployment, to being diffed, shared, and now, monitored.
However, the world of APIOps is as dynamic as the APIs it governs. While we've built a robust and comprehensive pipeline, it's important to remember that there's always room for improvement, customisation, and expansion. Whether it's integrating more tools, automating additional tasks, or refining existing processes, the pursuit of perfecting APIOps is a continuous one.
As we draw this chapter to a close, let's celebrate the completion of our APIOps pipeline - a testament to the power of automation, the value of monitoring, and the endless possibilities of API management. The journey continues, API enthusiasts. Onwards and upwards!
References:
GitHub - codecentric/github-apiops-pipeline: An APIOps Pipeline for Github
Charge your APIs Volume 8: Expanding APIOps - API Portals and Marketplaces
More articles
fromDaniel Kocot
Your job at codecentric?
Jobs
Agile Developer und Consultant (w/d/m)
Alle Standorte
More articles in this subject area
Discover exciting further topics and let the codecentric world inspire you.
Gemeinsam bessere Projekte umsetzen.
Wir helfen deinem Unternehmen.
Du stehst vor einer großen IT-Herausforderung? Wir sorgen für eine maßgeschneiderte Unterstützung. Informiere dich jetzt.
Hilf uns, noch besser zu werden.
Wir sind immer auf der Suche nach neuen Talenten. Auch für dich ist die passende Stelle dabei.
Blog author
Daniel Kocot
Senior Solution Architect / Head of API Consulting
Do you still have questions? Just send me a message.
Do you still have questions? Just send me a message.