Linux machine¶
You can automate Qualytics operations on a Linux machine by scheduling them with cron jobs. This guide walks you through setting up a scheduled curl command to trigger exports at defined intervals.
Prerequisites¶
Before proceeding, ensure that you have the following:
- Access to the terminal on your machine.
- The
curlcommand-line tool installed. - The desired Qualytics instance details, including the instance URL and authentication token.
Steps to Create a Scheduled Operation¶
1. Open the Crontab Editor¶
Run the following command in your terminal to open the crontab editor:
2. Add the Cron Job Entry¶
In the crontab editor, add the following line to execute the curl command at your specified schedule. Replace <asset-type> with anomalies, checks, or profiles. See the Export Operation API for every field the request accepts.
<cronjob-expression> /usr/bin/curl --request POST --url 'https://<your-instance>.qualytics.io/api/operations/run' --header 'Authorization: Bearer <your-token>' --header 'Content-Type: application/json' --data '{"type": "export", "datastore_id": <datastore-id>, "asset_type": "<asset-type>", "container_ids": [<container-id-one>, <container-id-two>]}' >> <path-to-show-logs> 2>&1
3. Example:¶
For example, to run the command every 5 minutes:
*/5 * * * * /usr/bin/curl --request POST --url 'https://your-instance.qualytics.io/api/operations/run' --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' --header 'Content-Type: application/json' --data '{"type": "export", "datastore_id": 123, "asset_type": "anomalies", "container_ids": [14, 16]}' >> /path/to/show/logs.txt 2>&1
4. Verify or List Cron Jobs:¶
Customize the placeholders based on your specific details and requirements. Save the crontab file to activate the scheduled operation.