Skip to content

Conversation

@mariomac
Copy link
Contributor

Enables BEYLA_PROMETHEUS_EXTRA_RESOURCE_ATTRIBUTES to provide a list of additional resource attributes to be added to the reported target_info metric, in Prometheus.

Due to internal limitations of the Prometheus API client, Beyla needs to know beforehand which attributes are exposed
for each metric. This would cause that some attributes that are discovered at runtime, during instrumentation, won't
be visible by default. For example, attributes defined on each application via Kubernetes annotations, or in the
target application's OTEL_RESOURCE_ATTRIBUTES environment variable.

For example, an application defining the OTEL_RESOURCE_ATTRIBUTES=deployment.environment=production as environment
variable, the target_info{deployment.environment="production"} attribute would be visible by default if the metrics
are exported via OpenTelemetry but not if they are exported via Prometheus.

To make deployment_environment visible in Prometheus, you need to add it to the extra_resource_attributes list.

@mariomac mariomac requested review from a team and grafsean as code owners March 13, 2025 14:39
Copy link
Contributor

@marctc marctc left a comment

Choose a reason for hiding this comment

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

LGTM!

@github-actions
Copy link
Contributor

This PR must be merged before a backport PR will be created.

@codecov
Copy link

codecov bot commented Mar 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.96%. Comparing base (6e7397a) to head (6b9188c).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1742      +/-   ##
==========================================
+ Coverage   65.84%   66.96%   +1.12%     
==========================================
  Files         214      214              
  Lines       22225    22241      +16     
==========================================
+ Hits        14634    14894     +260     
+ Misses       6855     6609     -246     
- Partials      736      738       +2     
Flag Coverage Δ
integration-test 54.17% <100.00%> (+0.04%) ⬆️
k8s-integration-test 54.04% <100.00%> (+0.13%) ⬆️
oats-test 34.83% <0.00%> (?)
unittests 43.85% <44.44%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@rafaelroquetto rafaelroquetto left a comment

Choose a reason for hiding this comment

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

Gnarly!

@mariomac
Copy link
Contributor Author

Merging due to some urgency from affected users. @grafsean feel free to suggest any correction to the docs and I'll address them in another PR before merging 2.0 backport.

@mariomac mariomac merged commit 7dbd664 into grafana:main Mar 14, 2025
16 checks passed
@mariomac mariomac deleted the extra-res-attrs branch March 14, 2025 11:43
github-actions bot pushed a commit that referenced this pull request Mar 14, 2025
* Allow defining extra resource labels in prometheus

* reformat

(cherry picked from commit 7dbd664)
@github-actions
Copy link
Contributor

The backport to release-2.0 failed:

Validation Failed: "Could not resolve to a node with the global id of 'T_kwDOAG3Mbc4AssrW'."

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-1742-to-release-2.0 origin/release-2.0
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 7dbd6642d73037e08de54f4f44d2caf7731cdf68

When the conflicts are resolved, stage and commit the changes:

git add . && git cherry-pick --continue

If you have the GitHub CLI installed:

# Push the branch to GitHub:
git push --set-upstream origin backport-1742-to-release-2.0
# Create the PR body template
PR_BODY=$(gh pr view 1742 --json body --template 'Backport 7dbd6642d73037e08de54f4f44d2caf7731cdf68 from #1742{{ "\n\n---\n\n" }}{{ index . "body" }}')
# Create the PR on GitHub
echo "${PR_BODY}" | gh pr create --title '[release-2.0] Allow defining extra resource labels in prometheus' --body-file - --label 'type/docs' --label 'backport' --base release-2.0 --milestone release-2.0 --web

Or, if you don't have the GitHub CLI installed (we recommend you install it!):

# Push the branch to GitHub:
git push --set-upstream origin backport-1742-to-release-2.0

# Create a pull request where the `base` branch is `release-2.0` and the `compare`/`head` branch is `backport-1742-to-release-2.0`.

# Remove the local backport branch
git switch main
git branch -D backport-1742-to-release-2.0

mariomac added a commit that referenced this pull request Mar 17, 2025
* Allow defining extra resource labels in prometheus (#1742)

* Allow defining extra resource labels in prometheus

* reformat

(cherry picked from commit 7dbd664)

* Fix ebpf artifacts

---------

Co-authored-by: Mario Macias <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants