NodeUtils: export upcall variables to the environment - #705
Open
thiell wants to merge 1 commit into
Open
Conversation
Group source upcalls only support textual substitution of $GROUP,
$NODE, $SOURCE and $CFGDIR. Also export them as environment variables
so shell parameter expansions like ${GROUP:-default} work as users
expect, instead of silently reading the caller's environment.
Signed-off-by: Stephane Thiell <stephane@thiell.com>
Collaborator
Author
|
The docs now state it explicitly: exported variables take precedence over any same-named variables from the calling environment. Flagging for the 1.11 release notes as a minor behavior change: upcall commands no longer inherit caller-exported |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upcall commands already inherit the caller's full environment. This change simply sets the four substitution variables (
$GROUP,$NODE,$SOURCE,$CFGDIR) in that environment, so shell parameter expansions that are not replaced by the library, like${GROUP:-default}, expand to the same values instead of silently reading whatever the caller exported.$GROUPand$NODEare set empty when they do not apply to the upcall. Textual substitution is unchanged and still happens first, so existing configs behave identically.This makes it easy for a map upcall to support a default when the group name is empty, e.g. for query-backed sources:
Here each Prometheus scrape job is a node group, resolving to the hostnames of its targets:
@prometheus:node_exporterexpands to the nodes scraped by thenode_exporterjob, and@prometheus:(empty group name) expands to the nodes of all jobs (useful for map-only sources, where@prometheus:*cannot work).See #609 for a related earlier discussion (FYI).
Docs updated: groups.conf(5) + sphinx config.
Closes #704