Cannot see my created saved_object when creating it thru POST API

I have created a space test and I want to fill it with the saved_object API.

I create a visualization (ID:nff) with the POST endpoint ( POST https://mykibana.flightwatching.com/bigdata/s/test/api/saved_objects/visualization/nff)

In the .kibana index I can see it, but it does not appear in the test space. Can you tell me what is wrong?

in conf: kibana.index: .kibana-insight-val

GET .kibana*/_search
{
  "query": {
    "match": {
        "_id": "test:visualization:nff"
    }
  }
}


RESULT:
{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 12,
    "successful" : 12,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : ".kibana-insight-val_4",
        "_type" : "_doc",
        "_id" : "test:visualization:nff",
        "_score" : 1.0,
        "_source" : {
          "visualization" : {
            "title" : "component change history (NFF)",
            "visState" : """{"title":"component change history (NFF)","type":"metrics","params":{"id":"61ca57f0-469d-11e7-af02-69e470af7417","type":"timeseries","series":[{"id":"61ca57f1-469d-11e7-af02-69e470af7417","color":"rgba(255,255,255,0)","split_mode":"everything","metrics":[{"id":"61ca57f2-469d-11e7-af02-69e470af7417","type":"avg","field":"altitude"}],"separate_axis":0,"axis_position":"right","formatter":"number","chart_type":"line","line_width":1,"point_size":1,"fill":0.5,"stacked":"none","hidden":false,"label":"NOP","type":"timeseries"}],"time_field":"","index_pattern":"","interval":"","axis_position":"right","axis_formatter":"number","axis_scale":"normal","show_legend":0,"show_grid":1,"default_index_pattern":"wilco__insight-val__*","default_timefield":"@timestamp","isModelInvalid":false,"annotations":[{"fields":"REMOV_PART,REMOV_PART_DESCRIPTION,REMOV_SERIAL,WS_SUMUP,fwot","template":"{{fwot}} NFF - PN: {{REMOV_PART}} ({{REMOV_PART_DESCRIPTION}}) / SN: {{REMOV_SERIAL}} ## {{WS_SUMUP}}","index_pattern":"wilco__insight-val__*","query_string":{"query":"WS_SUMUP.keyword : * and IS_NFF.keyword : \"Y\" ","language":"kuery"},"id":"fe7d6570-d0aa-11ea-be74-036a9309cf60","color":"rgba(244,78,59,1)","time_field":"@timestamp","icon":"fa-tag","ignore_global_filters":0,"ignore_panel_filters":0},{"fields":"REMOV_PART,REMOV_PART_DESCRIPTION,REMOV_SERIAL,WS_SUMUP,fwot","template":"{{fwot}} - PN: {{REMOV_PART}} ({{REMOV_PART_DESCRIPTION}}) / SN: {{REMOV_SERIAL}} ## {{WS_SUMUP}}","index_pattern":"wilco__insight-val__*","query_string":{"query":"WS_SUMUP.keyword : * and not IS_NFF.keyword : \"Y\" ","language":"kuery"},"id":"ffd67050-d0ab-11ea-be74-036a9309cf60","color":"rgba(115,216,255,1)","time_field":"@timestamp","icon":"fa-tag","ignore_global_filters":0,"ignore_panel_filters":0}],"axis_min":"0","axis_max":"1"},"aggs":[]}""",
            "uiStateJSON" : "{}",
            "description" : "",
            "version" : 1,
            "kibanaSavedObjectMeta" : {
              "searchSourceJSON" : """{"query":{"query":"","language":"kuery"},"filter":[]}"""
            }
          },
          "type" : "visualization",
          "references" : [ ],
          "namespace" : "test",
          "migrationVersion" : {
            "visualization" : "7.4.2"
          },
          "updated_at" : "2020-07-28T17:40:31.515Z"
        }
      }
    ]
  }
}

Hi,

I just tested this out by creating an index pattern in a space in 7.9

https://my-es-instance/s/test/api/saved_objects/index-pattern/my-pattern
{
  "attributes": {
    "title": "my-pattern-*"
  }
}

That worked just fine:

Would you mind trying that one out?

Also, would you please share the exact configuration of the request you used to create that visualization? And which version of Kibana are you using? 7.4?

My version: 7.6.1

I did try

POST https://XXX.flightwatching.com/bigdata/s/test/api/saved_objects/index-pattern/my-pattern

