Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load anchor document #50482

Closed
SSmale opened this issue Nov 13, 2019 · 20 comments
Closed

Failed to load anchor document #50482

SSmale opened this issue Nov 13, 2019 · 20 comments
Labels
bug Fixes for quality problems that affect the customer experience Feature:Discover Discover Application Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.

Comments

@SSmale
Copy link

SSmale commented Nov 13, 2019

Kibana version:
6.7.1
Elasticsearch version:
6.7.1
Server OS version:
centOS 7.5
Browser version:
Firefox 69
Browser OS version:
Windows_NT x64 10.0.17134
Original install method (e.g. download page, yum, from source, etc.):
yum
Describe the bug:
Clicking on the view surrounding documents button in the discover page gives the error Error: "Failed to load anchor document.". I cannot find any information on what the anchor document is or how it works. This is only an issue on one of our index types and I cannot see what could be causing the difference.

@azasypkin azasypkin added Feature:Discover Discover Application Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Nov 13, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@timroes
Copy link
Contributor

timroes commented Nov 13, 2019

Could you please open your browsers Dev Tools (F12) and go to the network tools and post the request/response from the _msearch (or _search) request that's made once you click on the "view surrounding documents" button?

@SSmale
Copy link
Author

SSmale commented Nov 13, 2019

Attached below

{
  "index": "INDEX_NAME-*",
  "ignore_unavailable": true,
  "NAME_metadata": {},
  "preference": 1573664705100
}
{
  "version": true,
  "size": 1,
  "sort": [
    {
      "@timestamp": {
        "order": "desc",
        "unmapped_type": "boolean"
      }
    },
    {
      "_doc": {
        "order": "asc",
        "unmapped_type": "boolean"
      }
    }
  ],
  "_source": {
    "excludes": []
  },
  "stored_fields": [
    "*"
  ],
  "script_fields": {},
  "docvalue_fields": [
    {
      "field": "@timestamp",
      "format": "date_time"
    },
    {
      "field": "FIELD_NAME",
      "format": "date_time"
    },
    {
      "field": "FIELD_NAME",
      "format": "date_time"
    }
  ],
  "query": {
    "bool": {
      "must": [
        {
          "constant_score": {
            "filter": {
              "ids": {
                "type": "TYPE",
                "values": [
                  "UUID"
                ]
              }
            }
          }
        }
      ],
      "filter": [],
      "should": [],
      "must_not": []
    }
  },
  "timeout": "30000ms"
}
{
  "responses": [
    {
      "took": 2,
      "timed_out": false,
      "_shards": {
        "total": 0,
        "successful": 0,
        "skipped": 0,
        "failed": 0
      },
      "_clusters": {
        "total": 1,
        "successful": 1,
        "skipped": 0
      },
      "hits": {
        "total": 0,
        "max_score": 0,
        "hits": []
      },
      "status": 200
    }
  ]
}

@timroes
Copy link
Contributor

timroes commented Nov 18, 2019

@kertal do you by any chance, have any idea what could be going on here?

@kertal
Copy link
Member

kertal commented Nov 18, 2019

@SSmale would it be possible to post the mapping of the index that has problems with context view? and 2 sample datasets (just examples), thx!

GET http://localhost:9200/{nameOfIndex}/_mapping

@SSmale
Copy link
Author

SSmale commented Nov 18, 2019

https://gist.github.com/SSmale/5507e5cc1014192ccc300ad3b4c3661e

Here is a gist with the mapping and datasets

@kertal
Copy link
Member

kertal commented Nov 19, 2019

thx, i will use that data to test

@kertal
Copy link
Member

kertal commented Nov 19, 2019

I've tested and it works, so I think this problem is specific to your index pattern and the indices that are queried. Context view first tries to fetch the document you clicked on view surrounding documents. That's the anchor document. For some reason no document is returned in this case. Could you use Kibana's devtools to try out a manual query on the index that doesn't work, like this:

GET /{yourIndex}/_search
{
    "query": {
        "ids" : {
            "type" : "{yourDocType}",
            "values" : ["{idOfTheAnchorDocument}"]
        }
    }
}

thx!

@SSmale
Copy link
Author

SSmale commented Nov 19, 2019

