Using REST API to create collector configs

I am trying to programmatically create Collector Sidecar configurations with inputs and outputs using the REST API, but I am having some trouble:

  1. When trying to use POST /plugins/org.graylog.plugins.collector/configurations, I get an error about “Null inputs” which I do not know how to resolve. I have an existing input which I retrieved using GET /plugins/org.graylog.plugins.collector/configurations/{id}, but using that one’s same format in the POST command results in the same error.
  2. There seems to be a circular reference problem with the above POST command. If the command needs an Input object, and that Input object needs an Output ID to forward to, but that Output hasn’t been created yet, how is this supposed to work?
  3. Once point of confusion: The GET /plugins/org.graylog.plugins.collector/configurations shows just names and tags of existing configurations; why does the POST command apparently need an Input object? My original thought was to follow the same pattern as with the admin interface: create an empty configuration first with just a name, and then add tags, inputs, and outputs in a separate command. The POST command above seems to want to all at once, which is fine, but I am at a loss as to what it’s specifically looking for.

If anyone can help out I’d appreciate it. Thanks.

Followup: I have managed to create a new config with the following minimal JSON, which is apparently ALL required:

{
"name" : "Test Config",
"tags": ["test"],
"inputs":
    [
        {
            "backend": "filebeat",
            "type": "file",
            "name": "Test Config Input",
            "properties":
                {
                    "paths": "['/home/jdoe/sample-logs/*.log']",
                },
               "forward_to": ""
        }
    ],
"outputs":
    [
        {
            "backend": "filebeat",
            "type": "logstash",
            "name": "Test Config Output",
            "properties":
                {
                    "hosts": "['localhost:5044']"
                }
        }
    ],
"snippets":
    [
        {
          "backend": "nxlog",
          "name": "nxlog-defaults",
          "snippet":""
        }
    ]
}

Note that this doesn’t completely work yet but at least I’m not getting errors from this. Also note that everything here is required even if you’re not using it (e.g. snippets)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.