Create an HTTP Monitor

The following example shows how to create an HTTP monitor. An HTTP monitor sends events to the target URL. You must run a server at the target URL. For test URLs, see one of the many online services that can receive and allow you to inspect web requests. For example: RequestBin

Request

POST /ws/v1/monitors/inventory

Request

{
  "type": "http",
  "topics": [
    "DataPoint/*/cl1/cval",
    "DataPoint/*/ts1/bat"
  ],
  "description": "DataPoint Events",
  "method": "POST",
  "format": "json",
  "url": "https://example.com/apis/post",
  "auth_token": "user:password",
  "headers": [
    "ExampleHeader: TestValue",
    "From: Remote Manager",
    "Third: meep! meep!"
  ],
  "persistent": true,
  "batch_duration": 10,
  "batch_size": 100,
  "schema_type": "handlebars",
  "schema": "[{{#eachFiltered this}}{{#if @index}},{{/if}}\n  {\n    \"timestamp\": \"{{formatTime DataPoint.timestamp}}\",\n    \"stream\": \"{{DataPoint.streamId}}\",\n    \"value\": \"{{DataPoint.data}}\",\n    \"device\": \"{{firstPathComponent DataPoint.streamId}}\"\n  }{{/eachFiltered}}\n]"
}

Response

The monitor is initially created with an inactive status. The system activates it in short order. If the target URL does not respond to requests, the monitor will eventually be deactivated.

{
    "batch_duration": 10,
    "batch_size": 100,
    "compression": "none",
    "customer_id": 42,
    "description": "DataPoint Events",
    "format": "json",
    "headers": [
        "ExampleHeader",
        "Third",
        "From"
    ],
    "id": 24798,
    "method": "POST",
    "persistent": true,
    "schema": "[{{#eachFiltered this}}{{#if @index}},{{/if}}\n  {\n    \"timestamp\": \"{{formatTime DataPoint.timestamp}}\",\n    \"stream\": \"{{DataPoint.streamId}}\",\n    \"value\": \"{{DataPoint.data}}\",\n    \"device\": \"{{firstPathComponent DataPoint.streamId}}\"\n  }{{/eachFiltered}}\n]",
    "schema_type": "handlebars",
    "status": "inactive",
    "topics": [
        "DataPoint/*/cl1/cval",
        "DataPoint/*/ts1/bat"
    ],
    "type": "http",
    "url": "https://example.com/apis/post"
}