GithubHelp home page GithubHelp logo

azure-samples / iot-telemetry-simulator Goto Github PK

View Code? Open in Web Editor NEW
66.0 22.0 47.0 315 KB

The IoT Telemetry Simulator allows you to test Azure IoT Hub or Eventhub ingestion at scale. The implementation is communicating with Azure IoT Hub using multiplexed AMQP connections. An automation library allows you to run it as load test as part of a CI/CD pipeline.

License: MIT License

PowerShell 1.14% Batchfile 0.53% Shell 0.50% C# 95.82% Dockerfile 0.92% Mustache 1.09%
azure-iot csharp iot-telemetry-simulator

iot-telemetry-simulator's Introduction

page_type languages products name urlFragment description
sample
csharp
powershell
dockerfile
azure-iot-hub
azure-event-hubs
azure-container-instances
azure-container-registry
Azure IoT Device Telemetry Simulator
azure-iot-device-telemetry-simulator
The IoT Telemetry Simulator allows you to test Azure IoT Hub, Event Hub or Kafka ingestion at scale.

Master test and push

Azure IoT Device Telemetry Simulator

The IoT Telemetry Simulator allows you to test Azure IoT Hub, Event Hub or Kafka ingestion at scale. The implementation is communicating with Azure IoT Hub using multiplexed AMQP connections. An automation library allows you to run it as load test as part of a CI/CD pipeline.

A single AMQP connection can handle approximately 995 devices.

Quick Start

The quickest way to generate telemetry is using Docker with the following command:

docker run -it -e "IotHubConnectionString=HostName=your-iothub-name.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=your-iothub-key" mcr.microsoft.com/oss/azure-samples/azureiot-telemetrysimulator

The simulator expects the devices to already exist in Azure IoT Hub. If you need help creating simulation devices in an Azure IoT Hub use the included project IotSimulatorDeviceProvisioning or the Docker image:

docker run -it -e "IotHubConnectionString=HostName=your-iothub-name.azure-devices.net;SharedAccessKeyName=registryReadWrite;SharedAccessKey=your-iothub-key" -e DeviceCount=1000 mcr.microsoft.com/oss/azure-samples/azureiot-simulatordeviceprovisioning

Simulator input parameters

The amount of devices, their names and telemetry generated can be customized using parameter. The list below contains the supported configuration parameters:

Name Description
IotHubConnectionString Iot Hub connection string. "Device" our "Iot Hub owner" scopes are good. Example: HostName=your-iothub-name.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=your-iothub-key
EventHubConnectionString Event Hub connection string. SAS Policy "Send" is required. For EventHub no device registration is required. Example: Endpoint=sb://your-eventhub-namespace.servicebus.windows.net/;SharedAccessKeyName=send;SharedAccessKey=your-send-sas-primary-key;EntityPath=your-eventhub-name.
KafkaConnectionProperties Kafka connection properties as a JSON string. Example: {"bootstrap.servers=kafka"}.
KafkaTopic Kafka topic name.
DeviceList comma separated list of device identifiers (default = ""). Use it to generate telemetry for specific devices instead of numeric generated identifiers. If the parameter has a value the following parameters are ignored: DevicePrefix, DeviceIndex and DeviceCount are ignored
DevicePrefix device identifier prefix (default = "sim")
DeviceIndex starting device number (default = 1)
DeviceCount amount of simulated devices (default = 1)
MessageCount amount of messages to send by device (default = 10). Set to zero if you wish to send messages until cancelled
Interval interval between each message in milliseconds (default = 1000)
Template telemetry payload template (see telemetry template)
FixPayload fix telemetry payload in base64 format. Use this setting if the content of the message does not need to change
FixPayloadSize fix telemetry payload size (in bytes). Use this setting if the content of the message does not need to change (will be an array filled with zeros)
PayloadDistribution Allows the generation of payloads based on a distribution
Example: "fixSize(10, 12) template(25, default) fix(65, aaaaBBBBBCCC)" generates 10% a fix payload of 10 bytes, 25% a template generated payload and 65% of the time a fix payload from values aaaaBBBBBCCC
Header telemetry header template (see telemetry template)
PartitionKey optional partition key template for Event Hubs (see telemetry template and Advanced options)
Variables telemetry variables (see telemetry template)
DuplicateEveryNEvents if > 0, send duplicates of the given fraction of messages. See Advanced options (default = 0)
File Defines a json file where templates, variables and device based intervals can be defined. File and environment variable configuration can be used in conjunction.
Intervals Allows customizing the intervals between messages per device. If an array is given, its elements are iterated one after another, so the interval can vary for the same device. The array is cycled when there's more values to send than elements in it.

