Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: add Flow debug.variables component #2772

Closed
rfratto opened this issue Jan 18, 2023 · 2 comments
Closed

Proposal: add Flow debug.variables component #2772

rfratto opened this issue Jan 18, 2023 · 2 comments
Labels
enhancement New feature or request flow Related to Grafana Agent Flow frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. proposal Proposal or RFC proposal-rejected Proposal has been rejected in its current form. Rejected proposals may be revisited in the future.

Comments

@rfratto
Copy link
Member

rfratto commented Jan 18, 2023

(Originally discussed in #2766)

I propose a new component called debug.variables, which defines a set of variables that can be changed by invoking an API endpoint:

logging {
  level = debug.variables.default.loglevel 
}

debug.variables "default" {
  variable "loglevel" {
    default = "info"
  }
}

Then, one could change the values of variables using the API:

curl -XPOST -d '"debug"' https://localhost:12345/components/debug.variables.default/loglevel

I think a component like this provides some basic level of remote configuration that would be helpful specifically for debugging without having to update the config file. This would also integrate well with conditionals (#2638) to allow dynamically switching between where data get sent:

debug.variables "default" {
  variable "uselocalprom" {
    default = false 
  }
}

prometheus.remote_write "default" {
  client {
    // Syntax for conditionals not final; see grafana/alloy#157 for more details.
    url = (
      if debug.variables.default.uselocalprom 
      then env("LOCAL_PROMETHEUS") 
      else env("CLOUD_PROMETHEUS")
    )
  }
}

Details

The variable block is a labeled block which defines an individual variable whose value can change. The label of the block defines the name of the variable. The default attribute provides the original value for the variable. The default attribute is ignored if a user has provided an explicit value via the API.

Variable values must be a type which can be represented in JSON:

  • Boolean
  • Number
  • String
  • Object
  • Array

Arrays can only have elements matching any of the above types, and Objects can only have values matching any of the above types.

For the initial implementation, it will not be possible to use River expressions from the API, so no capsule values can be used.

UI integration

The UI could show a special view for debug.variables which would allow changing the values for variables within the UI itself (and showing the current values).

@mattdurham
Copy link
Collaborator

I like this, the only part I am a bit hesitant about is the UI integration.

@rfratto rfratto added flow Related to Grafana Agent Flow flow/enhancement enhancement New feature or request and removed flow/enhancement labels Jan 19, 2023
@rfratto rfratto changed the title Proposal: add Flow debug.variables component Proposal: add Flow debug.variable component Jun 28, 2023
@rfratto rfratto changed the title Proposal: add Flow debug.variable component Proposal: add Flow debug.variables component Jun 28, 2023
@ptodev ptodev added the proposal-rejected Proposal has been rejected in its current form. Rejected proposals may be revisited in the future. label Jun 28, 2023
@rfratto
Copy link
Member Author

rfratto commented Jun 28, 2023

As discussed during the proposal review in the community call, we think that this encourages bad behavior, where debug hooks are left in the config file permanently. We think that changing the config file when you need to test out another value is a healthier approach, so we decided to reject this for now.

@rfratto rfratto closed this as not planned Won't fix, can't repro, duplicate, stale Jun 28, 2023
@github-project-automation github-project-automation bot moved this from Todo to Done in Grafana Agent (Public) Jun 28, 2023
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Feb 21, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request flow Related to Grafana Agent Flow frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. proposal Proposal or RFC proposal-rejected Proposal has been rejected in its current form. Rejected proposals may be revisited in the future.
Projects
No open projects
Development

No branches or pull requests

3 participants