-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Azure Monitor output plugin #4089
Merged
+1,318
−88
Merged
Changes from 15 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
28bf19d
Add idea for an output that aggregates before adding to metric buffer
danielnelson c092804
Starting on azure monitor metrics integration with MSI auth
f596bd6
Output: Azure Monitor: Initial aggregated metric implementation
gunnaraasen 997ece2
Output: Azure Monitor: Cleanup and add README
gunnaraasen 9bb22cc
Refactor to use AggregatingOutput
gunnaraasen d35c32e
Additional code cleanup
gunnaraasen 82d50e5
Address PR feedback
gunnaraasen 9e12ccf
Refactor authorization to use Azure SDK
gunnaraasen 1560f22
Finish authorization refactor
gunnaraasen 9340102
More refactoring
gunnaraasen 92600fc
Finish auth refactor and address remaining PR feedback
gunnaraasen 6cf2d06
Rename output to azure_monitor along with README updates
gunnaraasen 16afd80
Address PR feedback
gunnaraasen 0255e11
Remove temporarily remove tests to build package
gunnaraasen fb70450
Fix namespace issue
gunnaraasen 55631dd
Remove trailing whitespace
danielnelson acceeef
Add selfstat for metric_outside_window
danielnelson f4b21ca
Adjust spacing in sample config
danielnelson 0052401
Only pull instance metadata if not fully specified
danielnelson 0df4b6b
Add testutils for comparing telegraf.Metric
danielnelson 00c11b9
Add tests for aggregation functions
danielnelson 8e4d345
Add tests for write method of azure monitor output
danielnelson 949bfe9
Use dedicated aggregate type instead of Metric
danielnelson b277b5f
Fix testutil metrics testcase
danielnelson c112dbe
Call Add/Push/Write sequentially
danielnelson a8e8ced
Fix error if tag value is empty
danielnelson 1a7c64b
Update readme
danielnelson ed1f080
Update region list in readme
danielnelson e21494a
Update license of dependencies
danielnelson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
## Azure Monitor Custom Metrics Output for Telegraf | ||
|
||
This plugin will send custom metrics to Azure Monitor. Azure Monitor has a | ||
metric resolution of one minute. To handle this in Telegraf, the Azure Monitor | ||
output plugin will automatically aggregates metrics into one minute buckets, | ||
which are then sent to Azure Monitor on every flush interval. | ||
|
||
The metrics from each input plugin will be written to a separate Azure Monitor | ||
namespace, prefixed with `Telegraf/` by default. The field name for each | ||
metric is written as the Azure Monitor metric name. All field values are | ||
written as a summarized set that includes: min, max, sum, count. Tags are | ||
written as a dimension on each Azure Monitor metric. | ||
|
||
Since Azure Monitor only accepts numeric values, string-typed fields are | ||
dropped by default. There is a configuration option (`strings_as_dimensions`) | ||
to retain fields that contain strings as extra dimensions. Azure Monitor | ||
allows a maximum of 10 dimensions per metric so any dimensions over that | ||
amount will be deterministically dropped. | ||
|
||
## Initial Setup | ||
|
||
1. [Register your Azure subscription with the `microsoft.insights` resource | ||
provider.](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services#portal) | ||
2. [Consult this chart to identify which regions support Azure Monitor.](https://azure.microsoft.com/en-us/global-infrastructure/services/) | ||
3. Only some Azure Monitor regions support Custom Metrics. For regions with | ||
Custom Metrics support, an endpoint will be available with the format | ||
`https://<region>.monitoring.azure.com`. The following regions are | ||
currently known to be supported: | ||
- West Central US, e.g. `https://westcentralus.monitoring.azure.com` | ||
- South Central US, e.g. `https://southcentralus.monitoring.azure.com` | ||
|
||
## Azure Authentication | ||
|
||
This plugin uses one of several different types of authenticate methods. The | ||
preferred authentication methods are different from the *order* in which each | ||
authentication is checked. Here are the preferred authentication methods: | ||
|
||
1. Managed Service Identity (MSI) token | ||
- This is the prefered authentication method. Telegraf will automatically | ||
authenticate using this method when running on Azure VMs. | ||
2. AAD Application Tokens (Service Principals) | ||
- Primarily useful if Telegraf is writing metrics for other resources. [More | ||
information](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects). | ||
- A Service Principal or User Principal needs to be assigned the `Monitoring | ||
Contributor` roles. | ||
3. AAD User Tokens (User Principals) | ||
- Allows Telegraf to authenticate like a user. It is best to use this method | ||
for development. | ||
|
||
The plugin will attempt to authenticate with the first available of the | ||
following configurations in this order: | ||
|
||
1. **Client Credentials**: Azure AD Application ID and Secret. | ||
|
||
Set the following Telegraf configuration variables: | ||
|
||
- `azure_tenant_id`: Specifies the Tenant to which to authenticate. | ||
- `azure_client_id`: Specifies the app client ID to use. | ||
- `azure_client_secret`: Specifies the app secret to use. | ||
|
||
Or set the following environment variables: | ||
|
||
- `AZURE_TENANT_ID`: Specifies the Tenant to which to authenticate. | ||
- `AZURE_CLIENT_ID`: Specifies the app client ID to use. | ||
- `AZURE_CLIENT_SECRET`: Specifies the app secret to use. | ||
|
||
2. **Client Certificate**: Azure AD Application ID and X.509 Certificate. | ||
|
||
- `AZURE_TENANT_ID`: Specifies the Tenant to which to authenticate. | ||
- `AZURE_CLIENT_ID`: Specifies the app client ID to use. | ||
- `AZURE_CERTIFICATE_PATH`: Specifies the certificate Path to use. | ||
- `AZURE_CERTIFICATE_PASSWORD`: Specifies the certificate password to use. | ||
|
||
3. **Resource Owner Password**: Azure AD User and Password. This grant type is | ||
*not recommended*, use device login instead if you need interactive login. | ||
|
||
- `AZURE_TENANT_ID`: Specifies the Tenant to which to authenticate. | ||
- `AZURE_CLIENT_ID`: Specifies the app client ID to use. | ||
- `AZURE_USERNAME`: Specifies the username to use. | ||
- `AZURE_PASSWORD`: Specifies the password to use. | ||
|
||
4. **Azure Managed Service Identity**: Delegate credential management to the | ||
platform. Requires that code is running in Azure, e.g. on a VM. All | ||
configuration is handled by Azure. See [Azure Managed Service | ||
Identity](https://docs.microsoft.com/en-us/azure/active-directory/msi-overview) | ||
for more details. Only available on ARM-based resources. | ||
|
||
**Note: As shown above, the last option (#4) is the preferred way to | ||
authenticate when running Telegraf on Azure VMs. Make sure you've followed the | ||
[initial setup instructions](#initial-setup).** | ||
|
||
## Config | ||
|
||
The plugin will automatically attempt to discover the region and resource ID | ||
using the Azure VM Instance Metadata service. If Telegraf is not running on a | ||
virtual machine or the VM Instance Metadata service is not available, the | ||
following variables are required for the output to function. | ||
|
||
* region | ||
* resource_id | ||
|
||
### Configuration: | ||
|
||
``` | ||
[[outputs.azure_monitor]] | ||
## See the [Azure Monitor output plugin README](/plugins/outputs/azure_monitor/README.md) | ||
## for details on authentication options. | ||
|
||
## Write HTTP timeout, formatted as a string. Defaults to 20s. | ||
#timeout = "20s" | ||
|
||
## Set the namespace prefix, defaults to "Telegraf/<input-name>". | ||
#namespace_prefix = "Telegraf/" | ||
|
||
## Azure Monitor doesn't have a string value type, so convert string | ||
## fields to dimensions (a.k.a. tags) if enabled. Azure Monitor allows | ||
## a maximum of 10 dimensions so Telegraf will only send the first 10 | ||
## alphanumeric dimensions. | ||
#strings_as_dimensions = false | ||
|
||
## *The following two fields must be set or be available via the | ||
## Instance Metadata service on Azure Virtual Machines.* | ||
|
||
## Azure Region to publish metrics against, e.g. eastus, southcentralus. | ||
#region = "" | ||
|
||
## The Azure Resource ID against which metric will be logged, e.g. | ||
## "/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.Compute/virtualMachines/<vm_name>" | ||
#resource_id = "" | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this can you run
telegraf --usage azure_monitor
and use the output (minus the Description text).