Telemetry template

The simulator is able to create user customizable telemetry with dynamic variables (random, counter, time, unique identifier, value range).

To generate a custom piece of telemetry it is required to set the template and, optionally, variables.

The template defines how the telemetry looks like, having placeholders for variables. Variables are declared in the telemetry as $.VariableName. The optional header defines properties that will be transmitted as message properties.

Variables are declared defining how values in the template will be resolved.

Built-in variables

The following variables are provided out of the box:

Name Description
DeviceId Outputs the device identifier
Guid A unique identifier value
Time Outputs the utc time in which the telemetry was generated in ISO 8601 format
LocalTime Outputs the local time in which the telemetry was generated in ISO 8601 format
Ticks Outputs the ticks in which the telemetry was generated
Epoch Outputs the time in which the telemetry was generated in epoch format (seconds)
MachineName Outputs the machine name where the generator is running (pod name if running in Kubernetes)

Customizable variables

Customizable variables can be created with the following properties:

Name Description
name Name of the property. Defines what will be replaced in the template telemetry $.Name
random Make the value random, limited by min and max
step If the value is not random, will be incremented each time by the value of step
randomDouble Make the value random and double, limited by min and max
min For random (integer or double) values defines it's minimum. Otherwise, will be the starting value
max The maximum value generated
values Defines an array of possible values. Example ["on", "off"]
customlengthstring Creates a random string of n bytes. Provide n as parameter
sequence Create a sequence of values as defined in values property, producing one after the other. Values can reference other non-sequence variables

Example 1: Telemetry with temperature between 23 and 25 and a counter starting from 100

Template:

{ "deviceId": "$.DeviceId", "rand_int": $.Temp, "rand_double": $.DoubleValue, "Ticks": $.Ticks, "Counter": $.Counter, "time": "$.Time" }

Variables:

[{"name": "Temp", "random": true, "max": 25, "min": 23}, {"name":"Counter", "min":100, "max":102}, {"name": "DoubleValue", "randomDouble":true, "min":0.22, "max":1.25}]

Output:

{ "deviceId": "sim000001", "rand_int": 23, "rand_double": 0.207759137669466, "Ticks": 637097550115091350, "Counter": 100, "time": "2019-11-19T10:10:11.5091350Z" }
{ "deviceId": "sim000001", "rand_int": 23, "rand_double": 1.207232427664231, "Ticks": 637097550115952079, "Counter": 101, "time": "2019-11-19T10:10:11.5952079Z" }
{ "deviceId": "sim000001", "rand_int": 24, "rand_double": 0.992871827638167, "Ticks": 637097550116627320, "Counter": 102, "time": "2019-11-19T10:10:11.6627320Z" }
{ "deviceId": "sim000001", "rand_int": 24, "rand_double": 0.779288272162327, "Ticks": 637097550117027320, "Counter": 100, "time": "2019-11-19T10:10:11.7027320Z" }

Running with Docker:

docker run -it -e "IotHubConnectionString=HostName=your-iothub-name.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=your-iothub-key" -e Template="{ \"deviceId\": \"$.DeviceId\", \"rand_int\": $.Temp, \"rand_double\": $.DoubleValue, \"Ticks\": $.Ticks, \"Counter\": $.Counter, \"time\": \"$.Time\" }" -e Variables="[{name: \"Temp\", \"random\": true, \"max\": 25, \"min\": 23}, {\"name\":\"Counter\", \"min\":100, \"max\":102} ]" mcr.microsoft.com/oss/azure-samples/azureiot-telemetrysimulator

calling from PowerShell:

docker run -it -e "IotHubConnectionString=HostName=your-iothub-name.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=your-iothub-key" -e Template="{ \"""deviceId\""": \"""$.DeviceId\""", \"""rand_int\""": $.Temp, \"""rand_double\""": $.RandomDouble , \"""Ticks\""": $.Ticks, \"""Counter\""": $.Counter, \"""time\""": \"""$.Time\""", \"""engine\""": \"""$.Engine\""" }" -e Variables="[{name: \"""Temp\""", \"""random\""": true, \"""max\""": 25, \"""min\""": 23}, {\"""name\""":\"""Counter\""", \"""min\""":100, \"""max\""":102}, {name:\"""Engine\""", values: [\"""on\""", \"""off\"""]}]" -e DeviceCount=1 -e MessageCount=3 mcr.microsoft.com/oss/azure-samples/azureiot-telemetrysimulator

