TRY ME

Try Valo for free

We want to show you something amazing.

We'll send you a link to download a fully functional Valo copy to play with.



Great! Check your email and enjoy Valo



Apologies, we seem to be having a problem processing your input, please try again

Daemon API

Api for creating server side queries which are kept running until they are explicitly deleted.

The _daemonise end-point in the execution service API is a convenient way of creating server side queries directly from an execution session.

A daemon specification has two components; the query which is a valid execution session document, and the settings which controls the behaviour of the daemonised query.

{
    "query": {
        "variables": [],
        "queries": [
            {
                "id": "29356785-eb07-4185-94be-0d32c53c0d05",
                "label": "Q1",
                "query_type": "valo-query-lang",
                "body": "from /streams/demo/infrastructure/cpu window of 1 hour select count()"
            }
        ]
    },
    "settings" : {
      "contributor": "/contributor/demo/domain/9a2df62c-f97d-4971-932d-0099bc4efa49",
      "contributorFieldName": "source",
      "target": {
          "type": "STREAM",
          "uri": "/streams/demo/infrastructure/derivedMsg"
      },
    }
}

Query

The query is a valid execution service session document with the following restrictions

  • The session cannot have any issues.
  • The session can have many logical queries, but only a single query generating the actual output.

Settings

Type Description Optional Default
contributor A contributor id to decorate the output with. true  
contributorFieldName The output field name for contributor. true contributor
target Where the output of the query should be sent false  

Contributor

The contributor field is an optional contributor uri to decorate the query output with. If a query generates the following output

{ "host": "A", "user": 20, "kernel": 50 }

And the contributor is defined as

{
  "contributor": "/contributor/demo/domain/9a2df62c-f97d-4971-932d-0099bc4efa49"
}

Then the output is decorated as

{ "host": "A", "user": 20, "kernel": 50, "contributor": "9a2df62c-f97d-4971-932d-0099bc4efa49" }

And the resulting output schema is defined as

{
  "host": { "type": "string" },
  "user": { "type": "int" },
  "kernel": { "type": "int" },
  "contributor": { "type": "contributor", "definition": "domain" }
}

By default, the field which is added to the output is named “contributor”. This can be changed by explicitly defining which name to use by setting the contributorFieldName like so;

{
   "contributor": "/contributor/demo/domain/9a2df62c-f97d-4971-932d-0099bc4efa49",
   "contributorFieldName": "source"
}

Target

The target specifies where the output of the query should be sent. The options are QUERY and STREAM.

The QUERY target is used when the output type should be inferred from the query.

{
  "target": {
    "type": "QUERY"
  }
}

A query like the following would send the output to an OUTPUT_CHANNEL

from /streams/demo/infrastructure/cpu
where user > 50

whilst the following would send the output to a PHYSICAL_STREAM

from /streams/demo/infrastructure/cpu
where user > 50
into /streams/demo/infrastructure/derivedMsg

The STREAM target is used to explicitly define a PHYSICAL_STREAM as the output

{
  "target": {
    "type": "STREAM",
    "uri": "/streams/demo/infrastructure/derivedMsg"
  }
}

If the query already has an INTO clause with a conflicting target stream and error will be generated.

The actual output type can be resolved by calling the details end-point.

Ownership

It is up to the client to delete unused server side queries.

Get daemons under a collection

GET /daemon/:tenant/:collection

Lists all daemonised queries for this tenant.

Example Request:

GET /daemon/demo/system HTTP/1.1

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "instances": [
            "24fca89d-2c0c-4a2c-a45c-699bf8fe69b8",
            "7d8746fd-79da-4ab5-a39c-3dd949744926",
            "959d786c-79aa-4a77-abda-df7c643d4aee",
            "3b5673df-3efb-437f-aa46-43a714fbda09"
          ]
}

Put a new daemon

PUT /daemon/:tenant/:collection/:id

Creates a daemonised query.

Example Request:

PUT /daemon/demo/system/f4ef348c-0e47-44f8-9475-bf4bcc67ca8b HTTP/1.1
Valo-Config-Version: 86a4391e-79d3-4bca-9c31-651dc38b4910

{
    "query": {
        "variables": [],
        "queries": [
            {
                "id": "29356785-eb07-4185-94be-0d32c53c0d05",
                "label": "Q1",
                "query_type": "valo-query-lang",
                "body": "from /streams/demo/infrastructure/cpu window of 1 hour select count()"
            }
        ]
    },
    "settings" : {
      "contributor": "/contributor/demo/domain/9a2df62c-f97d-4971-932d-0099bc4efa49",
      "contributorFieldName": "source",
      "target": {
          "type": "STREAM",
          "uri": "/streams/demo/infrastructure/derivedMsg"
      },
    }
}

Example Response:

Just the same as GET /daemon/demo/system/:id.

Get an existing daemon

GET /daemon/:tenant/:collection/:id

Gets a single daemonised query by id.

Example Request:

GET /daemon/demo/system/4b553ad5-e365-4f82-9e2e-7aafb7058ba4 HTTP/1.1

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json
Valo-Config-Version: 86a4391e-79d3-4bca-9c31-651dc38b4910

{
    "query": {
        "variables": [],
        "queries": [
            {
                "id": "29356785-eb07-4185-94be-0d32c53c0d05",
                "label": "Q1",
                "query_type": "valo-query-lang",
                "body": "from /streams/demo/infrastructure/cpu window of 1 hour select count()"
            }
        ]
    },
    "settings" : {
      "contributor": "/contributor/demo/domain/9a2df62c-f97d-4971-932d-0099bc4efa49",
      "contributorFieldName": "source",
      "target": {
          "type": "STREAM",
          "uri": "/streams/demo/infrastructure/derivedMsg"
      },
    }
}

Get the daemon details

GET /daemon/:tenant/:collection/:id/details

Gets the session details of the daemonised query. The supported output types are the same as for an execution service.

Example Request:

GET /daemon/demo/system/4b553ad5-e365-4f82-9e2e-7aafb7058ba4/details HTTP/1.1

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
    "session": "/execution/system/daemon_5264726f-e17b-4bb4-bc44-f45be8fdb44e",
    "output": {
        "type": "OUTPUT_CHANNEL",
        "id": "5264726f-e17b-4bb4-bc44-f45be8fdb44e",
        "outputUri": "/output/demo/6daccb6739b02bacda2d4c37428263d3/5264726f-e17b-4bb4-bc44-f45be8fdb44e",
        "outputType": "UNBOUNDED",
        "isHistorical": false,
        "schema": {
          "version": "",
          "config": {
            "key": []
          },
          "topDef": {
            "type": "record",
            "properties": {
              "kernel": { "type": "double" },
              "contributor": { "type": "contributor", "definition": "probes" },
              "process": { "type": "string" }
            }
          }
        }
    }
}
Status Codes:
  • 404 Not Found – the output doesn’t exist anymore (ie. the daemonised query has been deleted)

Delete a daemon

DELETE /daemon/:tenant/:collection/:id

Deletes an existing daemon query.