Azure IoT Hub Streaming, Analytics, Alerts generation
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.github
.vscode
Services.Test
Services
StreamingAgent.Test
StreamingAgent
WebService.Test
WebService
scripts
.gitattributes
.gitignore
.travis.yml
CONTRIBUTING.md
DEVELOPMENT.md
LICENSE
README.md
telemetry-agent.sln
telemetry-agent.sln.DotSettings

README.md

Build Issues Gitter

Telemetry Agent Overview

This service analyzes the telemetry stream, stores messages from Azure IoT Hub to DocumentDb, and generates alerts according to defined rules. The IoT stream is analyzed using a set of rules defined in the Telemetry service, and generates "alarms" when a message matches some of these rules. The alarms are also stored in DocumentDb.

We provide also a Java version of this project.

Dependencies

How to use the microservice

Quickstart - Running the service with Docker

  1. Install Docker Compose: https://docs.docker.com/compose/install
  2. Create an instance of an Azure IoT Hub
  3. Store the "IoT Hub" connection string in the env-vars-setup script.
  4. Open a terminal console into the project folder, and run these commands to start the Telemetry Agent service
    cd scripts
    env-vars-setup      // (Bash users: ./env-vars-setup).  This script creates your env. variables
    cd docker
    docker-compose up
    

The Docker compose configuration requires the dependencies resolved and environment variables set as described previously. You should now start seeing the stream content in the console.

Running the service with Visual Studio or VS Code

  1. Install .NET Core 2.x
  2. Install any recent edition of Visual Studio (Windows/MacOS) or Visual Studio Code (Windows/MacOS/Linux).
  3. Open the solution in Visual Studio or VS Code.
  4. Define the following environment variables. See Configuration and Environment variables for detailed information for setting these for your enviroment.
    1. PCS_IOTHUB_CONNSTRING = {your Azure IoT Hub connection string}
    2. PCS_IOTHUB_PARTITIONS = {your Azure IoT Hub partitions count}
    3. PCS_STORAGEADAPTER_WEBSERVICE_URL = http://localhost:9022/v1
    4. etc...
  5. Start the WebService project (e.g. press F5).
  6. Use an HTTP client such as Postman, to exercise the RESTful API.

Configuration and Environment variables

The service configuration is accessed via ASP.NET Core configuration adapters, and stored in appsettings.ini. The INI format allows to store values in a readable format, with comments.

The configuration also supports references to environment variables, e.g. to import credentials and network details. Environment variables are not mandatory though, you can for example edit appsettings.ini and write credentials directly in the file. Just be careful not sharing the changes, e.g. sending a Pull Request or checking in the changes in git.

The configuration file in the repository references some environment variables that need to be defined. Depending on the OS and the IDE used, there are several ways to manage environment variables.

  1. If you're using Visual Studio (Windows/MacOS), the environment variables are loaded from the project settings. Right click on WebService, and select Options/Properties, and find the section with the list of env vars. See WebService/Properties/launchSettings.json.
  2. Visual Studio Code (Windows/MacOS/Linux) loads the environment variables from .vscode/launch.json
  3. When running the service with Docker or from the command line, the application will inherit environment variables values from the system.

Contributing to the solution

Please follow our contribution guildelines. We love PRs too.

Troubleshooting

Feedback

Please enter issues, bugs, or suggestions as GitHub Issues here