Skip to content

Discover AWS/Bedrock application inference profiles for tag/name enrichment - #1913

Open
AdilKh4n wants to merge 2 commits into
prometheus-community:masterfrom
AdilKh4n:bedrock-inference-profile-tags
Open

Discover AWS/Bedrock application inference profiles for tag/name enrichment#1913
AdilKh4n wants to merge 2 commits into
prometheus-community:masterfrom
AdilKh4n:bedrock-inference-profile-tags

Conversation

@AdilKh4n

Copy link
Copy Markdown

Summary

AWS/Bedrock has no ResourceFilters entry in pkg/config/services.go, so the tagging client's resourcegroupstaggingapi-based discovery (pkg/clients/tagging/client.go) never runs for it (if len(svc.ResourceFilters) > 0). As a result, AWS/Bedrock metrics are always emitted with:

  • Empty tag_* labels, regardless of exportedTagsOnMetrics configuration
  • A name="global" label, since no resource is ever associated to the metric

This is easy to reproduce: configure exportedTagsOnMetrics.AWS/Bedrock with any tag key, scrape AWS/Bedrock metrics, and the resulting tag_* label value is always "".

Unlike most namespaces, Bedrock application inference profile tags aren't reliably obtainable through the tagging API in a way that also carries the profile's human-readable name (InferenceProfileName), which isn't part of the ARN. So instead of adding ResourceFilters, this PR adds a dedicated ServiceFilter (see the existing AWS/StorageGateway entry for precedent) that:

  • Calls bedrock:ListInferenceProfiles directly to discover inference profiles
  • Calls bedrock:ListTagsForResource per profile to fetch tags (best-effort: SYSTEM_DEFINED profiles are AWS-owned and don't support tagging, so a failed call is treated as "no tags" rather than aborting discovery)
  • Sets the resource's ARN field to "<profile-id>/<profile-name>" instead of the real ARN (same trick AWS/StorageGateway uses with "<gateway-id>/<gateway-name>"), since CloudWatch's ModelId dimension for these metrics is the bare profile ID, not the full ARN. This lets the ModelId dimension regex match the id prefix while the profile's name still ends up in the metric's name label instead of "global".

Changes

  • pkg/config/services.go: drop ResourceFilters from AWS/Bedrock, update the DimensionRegexps entry to match the new <id>/<name> scheme
  • pkg/clients/tagging/filters.go: add a ServiceFilter for AWS/Bedrock
  • pkg/clients/tagging/adapters.go, client.go: wire up a bedrock client adapter, following the existing closure-based adapter pattern
  • pkg/clients/factory.go: construct the *bedrock.Client
  • pkg/promutil/prometheus.go: add BedrockAPICounter scrape metric
  • pkg/job/maxdimassociator/associator_bedrock_test.go: new associator test covering the match/skip cases
  • README.md: document the new bedrock:ListInferenceProfiles / bedrock:ListTagsForResource IAM permissions
  • go.mod/go.sum: add github.com/aws/aws-sdk-go-v2/service/bedrock (minor patch bumps to aws-sdk-go-v2 core and smithy-go came along via go mod tidy)

Test plan

  • go build ./...
  • go vet ./...
  • go test ./... (all packages pass)
  • Verified against a real account: the previously-broken tag_app label (added via exportedTagsOnMetrics) and name label are both populated correctly once this discovery path runs

…chment

AWS/Bedrock had no ResourceFilters entry, so the tagging client's
resourcegroupstaggingapi-based discovery never ran for it: metrics were
always emitted with empty tag_* labels and a "global" name label,
regardless of exportedTagsOnMetrics config.

Application inference profile tags aren't reliably surfaced through the
tagging API in a way that also carries the profile's human-readable name,
so this adds a dedicated ServiceFilter that calls bedrock:ListInferenceProfiles
and bedrock:ListTagsForResource directly, similar to the existing
AWS/StorageGateway resource discovery. The resource's ARN field is
repurposed to "<profile-id>/<profile-name>" so the ModelId dimension
regex still matches while the name label becomes human-readable instead
of "global".

Signed-off-by: Adil Khan <adikhan@adobe.com>
@AdilKh4n
AdilKh4n force-pushed the bedrock-inference-profile-tags branch from b11d642 to 38eafba Compare July 31, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant