We have updated our Terms of Service, Code of Conduct, and Addendum.

How can I download a list of worker nodes in JSON format?

Johan Woger
Johan Woger Posts: 16
edited September 2023 in Stream

I have a big deployment with hundreds of worker nodes. Is there an easy way to download a full list of worker nodes in json format?

Tagged:

Best Answer

  • Jeremy Prescott
    Jeremy Prescott Posts: 33 ✭✭
    Answer ✓

    If you dont have access to the CLI to perform an API call, heres a JavaScript snippet that you can paste into your Browsers Developer Console. Once the Fetch (JavaScripts curl, essentially) resolves, it should download a JSON file with the results.

    fetch(`${window.location.origin}/api/v1/master/workers`, {
        "headers": {
          "authorization": `Bearer ${localStorage.AUTH_TOKEN}`,
        },
        "body": null,
        "method": "GET",
        "mode": "cors",
        "credentials": "include"
      })
      .then(response => response.blob())
      .then(blob => {
        let url = window.URL.createObjectURL(blob);
        let a = document.createElement('a');
        a.href = url;
        a.download = 'worker_list.json';
        document.body.appendChild(a);
        a.click();
        a.remove();
      });
    

Answers

  • Jeremy Prescott
    Jeremy Prescott Posts: 33 ✭✭
    Answer ✓

    If you dont have access to the CLI to perform an API call, heres a JavaScript snippet that you can paste into your Browsers Developer Console. Once the Fetch (JavaScripts curl, essentially) resolves, it should download a JSON file with the results.

    fetch(`${window.location.origin}/api/v1/master/workers`, {
        "headers": {
          "authorization": `Bearer ${localStorage.AUTH_TOKEN}`,
        },
        "body": null,
        "method": "GET",
        "mode": "cors",
        "credentials": "include"
      })
      .then(response => response.blob())
      .then(blob => {
        let url = window.URL.createObjectURL(blob);
        let a = document.createElement('a');
        a.href = url;
        a.download = 'worker_list.json';
        document.body.appendChild(a);
        a.click();
        a.remove();
      });
    
  • Johan Woger
    Johan Woger Posts: 16
    edited March 2023

    I love it when you talk javascript to me. <3

  • Ben Marcus
    Ben Marcus Posts: 27 mod
    edited September 2023

    You can also do this easily directly from the Cribl GUI. Navigate to the stream → workers page and select the button "Export list as" and choose JSON. You can also export as CSV.