azure-timeseries-insights

How to setup Azure Time Series Insights to receive and visualise boolean data?


I'm currently sending data via EventHub to Time Series Insight with the help of following classes serialised to JSON:

public class DataItemBase
{
    public string VariableName { get; set; }
    public string SystemId { get; set; }
    public string DeviceTimestamp { get; set; }
}

public class DataItemDouble : DataItemBase
{
    public double Value { get; set; }
}

public class DataItemBool : DataItemBase
{
    public bool Value { get; set; }
}

The data is received ok and is easily queryable when the value is double. However, I am unable to display the data when it's received as boolean. The value column is marked as (T/F) which seems to indicate that TSI understand the received data format correctly. Received boolean data

The question is, how to display this boolean data on the TSI online viewer? For a reference, this is the link to Microsofts Contonso example environment: https://insights.timeseries.azure.com/preview/samples

I suspect this is all up to assign the instance with a correct type, in the environment. I have created DeviceData type which is assigned to the TSI instance. This DeviceData type has a property named NumericData with $event['value'].Double definition. This works as expected, however I don't seem to find a similar solution for the boolean values.


Solution

  • Only numeric data can be plotted in the TSI Explorer, so in order to display a chart with your boolean values you can create a Type variable with a conversion function in the Time Series Expression to cast the bool to a long or a double toDouble($event.value.Bool)

    You might want to create a categorical variable to have True/False labeled and select custom colors

    "Status": {
    "kind": "categorical",
      "value": {
     "tsx": "toLong($event.value.Bool)"},
      "interpolation": {
        "kind": "step",
        "boundary": {
          "span" : "PT1M"
        }
      },
      "categories": [
        {
          "values": [0],
          "label": "False"
        },
        {
          "values": [1],
          "label": "True"
        }
      ],
      "defaultCategory": {
        "label": "Not Applicable"
      }
    }