Example 2: Adding the engine status ("on" or "off") to the telemetry

Template:

{ "deviceId": "$.DeviceId", "rand_int": $.Temp, "Ticks": $.Ticks, "Counter": $.Counter, "time": "$.Time", "engine": "$.Engine" }

Variables:

[{"name": "Temp", "random": true, "max": 25, "min": 23}, {"name":"Counter", "min":100}, {"name": "Engine", "values": ["on", "off"]}]

Output:

{ "deviceId": "sim000001", "rand_int": 23, "Ticks": 637097644549666920, "Counter": 100, "time": "2019-11-19T12:47:34.9666920Z", "engine": "off" }
{ "deviceId": "sim000001", "rand_int": 24, "Ticks": 637097644550326096, "Counter": 101, "time": "2019-11-19T12:47:35.0326096Z", "engine": "on" }

Running with Docker:

docker run -it -e "IotHubConnectionString=HostName=your-iothub-name.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=your-iothub-key" -e Template="{ \"deviceId\": \"$.DeviceId\", \"rand_int\": $.Temp, \"Ticks\": $.Ticks, \"Counter\": $.Counter, \"time\": \"$.Time\", \"engine\": \"$.Engine\" }" -e Variables="[{name: \"Temp\", \"random\": true, \"max\": 25, \"min\": 23}, {\"name\":\"Counter\", \"min\":100}, {name:\"Engine\", values: [\"on\", \"off\"]}]" mcr.microsoft.com/oss/azure-samples/azureiot-telemetrysimulator

Example 3: Using a configuration file to customize simulation

docker run -it -e "IotHubConnectionString=HostName=your-iothub-name.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=your-iothub-key" -e "File=/config_files/test4-config-multiple-internals-per-device.json" -e DeviceCount=3 --mount type=bind,source=$pwd\test\IotTelemetrySimulator.Test\test_files,target=/config_files,readonly mcr.microsoft.com/oss/azure-samples/azureiot-telemetrysimulator

Where the file content is:

{
  "Variables": [
    {
      "name": "DeviceSequenceValue1",
      "sequence": true,
      "values": [ "$.Counter", "$.Counter", "$.Counter", "$.Counter", "$.Counter", "true", "false", "$.Counter" ]
    },
    {
      "name": "Device1Tags",
      "sequence": true,
      "values": [ "['ProducedPartCount']", "['ProducedPartCount']", "['ProducedPartCount']", "['ProducedPartCount']", "['ProducedPartCount']", "['Downtime']", "['Downtime']", "['ProducedPartCount']" ]
    },
    {
      "name": "Device1Downtime",
      "values": [ "true", "true", "true", "true", "false" ]
    },
    {
      "name": "Counter"
    }
  ],
  "Intervals": {
    "sim000001": 10000,
    "sim000002": [ 100 , 200 ]
  },
  "Payloads": [
    {
      "type": "template",
      "deviceId": "sim000001",
      "template": "{\"device\":\"$.DeviceId\",\"value\":\"$.DeviceSequenceValue1\",\"tags\": $.Device1Tags}"
    },
    {
      "type": "fix",
      "deviceId": "sim000002",
      "value": "{\"value\":\"myfixvalue\"}"
    },
    {
      "type": "template",
      "deviceId": "sim000003",
      "template": "{\"device\":\"$.DeviceId\",\"a\":\"b\",\"value\":\"$.DeviceSequenceValue1\"}"
    }
  ]
}

Generating high volume of telemetry

In order to generate a constant high volume of messages a single computer might not be enough. This section describes two way to run the simulator to ingest a high volume of messages

Azure Container Instance

Azure has container instances which allow the execution of containers with micro billing. This repository has a PowerShell script that creates azure container instances in your subscription. Requirements are having az cli installed.

To start the simulator in a single container instance:

.\SimulatorCloudRunner.ps1

You will be asked to enter the Azure IoT Hub Connection string. After that, a resource group and one or more container instances will be created.

The cloud runner can be customized with the following parameters (as -ParameterName ParameterValue):