I have done that and it returns the single record.

@SSmale
Copy link
Author

SSmale commented Dec 2, 2019

Did you have any other suggestions @kertal?

@kertal
Copy link
Member

kertal commented Dec 3, 2019

looking again at your result

"_clusters": {
        "total": 1,
        "successful": 1,
        "skipped": 0
      },
"_shards": {
        "total": 0,
        "successful": 0,
        "skipped": 0,
        "failed": 0
      },

so you're searching 1 cluster, and there was no shard found. I'd be interested in your index pattern, do you use cross cluster search?

@SSmale
Copy link
Author

SSmale commented Dec 6, 2019

yes we use cross cluster search. Sorry what do you mean by index pattern?

@kertal
Copy link
Member

kertal commented Dec 10, 2019

tutorial-discover-2
the index pattern defines which ES indices are queried. Since you're using cross cluster search, It seems this search doesn't query all of your clusters? that's why no data in this case is returned. That's why it would be interesting to have an exported version of your index pattern, which is exportable in the Saved Object Management:

https://www.elastic.co/guide/en/kibana/6.8/managing-saved-objects.html

@SSmale
Copy link
Author

SSmale commented Dec 10, 2019

On my dev machine (the one the data is from) only has a single cluster but we are getting the same issue on our multi cluster too.

I have included one that works and one that doesn't into the gist

@Leaf-Lin
Copy link
Contributor

Leaf-Lin commented Aug 24, 2020

I bump into this issue in Kibana 7.8.0. I notice the document _id is the culprit.

  • If the _id contains only alphanumerical characters, it will give me correct context and showing the surrounding url.
  • if the _id contains the special character + or =, it works fine too.
  • If the _id contains a slash /, it first converts the _id into html ASCII characters (with %2F) but then resolve into wrong url which subsequently causing "Failed to load anchor document" like this:

To check a surrounding document with id= v/xA69ZXhXRk21sWH56BNnwibvs=

It gives the url like:

https://my_kibana_url/app/kibana#/discover/context/my_index_pattern-*/v%2FxA69ZXhXRk21sWH56BNnwibvs%3D?<extra_filter>

Screen Shot 2020-08-24 at 11 20 47 am

Note the context changed into #xA69ZXhXRk21sWH56BNnwibvs= with missing v/

but it then resolves into:

https://my_kibana_url/app/kibana#/discover/context/my_index_pattern-*/xA69ZXhXRk21sWH56BNnwibvs=?<extra_filter>&type=v

Note the _id change and &type=v at the end of url.

  • probably worth to check other special characters.

TL;DR, _id containing foo/bar gives url with context bar, with &type=foo appended in the url.

@ppawel
Copy link

ppawel commented Sep 11, 2020

I can confirm @Leaf-Lin's finding about the _id. For me a document with _id = TLmBgdeL0GOgAqCX+Q1JSRE6Ijlqg95S71GIGS/JYkc= causes this problem, while others without / don't.

As a workaround we will probably adjust the _id when sending the data to Elasticsearch with fluentd but would be nice if Kibana handled it properly...

For the record, we are on ES/Kibana 7.9.

@kertal
Copy link
Member

kertal commented Sep 15, 2020

@Leaf-Lin @ppawel this is a different issue than the one @SSmale reported, so I've exported it to #77443

@timroes timroes added Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. and removed Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Aug 31, 2021
@jughosta jughosta added the bug Fixes for quality problems that affect the customer experience label Jun 27, 2022
@kertal
Copy link
Member

kertal commented Jul 19, 2022

had another look at it and I'm pretty sure this is an issue with cross cluster search. closing it since in the meantime 7.17 is our last minor of our previous major. feel free to reopen with additional information about your cross cluster setup.

@kertal kertal closed this as completed Jul 19, 2022
@ppawel
Copy link

ppawel commented Jul 19, 2022

It was a bug in Kibana's URL handling for anchors, not anything backend side...

@kertal
Copy link
Member

kertal commented Jul 19, 2022

There were 2 issue described here, the one @SSmale mentioned, and the one @Leaf-Lin mentioned, which was fixed, and was caused by URL handling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Discover Discover Application Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL.
Projects
None yet
Development

No branches or pull requests

8 participants