Skip to content
This repository was archived by the owner on Sep 29, 2021. It is now read-only.

Scheduling TelemetryDashboard 1 Generate Metadata

Levi Turner edited this page Dec 1, 2019 · 2 revisions

Objective: To schedule the reload task named TelemetryDashboard-1-Generate-Metadata which is an External Program Event used to generate a cache of app meta-data consumed by the Telemetry Dashboard

Table of Contents:

Requirements

  • Experience and ability to make RESTful API calls to Qlik Sense
  • Telemetry Dashboard:
    • Installed
    • Configured

Work-flow (high level)

  • Create the schemaeventoperational
  • Create the schemaEvent and link it to the externalprogramtask

Work-flow (detailed)

  • POST /qrs/schemaeventoperational
    • Example Body:
  {
    "nextExecution": "2018-10-25T13:30:26Z",
    "schemaPath": "SchemaEventOperational"
  }

Example response:

{
  "id": "65a74995-1c66-422f-9039-fa164dda68f6",
  "createdDate": "2018-10-25T13:06:26.078Z",
  "modifiedDate": "2018-10-25T13:06:26.078Z",
  "modifiedByUserName": "INTERNAL\\sa_repository",
  "lastEventDate": "1753-01-01T00:00:00Z",
  "nextExecution": "2018-10-25T13:30:26Z",
  "timesTriggered": 0,
  "privileges": null,
  "schemaPath": "SchemaEventOperational"
}
  • POST /qrs/schemaEvent
    • Example Body:
{
  "createdDate": "2017-05-06T00:55:54.201Z",
  "modifiedDate": "2017-05-26T15:48:06.347Z",
  "modifiedByUserName": "DOMAIN\\USERID",
  "timeZone": "America/New_York",
  "daylightSavingTime": 0,
  "startDate": "2018-10-25T13:30:26Z",
  "expirationDate": "9999-12-31T00:00:00",
  "schemaFilterDescription": [
    "* * - * * * * *"
  ],
  "incrementDescription": "0 0 1 0",
  "incrementOption": 2,
  "operational": {
  "id": "65a74995-1c66-422f-9039-fa164dda68f6",
  "createdDate": "2018-10-25T13:06:26.078Z",
  "modifiedDate": "2018-10-25T13:06:26.078Z",
  "modifiedByUserName": "INTERNAL\\sa_repository",
  "lastEventDate": "1753-01-01T00:00:00Z",
  "nextExecution": "2018-10-25T13:30:26Z",
  "timesTriggered": 0,
  "privileges": null,
  "schemaPath": "SchemaEventOperational"
},
  "name": "Reload fetchmetadata.js",
  "enabled": true,
  "eventType": 0,
  "externalProgramTask": {
    "id": "8fcb0e63-2ad3-4b2f-9ec1-7fa8624d6658",
    "operational": {
      "id": "c4691b58-2471-44b3-aed7-93f6ca5781b3"},
    "name": "TelemetryDashboard-1-Generate-Metadata",
    "taskType": 1,
    "enabled": true,
    "taskSessionTimeout": 1440,
    "maxRetries": 0,
    "privileges": null
  },
  "userSyncTask": null,
  "reloadTask": null,
  "privileges": null,
  "schemaPath": "SchemaEvent"
}
  • Notes:
    • operational > id is returned from the first call
    • externalProgramTask > id is returned from a GET /qrs/externalprogramtask/full call
    • externalProgramTask > operational > id is returned from a GET /qrs/externalprogramtask/full call

