How to check Firebolt Engine Status via REST API

Introduction

Monitoring the status of your Firebolt engine is crucial for ensuring smooth operation and performance. Using the Firebolt REST API, you can easily check the engine status to keep track of its activity and health. By the end of this article, you will know how to authenticate, get the system engine URL, and query the engine status.

You can refer to the Firebolt documentation for more details on Firebolt API.

TL;DR

  • Ensure you have an active service account.

  • Obtain a service account secrete and access token for authentication.

  • Retrieve the System Engine URL.

  • Query the system engine to check an engine status.

Step-by-step guide

Step 1: Ensure an Active Service Account

Verify that you have an active service account within your Firebolt account that is connected to a user. This is necessary for authenticating API requests.

Example SQL code:

SELECT sa.service_account_name , sa.service_account_id  
FROM information_schema.service_accounts sa
JOIN information_schema.users u ON u.service_account_name = sa.service_account_name;

Step 2: Obtain the service account secret

A service account secret is used to generate an access token, enabling programmatic access to the Firebolt API. To generate a secret for a service account using SQL, execute the statement below.

Example SQL code:

CALL fb_GENERATESERVICEACCOUNTKEY('<service_account_name>');

Replace <service_account_name> with your service account name obtained in Step 1.

Make a note of the secret once generated - it can’t be retrieved later. If the secret is lost (or needs to be rotated), you can always generate a new secret. However, generating a new secret for your service account replaces any previous secret (which cannot be used once a new one is generated).

Step 3: Obtain an ACCESS token

To make authenticated requests to the Firebolt API, you need an access token. Follow the below steps to obtain the token.

Example API request:

curl -X POST --location 'https://id.app.firebolt.io/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'audience=https://api.firebolt.io' \
--data-urlencode "client_id=<service_account_id>" \
--data-urlencode "client_secret=<service_account_secret>"

Replace <service_account_id> and <service_account_secret> with your service account ID and secret, obtained in Steps 1 and 2.

Step 4: Retrieve the System Engine URL

Use the access token to get the URL of the system engine.

Example API request:

curl https://api.app.firebolt.io/web/v3/account/<account_name>/engineUrl \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <access_token>'

Replace <account_name> with your Firebolt account name and <access_token> with the token obtained in Step 3.

Step 5: Query the System Engine

Query the system engine to check your engine status.

Example API request:

`curl --location 'https://<system engine URL>/query' \`--header 'Authorization: Bearer <access_token>' \
--data "select status from information_schema.engines where engine_name = '<your_engine_name>'"

Replace <system_engine_URL> with the URL obtained in Step 4, <access_token> with your access token obtained in Step 3, and <your_engine_name> with your engine name.

Full Example Code:

SELECT sa.service_account_name , sa.service_account_id  
FROM information_schema.service_accounts sa
JOIN information_schema.users u ON u.service_account_name = sa.service_account_name;

CALL fb_GENERATESERVICEACCOUNTKEY('<name>');

curl -X POST --location 'https://id.app.firebolt.io/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'audience=https://api.firebolt.io' \
--data-urlencode "client_id=<service_account_id>" \
--data-urlencode "client_secret=<service_account_secret>"

curl https://api.app.firebolt.io/web/v3/account/<account_name>/engineUrl \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <access_token>'

curl --location 'https://<system_engine_URL>/query' \
--header 'Authorization: Bearer <access_token>' \
--data "select status from information_schema.engines where engine_name = '<your_engine_name>'"