Skip to content

Commit

Permalink
feat: Provide support for scraping metrics for Azure Automation (#1464)
Browse files Browse the repository at this point in the history
* Provide configuration

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Support for resource discovery

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Provide validation & scraping

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Assign value to property

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Update guide

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Update changelog

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Fix mapping

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Update guide

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Fix scraper resolution

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Provide docs

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Provide support for specifying the runbook name

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Code quality

* Validate runbook name

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* PR fixes

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Add example config

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Cleanup

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>

* Remove duplicate metric

Signed-off-by: Tom Kerkhove <kerkhove.tom@gmail.com>
  • Loading branch information
tomkerkhove authored Jan 25, 2021
1 parent 5a361d4 commit d16392d
Show file tree
Hide file tree
Showing 30 changed files with 566 additions and 257 deletions.
10 changes: 8 additions & 2 deletions adding-a-new-scraper.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ discuss your scenario_

### Configuration

<!-- markdownlint-disable MD006 -->
<!-- markdownlint-disable MD007 -->
<!-- markdownlint-disable MD013 -->
<!-- markdownlint-disable MD029 -->
<!-- markdownlint-disable MD032 -->
1. Add your new scraping type to the `Promitor.Core.Scraping.Configuration.Model.ResourceType`.
2. Describe the resource for which you're scraping metrics by creating `<New-Type>ResourceDefinition`
and inherit from
Expand All @@ -32,7 +36,9 @@ discuss your scenario_
5. Update `Promitor.Core.Scraping.Configuration.v1.Core.AzureResourceDeserializerFactory`
to handle your new resource type by returning a new instance of the Deserializer
you created in the previous step.
6. Update the `Promitor.Core.Scraping.Configuration.Serialization.v1.Mapping.V1MappingProfile` to handle your new resource type by mapping the `<New-Type>ResourceV1` to `<New-Type>ResourceDefinition` and annotating how to map it to `IAzureResourceDefinition`.
6. Update the `Promitor.Core.Scraping.Configuration.Serialization.v1.Mapping.V1MappingProfile` so that it:
- Is able to map your new resource type by mapping the `<New-Type>ResourceV1` to `<New-Type>ResourceDefinition`
- Annotate how to map it with `IAzureResourceDefinition` (include).
7. Provide a unit test in `.\src\Promitor.Tests.Unit\Serialization\v1\Providers`
that tests the deserialization based on our sample. Your test class must inherit
from `ResourceDeserializerTest` to ensure the inherited functionality is tested.
Expand All @@ -53,7 +59,7 @@ This requires the following steps:
the validation inputs, steps, and outputs typical of validator implementation.
2. Add construction and usage of this validator to `.\src\Promitor.Agents.Scraper\Validation\Factories\MetricValidatorFactory.cs`
for the ResourceType you created in step #1 above.
3. Provide a unit test for every validation rule that was added in `.\src\Promitor.Tests.Unit\Validation\Metrics\ResourceTypes`
3. Provide a unit test for every validation rule that was added in `.\src\Promitor.Tests.Unit\Validation\Scraper\Metrics\ResourceTypes`

### Scraping

Expand Down
8 changes: 8 additions & 0 deletions changelog/content/experimental/unreleased.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
date: 2021-01-01T20:46:47+02:00
weight: 1
version:
---

- {{% tag added %}} Support for scraping Azure Automation account ([docs](https://promitor.io/configuration/v2.x/metrics/automation-account)
| [#352](https://github.com/tomkerkhove/promitor/issues/352))
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ resourceDiscoveryGroups:
type: ApiManagement
- name: app-plan-landscape
type: AppPlan
- name: automation-accounts
type: AutomationAccount
- name: container-instances
type: ContainerInstance
- name: container-registry-landscape
Expand Down
11 changes: 0 additions & 11 deletions config/promitor/scraper/contrib/README.md

This file was deleted.

71 changes: 0 additions & 71 deletions config/promitor/scraper/contrib/cosmosdb.yaml

This file was deleted.

35 changes: 0 additions & 35 deletions config/promitor/scraper/contrib/keyvault.yaml

This file was deleted.

55 changes: 0 additions & 55 deletions config/promitor/scraper/contrib/storage-blob.yaml

This file was deleted.

71 changes: 0 additions & 71 deletions config/promitor/scraper/contrib/vmss.yaml

This file was deleted.

38 changes: 37 additions & 1 deletion config/promitor/scraper/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,40 @@ metrics:
resources:
- resourceUri: Microsoft.Insights/Components/docker-hub-metrics
resourceGroupName: docker-hub-metrics
filter: dependency/resultCode eq '200'
filter: dependency/resultCode eq '200'
- name: promitor_demo_automation_job_count
description: "Amount of jobs per Azure Automation account"
resourceType: AutomationAccount
azureMetricConfiguration:
metricName: TotalJob
aggregation:
type: Total
resourceDiscoveryGroups:
- name: automation-accounts
resources:
- resourceGroupName: promitor-sources
accountName: promitor-sandbox
- name: promitor_demo_automation_update_deployment_runs
description: "Amount of jobs per Azure Automation account"
resourceType: AutomationAccount
azureMetricConfiguration:
metricName: TotalUpdateDeploymentRuns
aggregation:
type: Total
resourceDiscoveryGroups:
- name: automation-accounts
resources:
- resourceGroupName: promitor-sources
accountName: promitor-sandbox
- name: promitor_demo_automation_update_deployment_machine_runs
description: "Amount of jobs per Azure Automation account"
resourceType: AutomationAccount
azureMetricConfiguration:
metricName: TotalUpdateDeploymentMachineRuns
aggregation:
type: Total
resourceDiscoveryGroups:
- name: automation-accounts
resources:
- resourceGroupName: promitor-sources
accountName: promitor-sandbox
45 changes: 45 additions & 0 deletions docs/configuration/v2.x/metrics/automation-account.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
layout: default
title: Azure Automation Account Declaration
---

## Azure Automation account

![Availability Badge](https://img.shields.io/badge/Available%20Starting-v2.1-green.svg)![Resource Discovery Support Badge](https://img.shields.io/badge/Support%20for%20Resource%20Discovery-Yes-green.svg)

You can scrape an Azure Automation account via the `AutomationAccount`
resource type.

The following fields need to be provided:

- `accountName` - The name of the Azure Automation account.
- `runbookName` - The name of the runbook. (optional and only supported on limited metrics)

All supported metrics are documented in the official [Azure Monitor documentation](https://docs.microsoft.com/en-us/azure/azure-monitor/platform/metrics-supported#microsoftautomationautomationaccounts).

The following scraper-specific metric label will be added :

- `runbook_name` - Name of the runbook

Example:

```yaml
name: promitor_demo_automation_job_count
description: "Amount of jobs per Azure Automation account & job"
resourceType: AutomationAccount
azureMetricConfiguration:
metricName: TotalJob
aggregation:
type: Total
resources:
- resourceGroupName: promitor-sources
accountName: promitor-sandbox
runbookName: Example # Optional, currently only supported for 'TotalJob' metric
resourceDiscoveryGroups: # Optional, requires Promitor Resource Discovery agent (https://promitor.io/concepts/how-it-works#using-resource-discovery)
- name: automation-accounts
```
<!-- markdownlint-disable MD033 -->
[&larr; back to metrics declarations](/configuration/v2.x/metrics)<br />
[&larr; back to introduction](/)
<!-- markdownlint-enable -->
1 change: 1 addition & 0 deletions docs/configuration/v2.x/resource-discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Dynamic resource discovery is supported for the following scrapers:
- [Azure API Management](metrics/api-management)
- [Azure Application Gateway](metrics/application-gateway)
- [Azure App Plan](metrics/app-plan)
- [Azure Automation](metrics/automation-account)
- [Azure Cache for Redis](metrics/redis-cache)
- [Azure Container Instances](metrics/container-instances)
- [Azure Container Registry](metrics/container-registry)
Expand Down
Loading

0 comments on commit d16392d

Please sign in to comment.