Name Description
Location Location of the resource group being created. (Default = westeurope). For a list of locations try az account list-locations -o table
ResourceGroup Resource group (will be created if it does not exist) where container instances will be created. (Default = iothubsimulator)
DeviceCount Total amout of devices (Default = 100)
ContainerCount Total amount of container instances to create. The total DeviceCount will be divided among all instances (Default = 1)
MessageCount Total amount of messages to send per device. 0 means no limit, causing the container to never end. It is your job to stop and delete it! (Default = 100)
Intervals Interval in which each device will send messages in milliseconds (Default = 1000). Provide a comma separated list in case intervals change after each message.
Template Telemetry payload template to be used
(Default = '{ "deviceId": "$.DeviceId", "temp": $.Temp, "Ticks": $.Ticks, "Counter": $.Counter, "time": "$.Time", "engine": "$.Engine", "source": "$.MachineName" }')
PayloadDistribution Allows the generation of payloads based on a distribution
Example: "fixSize(10, 12) template(25, default) fix(65, aaaaBBBBBCCC)" generates 10% a fix payload of 10 bytes, 25% a template generated payload and 65% of the time a fix payload from values aaaaBBBBBCCC
Header Header properties template to be used
(Default = '')
Variables Variables used to create the telemetry
(Default = '[{name: "Temp", random: true, max: 25, min: 23}, {name:"Counter", min:100}, {name:"Engine", values: ["on", "off"]}]')
Cpu Amount of cpus allocated to each container instance (Default = 1.0)
IotHubConnectionString Azure Iot Hub connection string

Kubernetes

This repository also contains a helm chart to deploy the simulator to a Kubernetes cluster. An example release with helm for 5000 devices in 5 pods:

helm install sims iot-telemetry-simulator\. --namespace iotsimulator --set iotHubConnectionString="HostName=xxxx.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=xxxxxxx" --set replicaCount=5 --set deviceCount=5000

Automation

The IotTelemtrySimulator.Automation .NET Core 2.1 library allows you to run the IoT Telemetry Simulator as part of a pipeline or any other automation framework. See the automation guide.

Advanced options

  • PartitionKey option for Event Hubs: When processing events downstream with a distributed engine, it is often more efficient to have related messages in the same partition. For example, if computing values over windows of events per device in Spark, having all the events for a given device in the same partition ensures they are received by a single compute node and ordered. On the other hand, the default round-robin behavior has advantages too, such as ensuring all partitions have equal load and that the system remains available even if a partition fails. Therefore, it is good to give the user control over the partition key.
  • DuplicateEvery option to duplicate events: Upstream systems generating events usually offer at-least-once delivery guarantees. Given that there is no mechanism in IoT Hub / Event Hubs for distributed transactions, it is always possible for the client not to receive the response from the server after sending a message, or crashing before persisting the response, and therefore to retry sending an event. This results in message duplicates. When testing event processing solution, it's important to inject such behavior so as to test if/how the system reacts to it, e.g. by deduplication. The option DuplicateEvery allows randomly duplicating a fraction of messages, e.g. setting DuplicateEvery to 1000 will duplicate messages with a probability of 1/1000 for each, i.e. will duplicate on average every 1000th message. Note that messages may be duplicated more than once: a message will be duplicated N times with a probability of 1/(DuplicateEvery)^N.

iot-telemetry-simulator's People

Contributors

algattik avatar fbeltrao avatar gukoff avatar lauradamiantna avatar martin-weber avatar microsoft-github-operations[bot] avatar microsoftopensource avatar nikosksygkis avatar techpreacher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iot-telemetry-simulator's Issues

Feature Request: Multi platform build for docker images

Please provide us with the following information:

This issue is for a: (mark with an x)

- [] bug report -> please search issues before submitting
- [x] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Running the docker image on Arm64 Architecture (e.g. M1 Mac) does not work

docker run --platform linux/amd64 -it -e "IotHubConnectionString='HostName=HQ-Dev-IoT-Hub.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=85o1yfMXqxigSMC4nO0OVts0ZerAk2tvqEVUu+gu038='" mcr.microsoft.com/oss/azure-samples/azureiot-telemetrysimulator

Any log messages given by the failure

