Skip to content

feat: add SessionName and Tags support for STS AssumeRole - #76

Merged
SuperQ merged 2 commits into
prometheus:mainfrom
dongjiang1989:add-rolesessionname
Aug 31, 2026
Merged

feat: add SessionName and Tags support for STS AssumeRole#76
SuperQ merged 2 commits into
prometheus:mainfrom
dongjiang1989:add-rolesessionname

Conversation

@dongjiang1989

Copy link
Copy Markdown
Member

Add optional SessionName and Tags fields to SigV4Config to enable per-caller identity attribution (RoleSessionName) and cost allocation session tags when assuming IAM roles via STS. This mirrors the capability introduced in agentgateway PR #2435, enabling AWS billing chargeback by team/tenant/environment for Prometheus remote write traffic through assumed roles.

  • SessionName validated against AWS constraints: ^[\w+=,.@-]{2,64}$
  • Tags validated: key ≤ 128, value ≤ 256, both require role_arn
  • SessionName and Tags threaded through to stscreds.AssumeRoleProvider
  • New unit tests cover YAML parsing, validation boundary conditions, and end-to-end STS AssumeRole request body verification via mock server

Add optional SessionName and Tags fields to SigV4Config to enable
per-caller identity attribution (RoleSessionName) and cost allocation
session tags when assuming IAM roles via STS. This mirrors the
capability introduced in agentgateway PR #2435, enabling AWS billing
chargeback by team/tenant/environment for Prometheus remote write
traffic through assumed roles.

- SessionName validated against AWS constraints: ^[\w+=,.@-]{2,64}$
- Tags validated: key ≤ 128, value ≤ 256, both require role_arn
- SessionName and Tags threaded through to stscreds.AssumeRoleProvider
- New unit tests cover YAML parsing, validation boundary conditions,
  and end-to-end STS AssumeRole request body verification via mock server

Signed-off-by: dongjiang <dongjiang1989@126.com>

@SuperQ SuperQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@SuperQ
SuperQ merged commit 7ada2b7 into prometheus:main Aug 31, 2026
4 checks passed
@dongjiang1989
dongjiang1989 deleted the add-rolesessionname branch August 31, 2026 08:42
dongjiang1989 added a commit to dongjiang1989/prometheus that referenced this pull request Sep 2, 2026
Bump github.com/prometheus/sigv4 from v0.4.1 to v0.5.0, which adds
SessionName and Tags fields for STS AssumeRole (prometheus/sigv4#76).
The updated NewSigV4RoundTripper signature uses variadic options and
remains backward-compatible with existing callers.

Document the new session_name and tags fields, along with the previously
undocumented service_name field, in both the alertmanager and
remote_write sigv4 configuration blocks.

Also replace the deprecated expfmt.Negotiate call in web/federate.go
with the explicit expfmt.NegotiateAccept form to satisfy staticcheck.

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
dongjiang1989 added a commit to dongjiang1989/prometheus that referenced this pull request Sep 2, 2026
Bump github.com/prometheus/sigv4 from v0.4.1 to v0.5.0.

The new release adds SessionName and Tags fields for STS AssumeRole
(prometheus/sigv4#76). The updated NewSigV4RoundTripper signature uses
variadic options and remains backward-compatible, so no Prometheus code
changes are required beyond the version bump.

service_name was already part of the struct in v0.4.1 but was missing
from the documentation — it is now documented alongside the new fields.

Also replace deprecated expfmt.Fmt* constants with expfmt.NewFormat
(expfmt.Type*) in web/federate.go to fix the SA1019 staticcheck failure
introduced by the prometheus/common v0.71.0 transitive bump.

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
dongjiang1989 added a commit to dongjiang1989/alertmanager that referenced this pull request Sep 2, 2026
- Update github.com/prometheus/sigv4 from v0.4.1 to v0.5.0
- Add support for new SessionName field (maps to AWS RoleSessionName)
- Add support for new Tags field (maps to STS session tags for cost allocation)
- Both fields require role_arn and are passed to STS AssumeRole
- Add comprehensive AWS STS tag validation:
  * Call sigv4.Validate() for field-level validation
  * Enforce 50-tag limit (AWS STS maximum)
  * Reject reserved 'aws:' prefix in tag keys
- Add test cases for all validation rules
- Update documentation with AWS constraints

This mirrors the capability from prometheus/sigv4#76, enabling AWS billing
chargeback by team/tenant/environment for SNS notifications through assumed roles.

Signed-off-by: dongjiang1989 <dongjiang1989@126.com>
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.

2 participants