Correct API JSON Body To Assign a Config to a SideCar

I’m trying to figure out the right payload to assign a Collector Configuration to a SideCar in Graylog 3 using the API.

Based on what I can tell the following is the right API call:

The Graylog swagger interface(API Browser) is a little sparse on what actually needs to be included given at first glance a single array isn’t enough for the task at hand.

Currently the payload model is:

{
  "nodes": [
    "object"
  ]
}

Given the following information how would I construct a body to add the sidecar to the the specified config?

Sidecar Node ID: 39dafe37-b206-490e-9383-5472d8a5e40c
Configuration ID: 5d267fb46e686977c4ee2168

Perhaps there’s a different way to accomplish this task via an API call.

Hello @nom666nom,

the swagger GUI is not really helpful here. I used the network tab in the browser console to get
the needed information.

A assignment would look like this:

{"nodes":
  [
    {
      "node_id":"39dafe37-b206-490e-9383-5472d8a5e40c",
      "assignments": [{
         "collector_id":"not nknown to me",
         "configuration_id":"5d267fb46e686977c4ee2168"
      }]
    }
  ]
}

You have to add you collector id where I left no known to me.

I hope this was more helpful than swagger :slight_smile: Please ask if you have any more questions.

Greets,
Konrad

@konrad, the info was quite helpful. I didn’t even think about looking at the browser console for the payloads.

Based on your info I was able to make a payload via the swagger interface that worked. For others who run into this issue the following is a curl command that that includes the payload.

curl -u <sidecar token creds> -H 'Content-Type: application/json' -H 'X-Requested-By:cli' -X PUT -d '{"nodes":[{"node_id":"39dafe37-b206-490e-9383-5472d8a5e40c","assignments": [{"collector_id":"5ca67e4b6e6869042d90ea21","configuration_id":"5d267fb46e686977c4ee2168"}]}]}' "https://graylog.somedomain.com:9000/api/sidecars/configurations"

1 Like