with body

{
  "attributes": {
    "title": "my-pattern-*"
  }
}

Have this as returned from call:

{"type":"index-pattern","id":"my-pattern","attributes":{"title":"my-pattern-*"},"references":[],"migrationVersion":{"index-pattern":"7.6.0"},"updated_at":"2020-07-29T13:58:55.959Z","version":"WzM5NzksMV0="}

But the saved object is void as on the first post (only Advanced Settings [7.6.1]) as saved object

In the kibana logs (server side):

{"type":"response","@timestamp":"2020-07-29T14:04:14Z","tags":[],"pid":24034,"method":"post","statusCode":200,"req":{"url":"/api/saved_objects/index-pattern/my-pattern-2?overwrite=false","method":"post","headers":{"connection":"upgrade","host":"insight-val.flightwatching.com","content-length":"49","user-agent":"curl/7.64.1","accept":"*/*","kbn-xsrf":"true","content-type":"application/json"},"remoteAddress":"127.0.0.1","userAgent":"127.0.0.1"},"res":{"statusCode":200,"responseTime":1424,"contentLength":9},"message":"POST /api/saved_objects/index-pattern/my-pattern-2?overwrite=false 200 1424ms - 9.0B"}

Hey,

To make sure I understand: you tried creating the index pattern in the space, you can search for it but you can't see it in the space? Can you see it in the default space then? Or not at all?

Cannot see it even in the default space.

Note that the document seems to be created yet in the kibana index:

GET .kibana*/_search
{
  "query": {
    "match": {
        "_id": "test:index-pattern:my-pattern"
    }
  }
}

returns

{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 12,
    "successful" : 12,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : ".kibana-insight-val_4",
        "_type" : "_doc",
        "_id" : "test:index-pattern:my-pattern",
        "_score" : 1.0,
        "_source" : {
          "index-pattern" : {
            "title" : "my-pattern-*"
          },
          "type" : "index-pattern",
          "references" : [ ],
          "namespace" : "test",
          "migrationVersion" : {
            "index-pattern" : "7.6.0"
          },
          "updated_at" : "2020-07-29T13:58:55.959Z"
        }
      }
    ]
  }
}

I just repeated the same test in 7.6.1 and it works. I can see the object I create with the API in the UI.

Can you log in with the admin user (elastic?) and check if you see the objects?
I'm thinking it might be a permission issue with your user.

Thanks,
Liza

I am logged with elastic and I even have created the objects with elastic.

Where the permissions of elastic user can be set? I cannot see it when browsing the users...

I also tried with a regular user, and the same happend, obviously.

Can you help me finding where the role may filter out the saved_object?

  • It is in the .kibana index. Can you verify the structure is OK? (see previous posts)
  • It seems that the id of the object contains the space it belongs to and the type. Can you check the ID is well formatted?

If those 2 points are OK, then, the front end filters out the document for whatever reason. can you spot the places the filters can be placed (roles, users, etc...)?

best

@dao the only thing different between the object in your index and mine is the name of the index itself.

I see you modified the name of the kibana index to be .kibana-insight-val_4, while mine is the default .kibana_1. I wonder if this can somehow impact spaces.

Let me check this out.

Hey @dao,

This is an interesting one, I haven't seen this behavior before.
To answer some of your more recent questions:

It is in the .kibana index. Can you verify the structure is OK? (see previous posts)

The structure looks alright to me. Nothing stands out as incorrect here.

It seems that the id of the object contains the space it belongs to and the type. Can you check the ID is well formatted?

That's correct. The ID appears well-formatted to me.

If those 2 points are OK, then, the front end filters out the document for whatever reason. can you spot the places the filters can be placed (roles, users, etc...)?

Kibana currently doesn't support document-level security, and if you have access to the Saved Objects Management screen (which it appears you do...), then your account should have access to all saved objects, regardless of type.

Can you try to retrieve the saved objects via API call and let me know what you get back?

GET https://mykibana.flightwatching.com/bigdata/s/test/api/saved_objects/visualization/nff

and

GET https://mykibana.flightwatching.com/bigdata/s/test/api/saved_objects/_find?type=visualization