Unhandled exception. System.IO.IOException: Function not implemented
at System.IO.FileSystemWatcher.StartRaisingEvents()
at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration1..ctor(Func1 changeTokenProducer, Action1 changeTokenConsumer, TState state) at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func1 changeTokenProducer, Action changeTokenConsumer)
at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider..ctor(JsonConfigurationSource source)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at IotTelemetrySimulator.Program.<>c.b__1_0(IConfigurationBuilder builder) in /src/src/IotTelemetrySimulator/Program.cs:line 23
at Microsoft.Extensions.Hosting.HostingHostBuilderExtensions.<>c__DisplayClass6_0.b__0(HostBuilderContext context, IConfigurationBuilder builder)
at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at IotTelemetrySimulator.Program.Main(String[] args) in /src/src/IotTelemetrySimulator/Program.cs:line 12
qemu: uncaught target signal 6 (Aborted) - core dumped

Expected/desired behavior

The simulator should connect to my IoTHub and send the data samples

OS and Version?

macOS Ventura 13.4.1 (m1)

Versions

1.15.0

Mention any other details that might be useful

Can successfully build and run locally and can docker build and push to my ACR repo and successfully pull and run.


Thanks! We'll be in touch soon.

Co-related Telemetry

Team,

We're using this telemetry simulator to simulate one of the machines which have some values like Motor Speed, Belt Speed, and more.

And My Question is -
Is there any way that we can simulate the co-related values?
For example -

  1. The belt speed is co-related to Motor Speed. If the motor speed increases, how can we increase the belt speed as well?

Thanks

typo for utf8 of content encoding

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Set up routing in IoT Hub
Run the simulator and send telemetry to IoT Hub
It won't be routed as expected.

To fix the issue, i need to change the value below from "utf8" to "utf-8"
https://github.com/Azure-Samples/Iot-Telemetry-Simulator/blob/master/src/IotTelemetrySimulator/IotHubSender.cs#L12

[Nice To Have] Be able to use a counter inside and outside a sequence

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Define the following variables:
counter_1, counter_2, counter_3: counters
seq1: [ counter_1, counter_2, counter_3 ]
seq2: [ counter_2, counter_1 ]

Define the template:
{ v1: seq_1, v2: seq_2, v3: counter_3 }

The value of v3 will be "$.counter_3" as we don't support using a counter inside and outside a sequence.

Expected/desired behavior

Same variable can be used inside and outside a sequence.

Zeros produced instead of random values

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Ran the dockerhub image with:

DeviceCount=1000
DeviceIndex=0
Template={ "eventId": "$.Guid", "complexData": { "moreData0": $.moreData00, "moreData1": $.moreData01, "moreData2": $.moreData02, "moreData3": $.moreData03, "moreData4": $.moreData04, "moreData5": $.moreData05, "moreData6": $.moreData06, "moreData7": $.moreData07, "moreData8": $.moreData08, "moreData9": $.moreData09, "moreData10": $.moreData10, "moreData11": $.moreData11, "moreData12": $.moreData12, "moreData13": $.moreData13, "moreData14": $.moreData14, "moreData15": $.moreData15, "moreData16": $.moreData16, "moreData17": $.moreData17, "moreData18": $.moreData18, "moreData19": $.moreData19 }, "value": $.value, "deviceId": "$.DeviceId", "deviceSequenceNumber": $.Counter, "type": "$.type", "createdAt": "$.Time" }
Interval=1000
DevicePrefix=contoso-device-id-
MessageCount=0
Variables=[ {"name": "value", "random": true}, {"name": "moreData00", "random": true}, {"name": "moreData01", "random": true}, {"name": "moreData02", "random": true}, {"name": "moreData03", "random": true}, {"name": "moreData04", "random": true}, {"name": "moreData05", "random": true}, {"name": "moreData06", "random": true}, {"name": "moreData07", "random": true}, {"name": "moreData08", "random": true}, {"name": "moreData09", "random": true}, {"name": "moreData10", "random": true}, {"name": "moreData11", "random": true}, {"name": "moreData12", "random": true}, {"name": "moreData13", "random": true}, {"name": "moreData14", "random": true}, {"name": "moreData15", "random": true}, {"name": "moreData16", "random": true}, {"name": "moreData17", "random": true}, {"name": "moreData18", "random": true}, {"name": "moreData19", "random": true}, {"name": "Counter", "min": 0}, {"name": "type", "values": ["TEMP", "CO2"]} ]
IotHubConnectionString=HostName=iot-xxxx.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=xxxx

Accessing the IoT Hub Event Hubs endpoint shows a mixture of events with properly populated random values, and events where all random values are 0:

