Skip to content

Comments

Add Azure Dynamic Tags Support via AzureTagger Processor#1998

Draft
Paramadon wants to merge 13 commits intomainfrom
paramadon/Compass
Draft

Add Azure Dynamic Tags Support via AzureTagger Processor#1998
Paramadon wants to merge 13 commits intomainfrom
paramadon/Compass

Conversation

@Paramadon
Copy link
Contributor

Add Azure Dynamic Tags Support via AzureTagger Processor

Problem

CloudWatch Agent supports dynamic tag fetching on AWS via the ec2tagger processor, which retrieves instance tags from EC2 and adds them as metric dimensions. Azure VMs have tags available through IMDS, but there's no equivalent processor to fetch and apply these tags to metrics at runtime.

Solution

Introduce an azuretagger processor that mirrors the ec2tagger pattern for Azure environments. The processor fetches VM tags from Azure IMDS at startup and optionally refreshes them periodically, adding them as dimensions to metrics flowing through the pipeline.

Architecture

Data Flow:

  1. Metrics enter pipeline from receivers (cpu, mem, disk, etc.)
  2. azuretagger processor intercepts metrics
  3. Processor calls CMCA.GetTags() to get cached Azure tags
  4. Tags added as dimensions to each metric datapoint
  5. Enriched metrics sent to CloudWatch exporter

Tag Source:

  • Azure IMDS endpoint: 169.254.169.254/metadata/instance/compute?tagsList
  • No API calls required - tags exposed directly via local metadata service
  • No IAM/RBAC permissions needed (unlike AWS ec2:DescribeTags)

Key Design Decisions:

DecisionRationale
Separate processor (not extend ec2tagger)Clean separation of cloud-specific logic; easier to maintain
Uses CMCA providerConsistent with multi-cloud architecture; no duplicate IMDS calls
Tags from IMDS (no API calls)Azure exposes tags directly via IMDS; no IAM/RBAC required
Optional periodic refreshTags can change; configurable interval (default: disabled)
Graceful degradationProcessor starts even if tags unavailable; logs warning

Changes

New AzureTagger Processor (plugins/processors/azuretagger/)

  • azuretagger.go - Main processor: fetches tags from CMCA, adds to metrics
  • config.go - Configuration: metadata tags, instance tag keys, refresh interval
  • factory.go - OTel processor factory registration
  • constants.go - Azure-specific dimension keys (InstanceId, VMScaleSetName, etc.)
  • *_test.go - Unit tests for all components

Azure Provider Enhancement (internal/cloudmetadata/azure/)

  • Added StartRefreshLoop() method for periodic metadata refresh
  • Supports background tag updates without blocking the main agent

Component Registration (service/defaultcomponents/)

  • Registered azuretagger factory in processor list
  • Updated component tests

Translator (translator/translate/otel/processor/azuretaggerprocessor/)

  • Config translator for azuretagger processor
  • Maps JSON config to OTel processor config

Comparison with ec2tagger

Aspectec2tagger (AWS)azuretagger (Azure)
Tag sourceEC2 API (DescribeTags)IMDS (tagsList)
IAM requiredYes (ec2:DescribeTags)No
Network callYes (EC2 API)No (local IMDS)
ASG equivalentAutoScalingGroupNameVMScaleSetName
Account IDAWS Account IDAzure Subscription ID

Testing

Unit Tests

  • Processor initialization (with/without provider, Azure/non-Azure)
  • Tag filtering (specific keys vs wildcard *)
  • Metric attribute updates (existing values not overwritten)
  • Refresh loop (context cancellation, shutdown)
  • All metric types (Gauge, Sum, Histogram, ExponentialHistogram)

Manual Verification

  • Azure VM (eastus2): Tags fetched from IMDS, processor starts successfully
  • Build verification: make build, make lint, go test ./... all pass
  • Race detection: Clean under -race flag

Future Work

  • Pipeline integration: Update host/jmx translators to use azuretagger when on Azure
  • EntityStore integration: Add Azure entity support for Compass

Paramadon and others added 11 commits January 22, 2026 16:28
Rename unused 'r' parameter to '_' in TestProvider_Refresh_Timeout
to satisfy revive linter.
The return statement in InitGlobalProvider was reading globalErr
without holding the lock, causing a race with concurrent readers.
sync.Once cannot be safely reset while concurrent Do() calls may be
in progress. Replace with atomic uint32 flag and double-checked locking
pattern, which allows safe reset from tests without racing.
- Reset global provider in TestTranslator to ensure test uses mock metadata
- Update placeholderUtil tests to use SetGlobalProviderForTest instead of
  relying on legacy fallback path which doesn't work on Azure
- Skip TestGetMetadataInfo_FallbackToLegacy on Azure since azure.IsAzure()
  takes precedence over the legacy fallback path
The test was resetting the global provider but then calling GetMetadataInfo
which falls through to the Azure path on Azure CI runners. Now we set the
mock provider first so GetMetadataInfo uses it instead of Azure IMDS.
@Paramadon Paramadon changed the title Paramadon/compass Add Azure Dynamic Tags Support via AzureTagger Processor Jan 27, 2026
@Paramadon Paramadon added the ready for testing Indicates this PR is ready for integration tests to run label Jan 27, 2026
- Add azuretagger processor mirroring ec2tagger pattern
- Add StartRefreshLoop to Azure provider for tag refresh
- Add ScalingGroupName to MockProvider
- Register azuretagger in default components
- Add translator for azuretagger processor
- Remove non-code files (PR_DESCRIPTION.md, MERGE_CHECKLIST.md)
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

This PR was marked stale due to lack of activity.

@github-actions github-actions bot added the Stale label Feb 4, 2026
Copy link
Contributor

@jefchien jefchien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions github-actions bot removed the Stale label Feb 10, 2026
@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity.

@github-actions github-actions bot added the Stale label Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for testing Indicates this PR is ready for integration tests to run Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants