Skip to content

Commit

Permalink
docs(azure): update readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
manushak committed Feb 26, 2024
1 parent ab272e9 commit 0ce3083
Showing 1 changed file with 45 additions and 52 deletions.
97 changes: 45 additions & 52 deletions src/lib/azure-importer/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Azure-importer

> [!NOTE] > `Azure Importer` is an unofficial, not part of the IF standard library. This means the IF core team are not closely monitoring these models to keep them up to date. You should do your own research before implementing them!
> [!NOTE] > `Azure Importer` is an unofficial, not part of the IF standard library. This means the IF core team are not closely monitoring these plugins to keep them up to date. You should do your own research before implementing them!
The Azure importer model allows you to provide some basic details about an Azure virtual machine and automatically populate your `impl` with usage metrics that can then be passed along a model pipeline to calculate energy and carbon impacts.
The Azure importer plugin allows you to provide some basic details about an Azure virtual machine and automatically populate your `manifest` with usage metrics that can then be passed along a plugin pipeline to calculate energy and carbon impacts.

## Prerequisites

Expand Down Expand Up @@ -63,103 +63,96 @@ AZURE_CLIENT_ID: <your-client-id>
AZURE_CLIENT_SECRET: <your-client-secret>
```

## Inputs

All that remains is to provide the details about your virtual machine in the `inputs` field in your `impl`.
These are the required fields:
## Node config

- `timestamp`: An ISO8601 timestamp indicating the start time for your observation period. We work out your `timespan` by adding `duration` to this initial start time.
- `duration`: Number of seconds your observation period should last. We add this number of seconds to `timestamp` to work out when your observation period should stop.
- `azure-observation-window`: The time interval between measurements (temporal resolution) as a string with a value and a unit, e.g. `5 mins`. The value and unit must be space-separated.
- `azure-observation-aggregation`: This indicates how you want metrics to be aggregated between each `interval`. The recommended default is `average`.
- `azure-subscription-id`: Your Azure subscription ID, e.g. 9cf5e19b-8b18-4c37-9541-55fc47ad70c3
- `azure-resource-group`: Your Azure resource group name
- `azure-vm-name`: Your virtual machine name

These are all provided as `inputs`. You also need to instantiate an `azure-importer` model to handle the Azure-specific `input` data. Here's what a complete `impl` could look like:
## Inputs

All that remains is to provide the details about your virtual machine in the `inputs` field in your `manifest`.
These are the required fields:

- `timestamp`: An ISO8601 timestamp indicating the start time for your observation period. We work out your `timespan` by adding `duration` to this initial start time.
- `duration`: Number of seconds your observation period should last. We add this number of seconds to `timestamp` to work out when your observation period should stop.

These are all provided as `inputs`. You also need to instantiate an `azure-importer` plugin to handle the Azure-specific `input` data. Here's what a complete `manifest` could look like:

```yaml
name: azure-demo
description: example impl invoking Azure model
description: example manifest invoking Azure plugin
initialize:
models:
- name: azure-importer
model: AzureImporterModel
path: '@grnsft/if-unofficial-models'
graph:
plugins:
azure-importer:
method: AzureImporter
path: '@grnsft/if-unofficial-plugins'
tree:
children:
child:
pipeline:
- azure-importer
config:
azure-importer:
inputs:
- timestamp: '2023-11-02T10:35:31.820Z'
duration: 3600
azure-observation-window: 5 min
azure-observation-aggregation: 'average'
azure-subscription-id: 9cf5e19b-8b18-4c37-9541-55fc47ad70c3
azure-resource-group: my_group
azure-vm-name: my_vm
inputs:
- timestamp: '2023-11-02T10:35:31.820Z'
duration: 3600
```
This will grab Azure metrics for `my_vm` in `my_group` for a one hour period beginning at 10:35 UTC on 2nd November 2023, at 5 minute resolution, aggregating data occurring more frequently than 5 minutes by averaging.

## Outputs

The Azure importer model will enrich your `impl` with the following data:
The Azure importer plugin will enrich your `manifest` with the following data:

- `duration`: the per-input duration in seconds, calculated from `azure-observation-window`
- `cpu-util`: percentage CPU utilization
- `cloud-instance-type`: VM instance name
- `cpu/utilization`: percentage CPU utilization
- `cloud/instance-type`: VM instance name
- `location`: VM region
- `mem-availableGB`: Amount of memory _not_ in use by your application, in GB.
- `mem-usedGB`: Amount of memory being used by your application, in GB. Calculated as the difference between `total-memoryGB` and `memory-availableGB`.
- `total-memoryGB`: The total memory allocated to your virtual machine, in GB.
- `mem-util`: memory utilized, expressed as a percentage (`memory-usedGB`/`total-memoryGB` \* 100)
- `memory/available/GB`: Amount of memory _not_ in use by your application, in GB.
- `memory/used/GB`: Amount of memory being used by your application, in GB. Calculated as the difference between `memory/capacity/GB` and `memory/available/GB`.
- `memory/capacity/GB`: The total memory allocated to your virtual machine, in GB.
- `memory/utilization`: memory utilized, expressed as a percentage (`memory-usedGB`/`memory/capacity/GB` \* 100)

These can be used as inputs in other models in the pipeline. Typically, the `instance-type` can be used to obtain `tdp` data that can then, along with `cpu-util`, feed a model such as `teads-curve`.
These can be used as inputs in other plugins in the pipeline. Typically, the `instance-type` can be used to obtain `tdp-finder` data that can then, along with `cpu/utilization`, feed a plugin such as `teads-curve`.

The outputs look as follows:

```yaml
outputs:
- timestamp: '2023-11-02T10:35:00.000Z'
duration: 300
azure-observation-window: 5 min
azure-observation-aggregation: 'average'
azure-subscription-id: 9cf5e19b-8b18-4c37-9541-55fc47ad70c3
azure-resource-group: my_group
azure-vm-name: my_vm
cpu-util: '0.314'
mem-availableGB: 0.488636416
mem-usedGB: 0.5113635839999999
total-memoryGB: '1'
mem_util: 51.13635839999999
cpu/utilization: '0.314'
memory/available/GB: 0.488636416
memory/used/GB: 0.5113635839999999
memory/capacity/GB: '1'
memory/utilization: 51.13635839999999
location: uksouth
cloud-instance-type: Standard_B1s
cloud/instance-type: Standard_B1s
- timestamp: '2023-11-02T10:40:00.000Z'
duration: 300
azure-observation-window: 5 min
azure-observation-aggregation: 'average'
azure-subscription-id: 9cf5e19b-8b18-4c37-9541-55fc47ad70c3
azure-resource-group: my_group
azure-vm-name: my_vm
cpu-util: '0.314'
mem-availableGB: 0.48978984960000005
mem-usedGB: 0.5102101504
total-memoryGB: '1'
mem_util: 51.021015039999995
cpu/utilization: '0.314'
memory/available/GB: 0.48978984960000005
memory/used/GB: 0.5102101504
memory/capacity/GB: '1'
memory/utilization: 51.021015039999995
location: uksouth
cloud-instance-type: Standard_B1s
cloud/instance-type: Standard_B1s
```

You can run this example `impl` by saving it as `./examples/impls/test/azure-importer.yml` and executing the following command from the project root:
You can run this example `manifest` by saving it as `./examples/manifests/test/azure-importer.yml` and executing the following command from the project root:

```sh
npm i -g @grnsft/if
npm i -g @grnsft/if-unofficial-models
impact-engine --impl ./examples/impls/test/azure-importer.yml --ompl ./examples/ompls/azure-importer.yml
npm i -g @grnsft/if-unofficial-plugins
if --manifest ./examples/manifests/test/azure-importer.yml --output ./examples/outputs/azure-importer.yml
```

The results will be saved to a new `yaml` file in `./examples/ompls`.
The results will be saved to a new `yaml` file in `./examples/outputs`.

0 comments on commit 0ce3083

Please sign in to comment.