Connecting

Integration

Integration is done by creating a Station and then generating a Authentication Token for that Station. This token is then sent with every request from that Station so that Insight knows who is sending the event and that it is a trusted Station/Device.

You should know!

If your stations cannot make web requests for some reason but can log events to file, you could write your own parser to process those lines and then send events to Insight on behalf of those Stations using our Mediator tool. This will ensure that each Station is still treated as a separate Station even though it's one application sending the events for all of them.

We would be happy to help you with the integration process, including writing custom software to assist with integration.

Check out Offline stations for more options.


Stations and Station Types

A Station is what we refer to a device that will send events to Insight. This can be a machine in a factory, an IoT device, a Webserver or some desktop application. Any single device that sends events.

As you could have several identical machines, devices, workstations, etc we identify them collectively as a Station Type and individually as a Station.

You will need to first create a Station Type so that you can create Stations within that type.

Create a Station Type

Navigate to Configuration > Station Configuration

Create a Station Type by clicking on the Add Station Type button and give it a name defining those Stations.

Create a Station

Now that you have a Station Type defined, click on the Add a Station button within that Station Type and give it a name that identifies that specific Station.


Sending events

Please also refer to the API menu within the Insight server for all available API's and the full JSON structure for those events.

Generate an Authentication Token for the Station that will be sending the events by clicking on the [key] icon next to that Station on the [Station Configuration] page. The examples below will use a dummy generated authentication token of ABCD1234.

Instance Event

The table below describes the basic object structure of the Instance events that you can send.

FieldTypeDescription
instancesobject arrayAt least one instance must be sent.
tagsobject array (optional)Send additional tags along with your event that can be used in reporting later on.
tags: tag_type_namestringThe name of the tag. Ensure the tag's "key" matches the spelling of previously used identical keys to avoid issues like "order-num", "order_num", "order" meaning the same thing.
tags: valuedate/number/stringThe value of your tag. Insight will try to parse it as a Date, Number or default to String and then stores it in that format for searching.
instance_type_namestring (30 char limit)The name of your Instance Event Type that you are sending. Example: "Barcode read error", "Order Created", "Sample arrived", etc.
timestamptimestamp (optional)If provided, this timestamp will be used for the event's created time. If omitted, Insight will use the time the server receives it.
usernamestring (optional)The user/operator that was involved at the time. Typically, a logged in operator.
display_datastring (optional)Optional text that can be used to display as a tooltip when hovering over this event in a report.

An example of sending an Instance Event.

# Note the trailing / on the end of the URL!
curl -X 'POST' \
  'https://mycompany.myinsights.nz/api/v1/events/' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Token ABCD1234" \
  -d '{
      "instances": [
        {
          "tags": [
            {
              "tag_type_name": "Order Number",
              "value": "OD-123-456"
            },
            {
              "tag_type_name": "Batch",
              "value": "123456"
            }
          ],
          "instance_type_name": "Faulty container",
          "timestamp": "2022-11-02T22:32:14.352Z",
          "username": "Jack Sparrow"
        }
      ]
    }'

Starting Duration Events

The table below describes the basic object structure of the Duration events that you can send.

FieldTypeDescription
durationsobject arrayAt least one duration must be sent.
tagsobject array (optional)Send additional tags along with your event that can be used in reporting later on.
tags: tag_type_namestringThe name of the tag. It's important that your tags all have the same spelling if you want to report on them!
tags: valuestring/number/dateThe value of your tag. Insight will try to parse it and store it as a Date, Number or default to String.
duration_type_namestring (30 char limit)The name of your Duration Event Type that you are sending. Example: "Login", "Idle", "Stacking error", "Processing", etc.
start_timetimestamp (optional)If provided, this timestamp will be used as the start time of the duration. If omitted, you must send the action field with CREATE so the server knows if you are starting a duration. Insight will use the time the server receives it.
end_timetimestamp (optional)If provided, this timestamp will be used as the end time of the duration. If omitted, you must send the action field with END so the server knows if you are ending a duration. Insight will use the time the server receives it.
actionstring (optional)CREATE or END. Used when not sending start_time or end_time.
username_startstring (optional)The user/operator that was involved at the time the duration started. Typically, a logged in operator at the time.
username_endstring (optional)The user/operator that was involved at the time the duration ended. Typically, a logged in operator at the time.
display_datastring (optional)Optional text that can be used to display as a tooltip when hovering over this event in a report.
context_identifierstring (optional)Used when multiple open durations exist for a given Station so that open durations can be identified. Include this in the start and end to identify which duration you want to end.

An example of starting a duration event which we will close next.

# Note the trailing / on the end of the URL!
curl -X 'POST' \
  'https://mycompany.myinsights.nz/api/v1/events/' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Token ABCD1234" \
  -d '{
      "durations": [
        {
          "tags": [
            {
              "tag_type_name": "Order Number",
              "value": "OD-123-456"
            },
            {
              "tag_type_name": "Batch",
              "value": "123456"
            }
          ],
          "duration_type_name": "stoppage",
          "start_time": "2022-11-02T22:32:14.352Z",
          "username_start": "Bob",
          "context_identifier": "12",
        }
      ]
    }'

Ending Duration Events

If multiple durations are opened by a Station and you need to end a specific duration, you need to specify the context_identifier of the Duration you started.

The context_identifier is a way for a Station to keep track of its open durations, so it can end them later. This only has to be unique within this Station's open duration events. context_identifier's can be reused as soon as the duration using that context_identifier on that Station is closed.

# Don't forget the trailing / on the end!
curl -X 'POST' \
  'https://mycompany.myinsights.nz/api/v1/events/' \
  -H 'Content-Type: application/json' \
  -H "Authorization: Token ABCD1234" \
  -d '{
      "durations": [
        {
          "tags": [
            {
              "tag_type_name": "Order Number",
              "value": "OD-123-456"
            },
            {
              "tag_type_name": "Batch",
              "value": "123456"
            }
          ],
          "duration_type_name": "stoppage",
          "end_time": "2022-11-02T22:32:14.352Z",
          "username_end": "Bob",
          "context_identifier": "12",
        }
      ]
    }'

Retrieving a report

Please refer to the API menu within the Insight application for all available API's.

To retrieve a JSON formatted report for one of the created reports on Insight, you can do something like the below where the specific report of interest has an ID of 1.

curl -H "Authorization: Token ABCD1234" https://mycompany.myinsights.nz/api/v1/reports/graphs/1/run/

This will return something similar to the following for a report on Instance:

{
  "title": "My Error Duration Counts",
  "type": "bar",
  "data": {
    "Station 3": {
      "Error X": 4011.0
    },
    "Station 2": {
      "Error X": 2811.0
    },
    "Station 1": {
      "Error X": 1524.0
    }
  },
  "isDuration": false,
  "stackedGroups": false,
  ...
}
Previous
Overview