Skip to content

docs: document juju_unit label injection for wildcard and non-wildcard scrape targets#245

Open
Abuelodelanada wants to merge 2 commits intomainfrom
feat/juju-unit_metrics_documentation
Open

docs: document juju_unit label injection for wildcard and non-wildcard scrape targets#245
Abuelodelanada wants to merge 2 commits intomainfrom
feat/juju-unit_metrics_documentation

Conversation

@Abuelodelanada
Copy link
Copy Markdown
Contributor

@Abuelodelanada Abuelodelanada commented Apr 9, 2026

Issue

Document how the prometheus_scrape library injects the juju_unit topology label into Prometheus scrape jobs, covering both wildcard and non-wildcard targets.

Checklist

  • I have added or updated relevant documentation.
  • PR title makes an appropriate release note and follows conventional commits syntax.
  • Merge target is the correct branch, and relevant tandem backport PRs opened.

Copy link
Copy Markdown
Contributor

@sed-i sed-i left a comment

Choose a reason for hiding this comment

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

Looks good!

For quick reference in the future, could you please add a "Summary" section with a table such as

  juju_unit juju_application juju_charm juju_model juju_model_uuid
cos-config          
gagent:juju-info          
gagent:cos-agent          
...          

comparing which labels are present on which relations, and potentially contrasting label matchers and alert labels.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Documents how the prometheus_scrape library injects the juju_unit topology label into Prometheus scrape jobs for both wildcard and explicit (non-wildcard) scrape targets.

Changes:

  • Expanded juju-topology-labels.md to describe juju_unit injection behavior for wildcard vs non-wildcard scrape targets under metrics-endpoint.
  • Updated the “Exposing a Metrics Endpoint” how-to with guidance and an example for using explicit FQDN/IP targets (e.g., for strict TLS/SNI).
  • Minor Markdown whitespace/formatting cleanup in the affected sections.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
docs/reference/juju-topology-labels.md Adds reference documentation for juju_unit injection behavior for wildcard and non-wildcard scrape targets.
docs/how-to/exposing-a-metrics-endpoint.md Adds author guidance and an example showing explicit targets and how juju_unit enrichment applies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +61 to +63
The `*` wildcard in the target address is the most common pattern. At scrape
time, Prometheus expands it to one scrape job per unit, each labeled with the
corresponding `juju_unit` topology label.
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The statement that Prometheus "expands" the * target is inaccurate: Prometheus treats static_configs.targets as literal host:port strings and does not expand *. The per-unit expansion/juju_unit enrichment is done before Prometheus receives the final scrape config (e.g., by the prometheus_scrape library / charm generating the jobs). Please reword to avoid attributing this behavior to Prometheus itself.

Suggested change
The `*` wildcard in the target address is the most common pattern. At scrape
time, Prometheus expands it to one scrape job per unit, each labeled with the
corresponding `juju_unit` topology label.
The `*` wildcard in the target address is the most common pattern. The
`prometheus_scrape` library uses it to generate one scrape target per unit
before Prometheus receives the final scrape configuration, and each target is
labeled with the corresponding `juju_unit` topology label.

Copilot uses AI. Check for mistakes.
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.

3 participants