Received event from partition: 3.
{ body: '{
    "eventId": "1be879b9-0b32-4026-97aa-aafc38ddfbf1",
    "complexData": {
        "moreData0": 176772633,
        "moreData1": 1713618591,
        "moreData2": 851733976,
        "moreData3": 1045725759,
        "moreData4": 814559650,
        "moreData5": 698850308,
        "moreData6": 1227999053,
        "moreData7": 1833559892,
        "moreData8": 229729420,
        "moreData9": 703205628,
        "moreData10": 1724511707,
        "moreData11": 576329261,
        "moreData12": 783146766,
        "moreData13": 1257494123,
        "moreData14": 339609237,
        "moreData15": 1538624322,
        "moreData16": 634618423,
        "moreData17": 789017563,
        "moreData18": 1310816339,
        "moreData19": 1813005905
    },
    "value": 476772162,
    "deviceId": "contoso-device-id-000547",
    "deviceSequenceNumber": 38,
    "type": "TEMP",
    "createdAt": "2021-01-01T06:58:00.7419466Z"
}
', properties: {}, offset: 2486798103976, sequence_number: 16522817, enqueued_time=datetime.datetime(2021, 1, 1, 6, 58, 0, 744000, tzinfo=datetime.timezone.utc) }
Received event from partition: 1.
{ body: '{
    "eventId": "3c4dd67c-e782-4d00-be7f-5ac4f079c31f",
    "complexData": {
        "moreData0": 0,
        "moreData1": 0,
        "moreData2": 0,
        "moreData3": 0,
        "moreData4": 0,
        "moreData5": 0,
        "moreData6": 0,
        "moreData7": 0,
        "moreData8": 0,
        "moreData9": 0,
        "moreData10": 0,
        "moreData11": 0,
        "moreData12": 0,
        "moreData13": 0,
        "moreData14": 0,
        "moreData15": 0,
        "moreData16": 0,
        "moreData17": 0,
        "moreData18": 0,
        "moreData19": 0
    },
    "value": 0,
    "deviceId": "contoso-device-id-000363",
    "deviceSequenceNumber": 47,
    "type": "TEMP",
    "createdAt": "2021-01-01T06:58:11.2374109Z"
}
'

OS and Version?

Current Dockerhub image

Versions

Mention any other details that might be useful

This is probably related to sharing a single Random instance in the TelemetryValues class

https://stackoverflow.com/questions/3049467/is-c-sharp-random-number-generator-thread-safe

No, using the same instance from multiple threads can cause it to break and return all 0's.

does 'Interval' parameter works?

Please provide us with the following information:

