Piipan subsystem for monitoring other subsystems
The metrics/src
directory contains:
- Metrics API Library - data models and API interfaces
- Metrics Core Library - logic and data access layer
- Metrics API Function App - serves metrics data to external systems
- Metrics Collect Function App - monitors other subsystems and stores metrics data
The Metrics API is a Function App made up of Azure HTTPTrigger event functions.
For now, there's a 1-1 relationship between an API endpoint and a function within this app.
Metrics Collect is an Azure Function App made up of Azure Event Grid event functions.
For now, there's a 1-1 relationship between a specific metric needing to be captured and a function within this app.
The following environment variables are required by both the Metrics Functions and Metrics API apps and are set by the IaC:
Name | |
---|---|
DatabaseConnectionString |
details |
CloudName |
details |
KeyVaultName |
details |
Local development is currently limited as a result of using a managed identity to connect to the metrics database. The Instance Metadata Service used by managed identities to retrieve authentication tokens is not available locally. There are potential solutions using the Microsoft.Azure.Services.AppAuthentication
library. None have been implemented at this time.
The app will still build and run locally. However, any valid request sent to the local endpoint will result in an exception when the app attempts to retrieve an access token. Invalid requests (e.g., malformed or missing data in the request body) will return proper error responses.
To build and run the app with this limited functionality:
- Fetch any app settings using
func azure functionapp fetch-app-settings {app-name}
. The app name can be retrieved from the Portal. - Run
func start
or, if hot reloading is desired,dotnet watch msbuild /t:RunFunctions
.
Each project in the Piipan.Metrics
subsystem has a dedicated test project in the metrics/tests
directory.
To execute tests for the subsystem as a whole:
$ cd metrics
$ dotnet test
To execute tests for a particular subsystem project:
$ cd metrics/tests/Piipan.Metrics.<*>.Tests
$ dotnet test