Create Stream using REST API

Hi,
I’m using v2.2.3 and I want to create Stream using ReST API (using demo on api/api-browser GraylogURL).
Currently I have a problem with it about the optional attribute index_set_id.
Looking the Streams : Manage streams, I’m using the POST service with this json

{
“title”: “My Test Stream”,
“description”: “My desc”,
“rules”: [
{
“field”: “tags”,
“description”: “”,
“type”: 1,
“inverted”: false,
“value”: “test”
}
],
“content_pack”: null,
“matching_type”: “AND”,
“remove_matches_from_default_stream”: “false”
}

With this code I have a 400 error code with this details:

{
“type”: “ApiError”,
“message”: “Can not construct instance of org.graylog2.rest.resources.streams.requests.CreateStreamRequest, problem: Null indexSetId\n at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@32d92490; line: 17, column: 1]”
}

I have the same result if I use index_set_id with null or embpy value string (“”).

So it seems that index_set_id is mandatory also because if I set it (coping it from all messages Stream), the POST works fine, and the Stream is created.

Can somebody help me to understand this situation? where I’m wrong?
Thanks
Gianluca

The index_set_id is mandatory. Every stream has to have a reference to the index set which is backing it.

Why do you think it’s optional?

Hi @jochen
I’m using the api-browser tests on Graylog.

In the Stream Management, for PORT action, the model says:

urn:jsonschema:org:graylog2:rest:resources:streams:requests:CreateStreamRequest {
title (string, optional),
description (string, optional),
rules (array[object], optional),
content_pack (string, optional),
matching_type (string, optional) = [‘AND’ or ‘OR’],
remove_matches_from_default_stream (boolean, optional),
index_set_id (string, optional)
}

For this reason I believe so.
So how I can get the default index_set_id?

Thanks a lot

Interesting, the documentation browser (Swagger UI) seems to have a problem with the “optional” attribute.
As you can see in CreateStreamRequest, many of the attributes are in fact not optional.

You can get a list of index sets from the /system/indices/index_sets resource of the Graylog REST API.

Hi @jochen
Thanks a lot.

Hi @jochen
If I have more the one index_set, how can I filter the results?

How I can approach the GET using filter?
Thanks

What kind of filter do you mean?

I’d like to get the index_set_id using index_prefix.

I mean, I’d like to have the id from the index_sets list where the index_prefix = graylog

“index_sets”: [
{
“id”: “592d4cd24220b60688aca1ff”,
“title”: “Default index set”,
“description”: “The Graylog default index set”,
“index_prefix”: “graylog”,
“shards”: 4,
“replicas”: 0,

Thanks

That’s not possible. You’ll have to filter the list yourself after retrieving it.

Ok,
thanks a lot again :slight_smile:

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