Affichage des articles dont le libellé est JSON. Afficher tous les articles
Affichage des articles dont le libellé est JSON. Afficher tous les articles

jeudi 3 octobre 2024

json_exporter prometheus debug

 JSON url to convert : http://json_url/foobar.json

json_exporter running locally : localhost:7979 or json_exporter:7979 



Status of the json_exporter, does NOT contain the metrics from the targets, only related to the process itself (useful to know if it's up or not for example).

 localhost:7979/metrics


Check the result of a JSON URL to be converted / aka. what prometheus should scrape

curl http://json_url/foobar.json => JSON (original)

curl localhost:7979/probe?target=https://json_url/foobar.json => openmetrics converted by json_exporter



Other useful commands :


* edit, restart, wait, check json_exporter output

sudo vi /etc/json_exporter/config.yml && sudo systemctl restart json_exporter && sleep 5 && curl http://localhost:7979/probe?target=http://json_url/foobar.json


* edit, check and restart prometheus : 

sudo vi /etc/prometheus/prometheus.yml && sudo promtool check config /etc/prometheus/prometheus.yml && sudo systemctl restart prometheus.service



lundi 15 janvier 2024

jsonnet

K8s mixins & jsonnet demo : https://youtu.be/GDdnL5R_l-Y?si=6stnX7hCbdfidIK2&t=413 Jsonnet tester : https://jsonnet.org/

mercredi 21 juin 2023

parse json in terraform

 https://www.reddit.com/r/Terraform/comments/c07dgc/using_external_jsons_as_data_source/

    data "http" "example" {
  url = "..."
}

locals {
  example_response = jsondecode(data.http.example.body)
}
From there you can manipulate that data structure as you need. If you want to produce a map of lists then probably your next step would be to use two nested for expressions. I’m just guessing what you want the values in those lists to look like, but here’s a starting point:
    locals {
  example_rules = {
    for k, m in local.example_response : k => [
      for k, v in m : {
        key   = k
        value = v
      }
    ]
  }
}

jeudi 9 octobre 2014

JavaScript multiline code (JSON description)

It is currently not possible to store a multiline string in javascript. This is annoying since for example storing some JSON data often leads to long data to concatenate or to push into an array.
If you want to avoid this, you can use the following trick, since javascript accepts multiline comments, and returns them to the toString call on a function :

var jsonDescriptionText= function(){/*
[
    {
        "cat": "Categ1",
        "links": [
            {
                "txt": "text1",
                "url": "http://url",
                "title": "mouseover field"
            }
        ]
    }
]*/}.toString().slice(14,-3);
Note 1 : This avoids using concatenation for each line :
var longString2="string part1" + 
"string part2" 
or even escaping the new lines :
var longString2="string part1\
string part2"

Note 2 :

ECMA-262 5th Edition section 7.8.4 and called LineContinuation : "A line terminator character cannot appear in a string literal, except as part of a LineContinuation to produce the empty character sequence. The correct way to cause a line terminator character to be part of the String value of a string literal is to use an escape sequence such as \n or \u000A."

Note 3 :
 "In EcmaScript 6, you'll be able to use backticks for Template Strings, known in the spec as a NoSubstitutionTemplate:
var htmlString = `Say hello to 
multi-line
strings!`;
 "


(seen on : http://stackoverflow.com/questions/805107/creating-multiline-strings-in-javascript)