Modifying the Execution Time

  • GET /qrs/schemaeventoperational/65a74995-1c66-422f-9039-fa164dda68f6 Example Response:
{
  "id": "65a74995-1c66-422f-9039-fa164dda68f6",
  "createdDate": "2018-10-25T13:06:26.078Z",
  "modifiedDate": "2018-10-25T14:55:32.706Z",
  "modifiedByUserName": "INTERNAL\\sa_scheduler",
  "lastEventDate": "1753-01-01T00:00:00Z",
  "nextExecution": "2018-10-26T04:00:00Z",
  "timesTriggered": 0,
  "privileges": null,
  "schemaPath": "SchemaEventOperational"
}
  • PUT /qrs/schemaeventoperational/65a74995-1c66-422f-9039-fa164dda68f6 Example Body:
{
  "id": "65a74995-1c66-422f-9039-fa164dda68f6",
  "createdDate": "2018-10-25T13:06:26.078Z",
  "modifiedDate": "2018-10-25T14:55:32.706Z",
  "modifiedByUserName": "INTERNAL\\sa_scheduler",
  "lastEventDate": "1753-01-01T00:00:00Z",
  "nextExecution": "2018-10-25T15:30:33Z",
  "timesTriggered": 0,
  "privileges": null,
  "schemaPath": "SchemaEventOperational"
}
  • Note We've modified nextExecution
  • GET /qrs/schemaevent/76339da3-24ac-4e88-9fcb-a5ebface2756 Example Response:
{
  "id": "76339da3-24ac-4e88-9fcb-a5ebface2756",
  "createdDate": "2018-10-25T13:09:26.243Z",
  "modifiedDate": "2018-10-25T14:55:32.544Z",
  "modifiedByUserName": "INTERNAL\\sa_repository",
  "timeZone": "America/New_York",
  "daylightSavingTime": 0,
  "startDate": "1753-01-01T00:00:00",
  "expirationDate": "9999-12-31T00:00:00",
  "schemaFilterDescription": [
    "* * - * * * * *"
  ],
  "incrementDescription": "0 0 1 0",
  "incrementOption": 1,
  "operational": {
    "id": "65a74995-1c66-422f-9039-fa164dda68f6",
    "nextExecution": "2018-10-25T15:30:33Z",
    "timesTriggered": 0,
    "privileges": null
  },
  "name": "Reload fetchmetadata.js",
  "enabled": true,
  "eventType": 0,
  "reloadTask": null,
  "userSyncTask": null,
  "externalProgramTask": {
    "id": "8fcb0e63-2ad3-4b2f-9ec1-7fa8624d6658",
    "operational": {
      "id": "c4691b58-2471-44b3-aed7-93f6ca5781b3",
      "lastExecutionResult": {
        "id": "1238c399-311a-4111-947c-18ab5d2cc47f",
        "executingNodeName": "sense.company.com",
        "status": 7,
        "startTime": "2018-10-23T16:27:36.192Z",
        "stopTime": "2018-10-23T16:28:21.158Z",
        "duration": 44966,
        "fileReferenceID": "00000000-0000-0000-0000-000000000000",
        "scriptLogAvailable": false,
        "details": [
          {
            "id": "1b78bd94-3894-45c2-93aa-bf24cb39b96f",
            "detailsType": 2,
            "message": "Changing task state from Started to FinishedSuccess",
            "detailCreatedDate": "2018-10-23T16:28:21.192Z",
            "privileges": null
          },
          {
            "id": "89e43e7b-335d-45e8-bd07-56a8daf34690",
            "detailsType": 2,
            "message": "Changing task state to Triggered",
            "detailCreatedDate": "2018-10-23T16:27:36.192Z",
            "privileges": null
          },
          {
            "id": "3108753b-77bd-41cd-899a-3b77cd9a2142",
            "detailsType": 2,
            "message": "Trying to start task. Sending task to slave scheduler sense.company.com",
            "detailCreatedDate": "2018-10-23T16:27:36.386Z",
            "privileges": null
          },
          {
            "id": "e3f87688-3052-42b5-b33d-f5efdbc51d6a",
            "detailsType": 2,
            "message": "Changing task state from Triggered to Started",
            "detailCreatedDate": "2018-10-23T16:27:36.512Z",
            "privileges": null
          }
        ],
        "privileges": null
      },
      "nextExecution": "2018-10-26T04:00:00Z",
      "privileges": null
    },
    "name": "TelemetryDashboard-1-Generate-Metadata",
    "taskType": 1,
    "enabled": true,
    "taskSessionTimeout": 1440,
    "maxRetries": 0,
    "privileges": null
  },
  "privileges": null,
  "schemaPath": "SchemaEvent"
}
  • PUT /qrs/schemaevent/76339da3-24ac-4e88-9fcb-a5ebface2756
    • Example body:
{
  "id": "76339da3-24ac-4e88-9fcb-a5ebface2756",
  "createdDate": "2018-10-25T13:09:26.243Z",
  "modifiedDate": "2018-10-25T14:55:32.544Z",
  "modifiedByUserName": "INTERNAL\\sa_repository",
  "timeZone": "America/New_York",
  "daylightSavingTime": 0,
  "startDate": "2018-10-25T11:30:33",
  "expirationDate": "9999-12-31T00:00:00",
  "schemaFilterDescription": [
    "* * - * * * * *"
  ],
  "incrementDescription": "0 0 1 0",
  "incrementOption": 2,
  "operational": {
    "id": "65a74995-1c66-422f-9039-fa164dda68f6",
    "nextExecution": "2018-10-25T15:30:33Z",
    "timesTriggered": 0,
    "privileges": null
  },
  "name": "Reload fetchmetadata.js",
  "enabled": true,
  "eventType": 0,
  "reloadTask": null,
  "userSyncTask": null,
  "externalProgramTask": {
    "id": "8fcb0e63-2ad3-4b2f-9ec1-7fa8624d6658",
    "operational": {
      "id": "c4691b58-2471-44b3-aed7-93f6ca5781b3",
      "lastExecutionResult": {
        "id": "1238c399-311a-4111-947c-18ab5d2cc47f",
        "executingNodeName": "sense.company.com",
        "status": 7,
        "startTime": "2018-10-23T16:27:36.192Z",
        "stopTime": "2018-10-23T16:28:21.158Z",
        "duration": 44966,
        "fileReferenceID": "00000000-0000-0000-0000-000000000000",
        "scriptLogAvailable": false,
        "details": [
          {
            "id": "1b78bd94-3894-45c2-93aa-bf24cb39b96f",
            "detailsType": 2,
            "message": "Changing task state from Started to FinishedSuccess",
            "detailCreatedDate": "2018-10-23T16:28:21.192Z",
            "privileges": null
          },
          {
            "id": "89e43e7b-335d-45e8-bd07-56a8daf34690",
            "detailsType": 2,
            "message": "Changing task state to Triggered",
            "detailCreatedDate": "2018-10-23T16:27:36.192Z",
            "privileges": null
          },
          {
            "id": "3108753b-77bd-41cd-899a-3b77cd9a2142",
            "detailsType": 2,
            "message": "Trying to start task. Sending task to slave scheduler sense.company.com",
            "detailCreatedDate": "2018-10-23T16:27:36.386Z",
            "privileges": null
          },
          {
            "id": "e3f87688-3052-42b5-b33d-f5efdbc51d6a",
            "detailsType": 2,
            "message": "Changing task state from Triggered to Started",
            "detailCreatedDate": "2018-10-23T16:27:36.512Z",
            "privileges": null
          }
        ],
        "privileges": null
      },
      "nextExecution": "2018-10-25T15:30:33Z",
      "privileges": null
    },
    "name": "TelemetryDashboard-1-Generate-Metadata",
    "taskType": 1,
    "enabled": true,
    "taskSessionTimeout": 1440,
    "maxRetries": 0,
    "privileges": null
  },
  "privileges": null,
  "schemaPath": "SchemaEvent"
}
  • Note: We've modified startDate, incrementOption, nextExecution

