Flask "To-Do" Sample Application

Setup

  1. This package is not hosted on Pypi. You can install all dependencies locally using pip install -r azure_monitor/flask_sample/requirements.txt.
  2. To send telemetry to Azure Monitor, pass in your instrumentation key into INSTRUMENTATION_KEY in config.py.
INSTRUMENTATION_KEY = <your-ikey-here>

The default database URI links to a sqlite database app.db. To configure a different database, you can modify config.py and change the SQLALCHEMY_DATABASE_URI value to point to a database of your choosing.

SQLALCHEMY_DATABASE_URI = <your-database-URI-here>

Usage

  1. Navigate to where azure_monitor\flask_sample is located.
  2. Run the main application via python sample.py.
  3. Hit your local endpoint (should be http://localhost:5000). This should open up a browser to the main page.
  4. On the newly opened page, you can add tasks via the textbox under Add a new todo item:. You can enter any text you want (cannot be blank).
  5. Click Add Item to add the task. The task will be added under Incomplete Items. Adding an item with greater than 10 characters will generate an error.
  6. To utilize the Save to File feature, run the endpoint application via python endpoint.py. This will run another Flask application with a WSGI server running on http://localhost:5001. Click Save to File and all tasks will be written to a file file.txt in the output folder.
  7. Each task has a Mark As Complete button. Clicking it will move the task from incomplete to completed.

Types of telemetry sent

There are various types of telemetry that are being sent in the sample application. Refer to Telemetry Type in Azure Monitor. Every button click hits an endpoint that exists in the flask application, so they will be treated as incoming requests (requests table in Azure Monitor). A log message is also sent every time a button is clicked, so a log telemetry is sent (traces table in Azure Monitor). An exception telemetry is sent when an invalid task is entered (greater than 10 characters).