This issue is for Interval parameter: (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

docker run -it -e "IotHubConnectionString=HostName=your-iothub-name.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=your-iothub-key" mcr.microsoft.com/oss/azure-samples/azureiot-telemetrysimulator -e Interval=30000 -e DeviceList="mydevice"

Any log messages given by the failure

No errors but printing message shows Interval = System.Int32[]ms and the message is sending at 1000ms rate.

Expected/desired behavior

message sending at 30s interval.

OS and Version?

Windows 11, Docker Desktop

Versions

Latest

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Support Managed Identities to connect to EventHub

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

Managed identities can be used to authenticate the Telemetry Simulator with Event Hub.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Support Managed Identities to connect to IoT Hub and Kafka

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

Managed identities can be used to authenticate the Telemetry Simulator with IoT Hub and Kafka.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

TemplateVariableSubstitutionTest.GetTestData() fails when run on a system configured to use anything else but "." as decimal separator

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

TemplateVariableSubstitutionTest.GetTestData() fails when run on a system configured to use anything else but "." as a decimal separator as the expected result is as string has a hard-coded "." in $"Hello, World! I like some_data, -0.5 and , World.".

Expected/desired behavior

This needs to be a double cast to a string by the system that's running the test so the decimal separator gets replaced with the proper symbol.

OS and Version?

Windows 10 set to Greek Date/Time/Number formats.


Thanks! We'll be in touch soon.

Low performance on the templates with lots of variables

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Try using a 256KB template with 1000 variables. The simulator will be very slow, generating 1-2 messages per second.

Root cause

Building a message from the template T and variables V has the complexity of O(T * V) because of this loop:
https://github.com/Azure-Samples/Iot-Telemetry-Simulator/blob/master/src/IotTelemetrySimulator/TelemetryTemplate.cs#L34-L37

We can make it O(T + V) if we format the template in one go instead going through a loop.

Example solutions

1. Preprocess the template, make it aware of the future arguments.

E.g. turn "abc$.Variable1def" into a structure like ["abc", (variables => variables["Variable1"]), "def"].
This will make formatting it using a dictionary of variables an easy task.

C#'s composite formatting works in a similar fashion.

2. Precompile a regular expression to substitute the variables in one go.

This regex would have to match all variable names. Here's an example: https://stackoverflow.com/a/1231815/2116625

Our case is more complicated than this example because the variables are only tokenized from the left by the $. and not from the right. Understanding what the variable name is in the string like abc$.Variable1def is harder than if it were abc$.(Variable1)def or if there was a restriction that a variable name in the template can't be followed by a \w symbol.

[CSS] Throttling during provisioning

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [X] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Run the following command
docker run -it -e "IotHubConnectionString=[redacted]" -e DeviceCount=1000 mcr.microsoft.com/oss/azure-samples/azureiot-simulatordeviceprovisioning

Provisioning crashes with a ThrottlingBacklogTimeout that causes the script to stop running.

Any log messages given by the failure

PS C:\Users\kyichii>
Starting device provisioning
2021-10-12T07:17:21.6511837Z: 100 devices have been created @ 63.20/sec
2021-10-12T07:17:21.8319529Z: 200 devices have been created @ 553.18/sec
Microsoft.Azure.Devices.Common.Exceptions.ThrottlingException: {"Message":"ErrorCode:ThrottlingBacklogTimeout;The request has been throttled. Wait 10 seconds and try again. Operation type: CRUD","ExceptionMessage":"Tracking ID:55f0784980964ecf83ec9bf4cce2bc7c-G:0-TimeStamp:10/12/2021 07:18:02"}
at Microsoft.Azure.Devices.HttpClientHelper.ExecuteAsync(HttpClient httpClient, HttpMethod httpMethod, Uri requestUri, Func3 modifyRequestMessageAsync, Func2 isMappedToException, Func3 processResponseMessageAsync, IDictionary2 errorMappingOverrides, CancellationToken cancellationToken)
at Microsoft.Azure.Devices.HttpClientHelper.ExecuteAsync(HttpMethod httpMethod, Uri requestUri, Func3 modifyRequestMessageAsync, Func3 processResponseMessageAsync, IDictionary2 errorMappingOverrides, CancellationToken cancellationToken) at Microsoft.Azure.Devices.HttpClientHelper.PostAsync[T1,T2](Uri requestUri, T1 entity, IDictionary2 errorMappingOverrides, IDictionary2 customHeaders, CancellationToken cancellationToken) at IotSimulatorDeviceProvisioning.Program.BulkCreateDevicesAsync(List1 devices, RegistryManager registryManager, DeviceProvisionStats stats) in /src/src/IotSimulatorDeviceProvisioning/Program.cs:line 163
Microsoft.Azure.Devices.Common.Exceptions.ThrottlingException: {"Message":"ErrorCode:ThrottlingBacklogTimeout;The request has been throttled. Wait 10 seconds and try again. Operation type: CRUD","ExceptionMessage":"Tracking ID:3ea3022e253e4d7b95ae629f77c7c403-G:0-TimeStamp:10/12/2021 07:18:02"}
at Microsoft.Azure.Devices.HttpClientHelper.ExecuteAsync(HttpClient httpClient, HttpMethod httpMethod, Uri requestUri, Func3 modifyRequestMessageAsync, Func2 isMappedToException, Func3 processResponseMessageAsync, IDictionary2 errorMappingOverrides, CancellationToken cancellationToken)
at Microsoft.Azure.Devices.HttpClientHelper.ExecuteAsync(HttpMethod httpMethod, Uri requestUri, Func3 modifyRequestMessageAsync, Func3 processResponseMessageAsync, IDictionary2 errorMappingOverrides, CancellationToken cancellationToken) at Microsoft.Azure.Devices.HttpClientHelper.PostAsync[T1,T2](Uri requestUri, T1 entity, IDictionary2 errorMappingOverrides, IDictionary2 customHeaders, CancellationToken cancellationToken) at IotSimulatorDeviceProvisioning.Program.BulkCreateDevicesAsync(List1 devices, RegistryManager registryManager, DeviceProvisionStats stats) in /src/src/IotSimulatorDeviceProvisioning/Program.cs:line 163
Microsoft.Azure.Devices.Common.Exceptions.ThrottlingException: {"Message":"ErrorCode:ThrottlingBacklogTimeout;The request has been throttled. Wait 10 seconds and try again. Operation type: CRUD","ExceptionMessage":"Tracking ID:474cf77e1c214b409f7429e4ed439825-G:0-TimeStamp:10/12/2021 07:18:02"}
at Microsoft.Azure.Devices.HttpClientHelper.ExecuteAsync(HttpClient httpClient, HttpMethod httpMethod, Uri requestUri, Func3 modifyRequestMessageAsync, Func2 isMappedToException, Func3 processResponseMessageAsync, IDictionary2 errorMappingOverrides, CancellationToken cancellationToken)
at Microsoft.Azure.Devices.HttpClientHelper.ExecuteAsync(HttpMethod httpMethod, Uri requestUri, Func3 modifyRequestMessageAsync, Func3 processResponseMessageAsync, IDictionary2 errorMappingOverrides, CancellationToken cancellationToken) at Microsoft.Azure.Devices.HttpClientHelper.PostAsync[T1,T2](Uri requestUri, T1 entity, IDictionary2 errorMappingOverrides, IDictionary2 customHeaders, CancellationToken cancellationToken) at IotSimulatorDeviceProvisioning.Program.BulkCreateDevicesAsync(List1 devices, RegistryManager registryManager, DeviceProvisionStats stats) in /src/src/IotSimulatorDeviceProvisioning/Program.cs:line 163
Microsoft.Azure.Devices.Common.Exceptions.ThrottlingException: {"Message":"ErrorCode:ThrottlingBacklogTimeout;The request has been throttled. Wait 10 seconds and try again. Operation type: CRUD","ExceptionMessage":"Tracking ID:a6b0b0fd21ab40c0a341fbe65a366d54-G:0-TimeStamp:10/12/2021 07:18:02"}
at Microsoft.Azure.Devices.HttpClientHelper.ExecuteAsync(HttpClient httpClient, HttpMethod httpMethod, Uri requestUri, Func3 modifyRequestMessageAsync, Func2 isMappedToException, Func3 processResponseMessageAsync, IDictionary2 errorMappingOverrides, CancellationToken cancellationToken)
at Microsoft.Azure.Devices.HttpClientHelper.ExecuteAsync(HttpMethod httpMethod, Uri requestUri, Func3 modifyRequestMessageAsync, Func3 processResponseMessageAsync, IDictionary2 errorMappingOverrides, CancellationToken cancellationToken) at Microsoft.Azure.Devices.HttpClientHelper.PostAsync[T1,T2](Uri requestUri, T1 entity, IDictionary2 errorMappingOverrides, IDictionary2 customHeaders, CancellationToken cancellationToken) at IotSimulatorDeviceProvisioning.Program.BulkCreateDevicesAsync(List1 devices, RegistryManager registryManager, DeviceProvisionStats stats) in /src/src/IotSimulatorDeviceProvisioning/Program.cs:line 163

Expected/desired behavior

This should not crash when throttling. Ideally it would allow us to set the SKU rate for the IoT Hub to avoid the throttling all together and test provisioning at the maximum limits of a specific iot hub

OS and Version?

Windows 10

Versions

Latest

Mention any other details that might be useful

This is behavior that inconsistently crashes but consistently throttles on lower end IoT Hub due to the registry operations. I am also attempting to get some additional logs from customers that are encountering the same issuje.

Azure IoT Hub stress testing issues

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

  1. We could only generate 259 IoT Hub identities when we ran the docker container "azureiot-simulatordeviceprovisioning" as given in the document.
  1. Running the "azureiot-telemetrysimulator" docker container could only generate 70 odd messages. Got an error while sending telemetry.

  2. When we ran the AZ Cli script as mentioned in "Generating high volume of telemetry" section of the doc it didn't generate any load (~ 70 messages is what we see in IoT Hub usage.

Any log messages given by the failure

Screenshot from 2021-06-25 19-15-13

Expected/desired behavior

We expected to see 1000 device identities in IoT Hub and a huge traffic from the devices.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)
Ran this from my Ubuntu 20.04

Versions

We used the latest version of this tool

Mention any other details that might be useful

--------------------------------------------------------------- We are trying to do a Stress testing on our Azure IoT Hub.
Thanks! We'll be in touch soon.

Support IoTHub MQTT protocol in device simulator

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

Support IoTHub MQTT protocol to allow simulating devices that use that protocol.

OS and Version?

N/A

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

When reading config from a file, Simulator should emulate all devices specified times device count.

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

When reading the configuration from a file, the Iot Telemetry Simulator should emulate all devices specified times the device count defined in the env vars (Default=1).

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.