Unable to import ndjson file into kibana bashboard using API

Hey Everyone,

I'm stuck at a point of importing dashboard(ndjson) file which I exported into kibana using API.
I've tried below commands as per AWS Official documentation.

curl -X POST https://<kibana_URL>/_plugin/kibana/auth/login -H "kbn-xsrf: true" -H "content-type:application/json" -d '{"username":"user", "password" : "pass"} ' -c auth.txt

curl -X POST https://<kibana_URL>/_plugin/kibana/api/saved_objects/_import -H "kbn-xsrf:true" -b auth.txt --form file=@test.ndjson

I'm able to login and export the dashboard. But when i try to import it's giving below error.

It was taking 1 min of time and later throwing below error. Even for very small dashboards as well it's the same error.

Can some one please help me. Stuck at this point since 3 restless days.

====================

  • We are completely uploaded and fine

< HTTP/1.1 504 Gateway Time-out
< Server: nginx
< Date: Sun, 02 Jun 2024 10:12:08 GMT
< Content-Type: text/html
< Content-Length: 160
< Connection: keep-alive
<

504 Gateway Time-out

504 Gateway Time-out


nginx * Connection #0 to host left intact ==============

I'm able to import this via UI. The issue i'm facing from is via API.

Welcome!

What do you mean? Kibana is made by elastic.

Sounds like the error message is from nginx and not Kibana. I suspect that you are not running a real version of Kibana. Which version is Elasticsearch?

Hey, Thanks for your swift response.

The version I'm using is 7.9

Upgrade to 7.17 at least or 8.13.4.

You are saying error is w.r.t nginx. How could version upgrade solve this issue.
Please let me know :slight_smile:

I don't know if it will solve your issue. Probably not, but at least you will use a "safe" version and not an outdated one.

I was able to import dashboards from UI. But when I try from kibana import api
https://<kibana_URL>/_plugin/kibana/api/saved_objects/_import

Then I'm facing this issue. I wonder that import API worked some time for me and later it started giving this error.

On executing below approach it seems like I was able to send the ndjson file to kibana. But Kibana was unable to process.

curl -X POST -v <kibana_URL>/_plugin/kibana/api/saved_objects/_import -H "kbn-xsrf:true" -b auth.txt --form file=@test.ndjson

===================================
Note: Unnecessary use of -X or --request, POST is already inferred.

  • Host <kibana_URL>:443 was resolved.

  • IPv6: (none)

  • IPv4: 13.54.149.250

  • Trying 13.54.149.250:443...

  • Connected to <kibana_URL> (13.54.149.250) port 443

  • ALPN: curl offers h2,http/1.1

  • (304) (OUT), TLS handshake, Client hello (1):

  • CAfile: /etc/ssl/cert.pem

  • CApath: none

  • (304) (IN), TLS handshake, Server hello (2):

  • (304) (IN), TLS handshake, Unknown (8):

  • (304) (IN), TLS handshake, Certificate (11):

  • (304) (IN), TLS handshake, CERT verify (15):

  • (304) (IN), TLS handshake, Finished (20):

  • (304) (OUT), TLS handshake, Finished (20):

  • SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384 / [blank] / UNDEF

  • ALPN: server accepted http/1.1

  • Server certificate:

  • subject: C=GB; L=London; O=IMImobile Limited; CN=*.imiconnect.com

  • start date: Sep 20 00:00:00 2023 GMT

  • expire date: Oct 20 23:59:59 2024 GMT

  • issuer: C=US; O=DigiCert Inc; CN=DigiCert Global G2 TLS RSA SHA256 2020 CA1

  • SSL certificate verify ok.

  • using HTTP/1.x

POST /_plugin/kibana/api/saved_objects/_import HTTP/1.1

User-Agent: curl/8.6.0

Accept: /

Cookie: security_authentication=Fe26.2**10139ab39834bb569f5b843f0aef738a7bb640410d82033483b7H3dqsxNMSWnu3sKKxPijZpIq2kGb4ZqeQOQW20ZdBagwAvMDO-CeP8lEvwM1caefeed253eb76298c0d4015270e4455480bfb597265fa8bea6b4321f14b6*iwasJTjQKfrRiw3r2GQYrjPv9w_wtMgSdBy6Ubjt7GA

kbn-xsrf:true

Content-Length: 23644

Content-Type: multipart/form-data; boundary=------------------------5DKENfBvBQAP78uMqgiNOT

  • We are completely uploaded and fine

< HTTP/1.1 504 Gateway Time-out

< Server: nginx

< Date: Sun, 02 Jun 2024 10:12:08 GMT

< Content-Type: text/html

< Content-Length: 160

< Connection: keep-alive

<

504 Gateway Time-out

504 Gateway Time-out


nginx
  • Connection #0 to host <Kibana_URL> left intact

===================================

Do you have nginx running? Could directly call kibana instead ?

Also check the content-type. You are not providing it when running the curl command.