-
Notifications
You must be signed in to change notification settings - Fork 487
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: Support JSON and YAML forms in place of River #2690
Comments
cc @Logiraptor for thoughts since you mentioned wanting to be able to use YAML in Helm charts for #2604. |
Biased viewpoint but, I would prefer to invest time into the conversion of yaml -> river instead of supporting yaml. I believe as river and flow expands it's going to be harder to maintain parity. |
Just to make sure I understand, you're talking about the conversion of the static agent config to a Flow config? Just want to make sure; this proposal could also be interpreted as supporting "yaml -> river" in a way. |
Correct, you can convert the static agent config as it exists today from yaml to river, but you cannot use expressions in the yaml or any other river-specific features or any new features/components introduced in flow. |
I think any of the proposals here could technically work for my use-case. I'll leave some more details here to hopefully help. I'll reduce this to a simple case to avoid too much redundant information: In the Mimir helm chart, I'd like to make the work from #2604 work out of the box. That means I need a few things to happen:
With the current agent chart as a subchart, I think it would look something like this: I would add the agent chart as a subchart and in mimir values.yaml: agent:
mode: 'flow'
configMap:
# disable this configmap so I can generate my own
create: false
name: mimir-agent-config Then I would add a template to our helm chart to generate the new configmap:
What I'm specifically trying to avoid is the need to generate correct river syntax. I think this problem extends to any environment where configuration is generated by machines, as evidenced by the existence of a river-jsonnet library. If I needed to build this feature today I would probably take a different approach and let the user define a snippet of river which just gets pasted into the agent config map. For example, check out what we do with the nginx configuration: https://github.com/grafana/mimir/blob/main/operations/helm/charts/mimir-distributed/values.yaml#L2090. Importantly, you can use helm templating in that string and we provide a reasonable default value. FYI The helm templating is enabled by a function in helm, so it doesn't automatically apply to every string. |
Closing per May community call conversation |
1 similar comment
Closing per May community call conversation |
While I (personally, with obvious bias) believe the learning curve of River isn't too high:
One possible way to solve these problems is to introduce JSON and YAML representation that can be used in place of River, but still support River expressions instead of them.
Proposal
There are three challenges with mapping JSON and YAML to River:
rule
blocks inprometheus.relabel
).I propose that blocks be given a special syntax of
block BLOCK_NAME BLOCK_LABEL
. For example:block prometheus.remote_write default
. Note the lack of quotes for the label; quotes are avoided to make it easier for JSON, which would otherwise require escaping the double quotes. This introduces the risk of improperly formatting the block, such as not putting a space between the block name and block label.Expressions will be represented by the interpolated string syntax,
${EXPR}
, as proposed in grafana/river#15.If there is content before or after the expression, the expression is converted into a string and concatenated to the strings before and after it:
would evaluate to:
A string which contains only the interpolated string syntax is treated as a pure expression:
would evaluate to a number, not a string:
If the expression cannot be converted into a string, a VM error would be produced.
Finally, blocks may be defined as an array if there are multiple blocks of the same name:
Internally, JSON and YAML files will be parsed into a River AST. AST elements which store position (like the position of
{
for a block) will have to get creative with where a{
hypothetically would be for the start of the block.Examples
The following examples are all three equivalent Flow configuration files using River, YAML, and JSON:
Potentially removing the "block" keyword
The
block
keyword is needed to identify at parse time whether a key in a JSON or YAML object is referring to a block or an attribute. Other keywords could potentially be used which are less verbose.Alternatively, the River AST could be modified to include an ambiguous AST node which either represents a block or an attribute. The River VM would have to be responsible for resolving this AST node into its final form, and fail the evaluation if an expression was used to assign a block. This shouldn't have any significant overhead, but would require introducing an AST element for something which isn't River.
Modifying the AST to remove the block keyword would change the above YAML to the following:
Counterarguments
There are some counterarguments I can imagine to this entire proposal:
The text was updated successfully, but these errors were encountered: