Sift | Docs

Step 4: Create Rule and view it in Sift

Overview

As observed in the first tutorial, there was a sharp and sudden decline in both max_air_temp(C) and max_ground_temp(C). On October 6, 2021, at 17:00:00, both signals dropped well below their normal range, possibly reflecting an unexpected environmental condition or a brief telemetry issue. To capture this behavior, let's create the same Rule as in Step 4 of the first tutorial, but this time using the REST API instead of the UI. The endpoint we will use to create the Rule is: CreateRule.

Create Rule

Run the cURL command below to create the Rule.

curl -X POST "YOUR_REST_API_URL_HERE/api/v1/rules" \
  -H "Authorization: Bearer YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "update": {
      "name": "fl_demo_rule",
      "isEnabled": true,
      "assetConfiguration": {
        "assetIds": ["ASSET_ID"]
      },
      "conditions": [
        {
          "ruleConditionId": "condition-1",
          "expression": {
            "calculatedChannel": {
              "expression": "$1 < -50 && $2 < -60",
              "channelReferences": {
                "$1": { "name": "max_air_temp(C)" },
                "$2": { "name": "max_ground_temp(C)" }
              }
            }
          },
          "actions": [
            {
              "ruleActionId": "action-1",
              "actionType": "ANNOTATION",
              "configuration": {}
            }
          ]
        }
      ]
    }
  }'

Placeholders

  • Replace YOUR_REST_API_URL_HERE with your REST API URL obtained in the previous step.
  • Replace YOUR_API_KEY_HERE with your API key obtained in the previous step.
  • Replace fl (in fl_demo_rule) with your initials.
  • Replace ASSET_ID with the Asset ID you copied in Step 3.
A successful response
{
"ruleId": "string" 
}

View created Rule in Sift

Now that we have created the Rule using the REST API, let's view the created Rule in Sift.

  1. In Sift, click .
  2. Click the Rules tab.
  3. In the Rule name box, enter the name of the Rule.
  4. In the Rules tab, click the name of the Rule.
Created Rule

On this page