Skip to content

Live Monitoring

You can use the REST API to start an EVAL activity that generates model output for the missed time range. The activity status can be tracked within Activity view on the Falkonry UI.

Note

This is a recommended option, if you do not want to disrupt or restart live monitoring for an entity in order to set the retroactive time option to generate model output on the historical time range.

The API requires live model ID, common model ID (i.e. M[0]), entity name and time range for which model output needs to be generated. Use the Live Context API</apis/fetch_output> to get the common model ID and use the Falkonry UI to get the live model ID of the relevant assessment. Then use the below Flows API to start generating model output for the historical time range.

Patterns (AI) Model

Request Payload

{
  "flowType": "EVAL",
  "datastream": "zzzzzzzzzzzzzzz",
  "assessment": "yyyyyyyyyyyyyyy",
  "model": "mmmmmmmmmmmmmm",
  "name": "Model output run-1",
  "spec": {
    "commonModelId": "ccccccccccccccc",
    "segments": [{
      "entities": ["<entity_name_1>", "<entity_name_2>"],
      "timeRange": {
        "startTime": "0000000000000000", // in nanoseconds
        "endTime": "0000000000000000" // in nanoseconds
      }
    }],
    "forLive": true,
    "withEpisodes": true
  }
}

cURL request

$ curl --location --request POST 'https://app3.falkonry.ai/api/1.2/accounts/xxxxxxxxxxxxxxx/flows' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
      "flowType": "EVAL", 
      "datastream": "zzzzzzzzzzzzzzz",
      "assessment": "yyyyyyyyyyyyyyy", 
      "model": "mmmmmmmmmmmmmm", 
      "name": "Model output run-1", 
      "spec": {
          "commonModelId": "ccccccccccccccc", 
          "segments": [{
              "entities": ["<entity_name>"], 
              "timeRange": {
                  "startTime": "0000000000000000", // in nanoseconds
                  "endTime": "0000000000000000" // in nanoseconds 
                      }}],
      "forLive": true, 
      "withEpisodes": true } }'

Python

import requests 

URL = 'https://app3.falkonry.ai/api/1.2/accounts/xxxxxxxxxxxxxxx/flows'
TOKEN = '<token>' 
HEADERS = {'Authorization': f'Bearer {TOKEN}'} 
PAYLOAD = { "flowType": "EVAL", 
              "datastream":"zzzzzzzzzzzzzzz", 
              "assessment": "yyyyyyyyyyyyyyy", 
              "model": "mmmmmmmmmmmmmm", 
              "name": "Model output run-1", 
              "spec": {
                  "commonModelId": "ccccccccccccccc", 
                  "segments": [ {
                          "entities": ["<entity_name>"], 
                          "timeRange": { "startTime": "0000000000000000", # in nanoseconds 
                          "endTime": "00000000000000000" # in nanoseconds 
                              }}], 
              "forLive": true,
              "withEpisodes": true}}

response = requests.post(URL, headers=HEADERS, data=PAYLOAD)
print(response.json())

Example response

{
  "id": "1124191510837645312",
  "type": "entities.flow",
  "flowType": "EVAL",
  "status": "CREATED",
  "name": "Model output run-1",
  "datastream": "zzzzzzzzzzzzzzz",
  "assessment": "yyyyyyyyyyyyyyy",
  "model": "mmmmmmmmmmmmmm",
  "spec": {
    "isBatch": false,
    "datastreamStats": {},
    "model": "mmmmmmmmmmmmmm",
    "commonModelId": "ccccccccccccccc",
    "segments": [
      {
        "entities": [
          "machine-1"
        ],
        "timeRange": {
          "startTime": "1684843200000000000",
          "endTime": "1687521600000000000"
        }
      }
    ],
    "assessmentRate": 2000000000,
    "config": {},
    "inputList": [],
    "withEpisodes": true,
    "forEpisode": false,
    "tolerateNoData": false,
    "forLive": true
  },
  "createTime": 1688098542651,
  "updateTime": 1688098542651,
  "createdBy": "1013056801100267520",
  "updatedBy": "1013056801100267520",
  "archived": false,
  "links": []
}

Insights and Rules Model

To start or stop a model for continuous evaluation of incoming data, use the STARTLIVEMODEL and STOPLIVEMODEL flows, respectively. These flows require the model ID of the model you wish to activate or deactivate. - model: The ID of the model that must be made live.

  • For Insights (Anomaly) model: The model ID is the same as the ANOMALYLEARN flow ID for the signal. In case you do not have the ANOMALYLEARN flow ID, you can retrieve the model ID using the following API:

    https://app3.falkonry.ai/api/1.2/accounts/<accountID>/datastreams/000000001/assessments/<signalID>/models?limit=n&sort=-createTime
    

  • For Rules model: you can retrieve the latest model ID using the following API:

    https://app3.falkonry.ai/api/1.2/accounts/<accountID>/datastreams/000000002/assessments/<ruleID>/models?limit=n&sort=-createTime
    

Start live monitoring

To start an live model live, use the STARTLIVEMODEL flow.

Request Payload

{
    "flowType": "STARTLIVEMODEL",
    "name": "Start monitoring signal current",
    "datastream":"000000001",
    "assessment":"1144312304706437120",
    "spec": {
        "model": "1402745199344193536"
    }
}

cURL request

$ curl --location --request POST 'https://app3.falkonry.ai/api/1.2/accounts/xxxxxxxxxxxxxxx/flows' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
      "flowType": "STARTLIVEMODEL", 
      "name": "Start monitoring signal current",
      "datastream":"000000001",
      "assessment":"1144312304706437120",
      "spec": {
          "model": "1402745199344193536"
      }'

Python

import requests 

URL = 'https://app3.falkonry.ai/api/1.2/accounts/xxxxxxxxxxxxxxx/flows'
TOKEN = '<token>' 
HEADERS = {'Authorization': f'Bearer {TOKEN}'} 
PAYLOAD = <payload>

response = requests.post(URL, headers=HEADERS, data=PAYLOAD)
print(response.json())

Stop live monitoring

To stop an live model live, use the STOPLIVEMODEL flow.

Request Payload

{
    "flowType": "STOPLIVEMODEL",
    "name": "Start monitoring signal current",
    "spec": {
              "model": "1402745199344193536"
            }
}

cURL request

$ curl --location --request POST 'https://app3.falkonry.ai/api/1.2/accounts/xxxxxxxxxxxxxxx/flows' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
      "flowType": "STOPLIVEMODEL", 
      "name": "Start monitoring signal current",
      "spec": {
          "model": "1402745199344193536"
      }'

Python

import requests 

URL = 'https://app3.falkonry.ai/api/1.2/accounts/xxxxxxxxxxxxxxx/flows'
TOKEN = '<token>' 
HEADERS = {'Authorization': f'Bearer {TOKEN}'} 
PAYLOAD = <payload>

response = requests.post(URL, headers=HEADERS, data=PAYLOAD)
print(response.json())