Questions tagged [jsonnet]

Jsonnet is a data templating language which compiles to JSON.

Jsonnet is a domain specific configuration language that helps you define JSON data. Jsonnet lets you compute fragments of JSON within the structure, bringing the same benefit to structured data that templating languages bring to plain text.

Project info

116 questions
0
votes
1 answer

Would like to assign multiple variables from split() on one line of code

Given the following array: // use strings only in the form - ports: [ 'tcp-1514', 'tcp-8080', 'tcp-8443', ], I'm trying to write jsonnet to split each element of the array to generate this object (represented here in…
Jim
  • 1,499
  • 1
  • 24
  • 43
0
votes
1 answer

How do I correctly format this jsonnet array output?

I have the following JSON and am using the -y option to produce a yaml output. { array: [ {item1: 1}, {item2: 2}, ] } I would like to produce (desired) { "array": - "item1": 1, - "item2": 2 } but I am…
user3877654
  • 1,045
  • 1
  • 16
  • 40
0
votes
1 answer

To use Gitlab Dashboards - How to use grafonnet with jsonnet to produce a json file that I can use with Grafana

Can someone please show me how to use the jsonnet files with grafonnet? Like a step by step for newbies? I want to use the GitLab dashboards here in my local Grafana environment - https://gitlab.com/gitlab-com/runbooks/-/tree/master/dashboards The…
ErnieAndBert
  • 1,344
  • 3
  • 21
  • 43
0
votes
1 answer

Object comprehension with iterator

I have a given object renameByName like that: { fieldA: 'foo', fieldB: 'bar' } and I want to convert that into an object that is supposed to order the fields by an index: { fieldA: 0, fieldB: 1, } My idea: { [key]: 0, …
kentor
  • 16,553
  • 20
  • 86
  • 144
0
votes
1 answer

Increment variable from methods

I would like to increment a counter in a method, like this: row(title, height):: { _panels:: [], _panelSlot:: 0, addPanel(panel):: self { self._panelSlot = self._panelSlot + 1, _panels+: [{ slot: panelSlot, …
kentor
  • 16,553
  • 20
  • 86
  • 144
0
votes
1 answer

Can a .jsonnet file be constructed in pure python

I use .jsonnet file as a template for AllenNLP model config I search through hyperparameter space with Optuna package and evaluate that template on each step with suggested hyperparameters as extVars. Then I train a model and save it to an…
Ojomio
  • 843
  • 1
  • 8
  • 17
0
votes
1 answer

Passing TLAs from argocd to jsonnet

Trying to understand passing TLAs to my jsonnet file with argocd. This is part of my argocd application.yaml which compiles the kube-prometheus manifests straight from my main.jsonnet file. I want to create 2 kube-prometheus apps in argocd (prod and…
Alan
  • 491
  • 4
  • 13
0
votes
1 answer

How to Populate Variables for Grafana Dashboard Template in Jsonnet

I'd like to deploy and manage many similar Grafana dashboards with jsonnet/grafonnet using a single template where variables are substituted in each dashboard instance. A simplified example of my (not working) approach so far looks like this: #…
0
votes
1 answer

Concat array elements into new array

I have a string which is separated by "/", which I then split into an array. eg. local string = 'Code/Github/Exercises' local array = std.split(string, "/") // ['Code', 'Github', 'Exercises'] How do I then convert array so that I can get the…
Robert Hung
  • 165
  • 13
0
votes
1 answer

As far as I can tell, there is no way to parameterize character strings in an AllenNLP config file --- only ints or floats

So the issue is that, for using autotuning (like optuna) with AllenNLP, the suggested practice is to use, in jsonnet scripts, references to environment variables, and then to set up a study to modify those parameters. That works fine, when the…
Jim Cox
  • 13
  • 3
0
votes
1 answer

How to use std.prune() with a function?

I have a function that takes one required parameter and two optional parameters. I want the function to prune out the optional parameters from the result if they are not provided, but it evaluates to an empty expression. My function: local…
ckmason
  • 3
  • 3
0
votes
1 answer

Add elements of array in jsonnet

I am trying to add elements of an array in jsonnet. Can someone post a sample? Sample input: [0, 1, 2, 3] output 6
0
votes
1 answer

Using jsonnet for grafana dashboard

I am trying jsonnet (my-custom-grafana.jsonnet) for grafana dashboard.I tried below code. local grafana = import 'grafonnet/grafana.libsonnet'; local dashboard = grafana.dashboard; local row = grafana.row; local prometheus =…
Rad4
  • 1,936
  • 8
  • 30
  • 50
0
votes
1 answer

Using jsonnet to update Prometheus operator default rule

I am trying to override the Default rules in Kube-Prometheus-Stack. I have enabled default rules when Kube-Prometheus-Stack was deployed. I tried with jsonnet as shown in this example…
Rad4
  • 1,936
  • 8
  • 30
  • 50
0
votes
1 answer

Conditional in the top level object cannot access merged config

I'm dealing with jsonnet and I cannot access to the $._config coming from the merged object { if ! $._config.hello.enable then { 'hello': 'world' } else {}, } + { _config+:: { hello: { enable: true }, } } the error…
Mazzy
  • 13,354
  • 43
  • 126
  • 207