Qlik-CLI

Here is an example of scheduling the Metadata fetch using the Qlik-CLI project:

#Requires -Modules Qlik-Cli
$Data = Get-Content C:\ProgramData\Qlik\Sense\Host.cfg
# Convert the base64 encoded install name for Sense to UTF data
$FQDN = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($($Data)))
Connect-Qlik -ComputerName $($FQDN) -UseDefaultCredentials
# Using raw output to handle date formats
$rawoutput=$true
$operationalBody = '  {
    "nextExecution": "2018-10-25T13:30:26Z",
    "schemaPath": "SchemaEventOperational"
  }'
# Create the Schema Operational
$schemaOperational = Invoke-QlikPost -path /qrs/schemaeventoperational -body $operationalBody
$metadataFetchTask = Invoke-QlikGet -path "/qrs/externalprogramtask/full?filter=(name eq 'TelemetryDashboard-1-Generate-Metadata')"
$metadataFetchTask = Invoke-QlikGet -path /qrs/externalprogramtask/$($metadataFetchTask.id)
$eventBody = '{
    "createdDate": "2017-05-06T00:55:54.201Z",
    "modifiedDate": "2017-05-26T15:48:06.347Z",
    "modifiedByUserName": "INTERNAL\\sa_api",
    "timeZone": "America/New_York",
    "daylightSavingTime": 0,
    "startDate": "2018-10-25T13:30:26Z",
    "expirationDate": "9999-12-31T00:00:00",
    "schemaFilterDescription": [
      "* * - * * * * *"
    ],
    "incrementDescription": "0 0 1 0",
    "incrementOption": 2,
    "operational": {
    "id": "'
$eventbody += $($schemaOperational.id)
$eventBody += '",
    "createdDate": "2018-10-25T13:06:26.078Z",
    "modifiedDate": "2018-10-25T13:06:26.078Z",
    "modifiedByUserName": "INTERNAL\\sa_repository",
    "lastEventDate": "1753-01-01T00:00:00Z",
    "nextExecution": "2018-10-25T13:30:26Z",
    "timesTriggered": 0,
    "privileges": null,
    "schemaPath": "SchemaEventOperational"
  },
    "name": "Reload fetchmetadata.js",
    "enabled": true,
    "eventType": 0,
    "externalProgramTask": {
      "id": "'
$eventBody += $($metadataFetchTask.id)
$eventBody += '",
      "operational": {
        "id": "'
$eventBody += $($metadataFetchTask.operational.id)
$eventBody += '"},
      "name": "TelemetryDashboard-1-Generate-Metadata",
      "taskType": 1,
      "enabled": true,
      "taskSessionTimeout": 1440,
      "maxRetries": 0,
      "privileges": null
    },
    "userSyncTask": null,
    "reloadTask": null,
    "privileges": null,
    "schemaPath": "SchemaEvent"
  }'
Invoke-QlikPost -path "/qrs/schemaEvent" -body $eventBody
Clone this wiki locally