Can you also run this and report back what you get? This will retrieve some details about your current user account (assuming you're running with Security enabled)

GET https://mykibana.flightwatching.com/bigdata/internal/security/me

Here it is:

GET https://mykibana.flightwatching.com/bigdata/s/test/api/saved_objects/visualization/nff

{
  "id": "nff",
  "type": "visualization",
  "updated_at": "2020-07-28T17:40:31.515Z",
  "version": "WzM5NTgsMV0=",
  "attributes": {
    "title": "component change history (NFF)",
    "visState": "{\"title\":\"component change history (NFF)\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"timeseries\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"rgba(255,255,255,0)\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"avg\",\"field\":\"altitude\"}],\"separate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"hidden\":false,\"label\":\"NOP\",\"type\":\"timeseries\"}],\"time_field\":\"\",\"index_pattern\":\"\",\"interval\":\"\",\"axis_position\":\"right\",\"axis_formatter\":\"number\",\"axis_scale\":\"normal\",\"show_legend\":0,\"show_grid\":1,\"default_index_pattern\":\"wilco__insight-val__*\",\"default_timefield\":\"@timestamp\",\"isModelInvalid\":false,\"annotations\":[{\"fields\":\"REMOV_PART,REMOV_PART_DESCRIPTION,REMOV_SERIAL,WS_SUMUP,fwot\",\"template\":\"{{fwot}} NFF - PN: {{REMOV_PART}} ({{REMOV_PART_DESCRIPTION}}) / SN: {{REMOV_SERIAL}} ## {{WS_SUMUP}}\",\"index_pattern\":\"wilco__insight-val__*\",\"query_string\":{\"query\":\"WS_SUMUP.keyword : * and IS_NFF.keyword : \\\"Y\\\" \",\"language\":\"kuery\"},\"id\":\"fe7d6570-d0aa-11ea-be74-036a9309cf60\",\"color\":\"rgba(244,78,59,1)\",\"time_field\":\"@timestamp\",\"icon\":\"fa-tag\",\"ignore_global_filters\":0,\"ignore_panel_filters\":0},{\"fields\":\"REMOV_PART,REMOV_PART_DESCRIPTION,REMOV_SERIAL,WS_SUMUP,fwot\",\"template\":\"{{fwot}} - PN: {{REMOV_PART}} ({{REMOV_PART_DESCRIPTION}}) / SN: {{REMOV_SERIAL}} ## {{WS_SUMUP}}\",\"index_pattern\":\"wilco__insight-val__*\",\"query_string\":{\"query\":\"WS_SUMUP.keyword : * and not IS_NFF.keyword : \\\"Y\\\" \",\"language\":\"kuery\"},\"id\":\"ffd67050-d0ab-11ea-be74-036a9309cf60\",\"color\":\"rgba(115,216,255,1)\",\"time_field\":\"@timestamp\",\"icon\":\"fa-tag\",\"ignore_global_filters\":0,\"ignore_panel_filters\":0}],\"axis_min\":\"0\",\"axis_max\":\"1\"},\"aggs\":[]}",
    "uiStateJSON": "{}",
    "description": "",
    "version": 1,
    "kibanaSavedObjectMeta": {
      "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"
    }
  },
  "references": [],
  "migrationVersion": {
    "visualization": "7.4.2"
  }
}

GET https://mykibana.flightwatching.com/bigdata/s/test/api/saved_objects/_find?type=visualization

{
  "page": 1,
  "per_page": 20,
  "total": 1,
  "saved_objects": [
    {
      "type": "visualization",
      "id": "nff",
      "attributes": {
        "title": "component change history (NFF)",
        "visState": "{\"title\":\"component change history (NFF)\",\"type\":\"metrics\",\"params\":{\"id\":\"61ca57f0-469d-11e7-af02-69e470af7417\",\"type\":\"timeseries\",\"series\":[{\"id\":\"61ca57f1-469d-11e7-af02-69e470af7417\",\"color\":\"rgba(255,255,255,0)\",\"split_mode\":\"everything\",\"metrics\":[{\"id\":\"61ca57f2-469d-11e7-af02-69e470af7417\",\"type\":\"avg\",\"field\":\"altitude\"}],\"separate_axis\":0,\"axis_position\":\"right\",\"formatter\":\"number\",\"chart_type\":\"line\",\"line_width\":1,\"point_size\":1,\"fill\":0.5,\"stacked\":\"none\",\"hidden\":false,\"label\":\"NOP\",\"type\":\"timeseries\"}],\"time_field\":\"\",\"index_pattern\":\"\",\"interval\":\"\",\"axis_position\":\"right\",\"axis_formatter\":\"number\",\"axis_scale\":\"normal\",\"show_legend\":0,\"show_grid\":1,\"default_index_pattern\":\"wilco__insight-val__*\",\"default_timefield\":\"@timestamp\",\"isModelInvalid\":false,\"annotations\":[{\"fields\":\"REMOV_PART,REMOV_PART_DESCRIPTION,REMOV_SERIAL,WS_SUMUP,fwot\",\"template\":\"{{fwot}} NFF - PN: {{REMOV_PART}} ({{REMOV_PART_DESCRIPTION}}) / SN: {{REMOV_SERIAL}} ## {{WS_SUMUP}}\",\"index_pattern\":\"wilco__insight-val__*\",\"query_string\":{\"query\":\"WS_SUMUP.keyword : * and IS_NFF.keyword : \\\"Y\\\" \",\"language\":\"kuery\"},\"id\":\"fe7d6570-d0aa-11ea-be74-036a9309cf60\",\"color\":\"rgba(244,78,59,1)\",\"time_field\":\"@timestamp\",\"icon\":\"fa-tag\",\"ignore_global_filters\":0,\"ignore_panel_filters\":0},{\"fields\":\"REMOV_PART,REMOV_PART_DESCRIPTION,REMOV_SERIAL,WS_SUMUP,fwot\",\"template\":\"{{fwot}} - PN: {{REMOV_PART}} ({{REMOV_PART_DESCRIPTION}}) / SN: {{REMOV_SERIAL}} ## {{WS_SUMUP}}\",\"index_pattern\":\"wilco__insight-val__*\",\"query_string\":{\"query\":\"WS_SUMUP.keyword : * and not IS_NFF.keyword : \\\"Y\\\" \",\"language\":\"kuery\"},\"id\":\"ffd67050-d0ab-11ea-be74-036a9309cf60\",\"color\":\"rgba(115,216,255,1)\",\"time_field\":\"@timestamp\",\"icon\":\"fa-tag\",\"ignore_global_filters\":0,\"ignore_panel_filters\":0}],\"axis_min\":\"0\",\"axis_max\":\"1\"},\"aggs\":[]}",
        "uiStateJSON": "{}",
        "description": "",
        "version": 1,
        "kibanaSavedObjectMeta": {
          "searchSourceJSON": "{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[]}"
        }
      },
      "references": [],
      "migrationVersion": {
        "visualization": "7.4.2"
      },
      "updated_at": "2020-07-28T17:40:31.515Z",
      "version": "WzM5NTgsMV0="
    }
  ]
}

GET https://mykibana.flightwatching.com/bigdata/internal/security/me

{
  "username": "elastic",
  "roles": [
    "found-customer-admin"
  ],
  "full_name": null,
  "email": null,
  "metadata": {},
  "enabled": true,
  "authentication_realm": {
    "name": "found",
    "type": "file"
  },
  "lookup_realm": {
    "name": "found",
    "type": "file"
  }
}

Thanks for providing that @dao.

So it looks like everything is working correctly at the API level, since we can both create and retrieve these space-specific saved objects.

Does your visualization appear within the "Visualize" application, or is it hidden there too?
At this point, I think inspecting the "network" tab of your browsers dev tools would be helpful, so we can get a better idea of what's going on between Kibana and your browser.

visualization panel

It is void, and when I click on the icon, I am redirected to Management / Index patterns / Create index pattern

Inspect console

I have this error message at kibana loading

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-P5polb1UreUSOe5V/Pv7tc+yeZuJXiOi/3fqhGsU7BE='), or a nonce ('nonce-...') is required to enable inline execution.

network tab

Seems to be a good lead: The space in the URL seems to be wrong (test-space instead of test)

https://insight-val.flightwatching.com/bigdata/s/test-space/api/saved_objects/_find?fields=title&per_page=10000&type=index-pattern

Dear all, could you spot the problem? is it an actual bug according to the previous comment?

Ah yeah this is the problem. Not a bug, just a typo in the API calls. Instead of pointing your API calls to /s/test, you 'll need to use /s/test-space.

Each space is uniquely identified by its "Space ID", which is what we include as part of the URL. This is something you can customize when the space is first created, but it cannot be changed after the fact. If you want your space to have an ID of test instead of test-space, then you'll need to create a new space altogether.

Thanx for your help and reactivity

best