Rody
Rody

Reputation: 2655

Azure Streaming Analytics, constant flow of output events

I have a sensor which sends data from IOT Hub to Streaming Analytics only on a pulse, not on a regular interval.

I want to calculate the times that pulse is send in a certain time frame, i.e. last 10 minutes.

I have very simple packets like this:

{
    "Timestamp": "2017-10-26T13:27:11.1103973",
    "Pulses": 1
}

Those are send, let's say 3 times in a 10 minute time frame. I use the following Stream Analytics query:

SELECT
    SUM(Pulses) as Pulses,
    System.Timestamp AS WindowEnd
INTO
    [RawData-10-Minutes]
FROM
    [Input]
GROUP BY
    HoppingWindow(Duration(minute, 10), Hop(minute, 1))

This works very good. I get a nice flow of data every 1 minute with the total of pulses per last 10 minutes:

[
    {
        "pulses": 2.0,
        "windowend": "1970-01-01T12:02:00.0000000Z"
    },
    {
        "pulses": 2.0,
        "windowend": "1970-01-01T12:03:00.0000000Z"
    },
    {
        "pulses": 3.0,
        "windowend": "1970-01-01T12:04:00.0000000Z"
    }
]

However when there are no pulses for 10 minutes, I would expect I still receive summation values of 0 pulses every minute. However that is not the case.

The problem with this is, that I am showing a "Last Value" on a Power BI report, which shows: X pulses in last 10 minutes. However when there are no pulses, the value stays at the last result, which is incorrect.

Is it possible to send a regular stream of data from Stream Analytics per minute, even without incoming messages?

Upvotes: 0

Views: 221

Answers (1)

Vignesh Chandramohan
Vignesh Chandramohan

Reputation: 1306

Producing output without input events is not possible as of now. To achieve above scenario, you could either emit "heartbeat" events that are guaranteed to be there every minute in the same stream [or] have a different stream for heartbeats and left join with that stream. In both these cases, we are forcing an input event to be there every minute.

Another option is to handle this in the output datasource if it supports it. For example, if you know the rate of arrival you could write a query that treats lack of row after certain amount of time as "zero".

Upvotes: 3

Related Questions