Kibana/elastic search - Fetching search data


(Romil) #1

Kibana version 6.2.2
I am trying to export my dashboard using POST API call from an external server. Is there a way I can achieve that?
The tool only shows me curl command using GET.

Here is what i am want to perform using a POST Call. Need some guidance on this.

curl -XGET "http://Hostname.com:9200/_search" -H 'Content-Type: application/json' -d'
{
"size": 0,
"_source": {
"excludes": []
},
"aggs": {
"6": {
"terms": {
"field": "api_name.keyword",
"size": 2,
"order": {
"7": "desc"
}
},
"aggs": {
"1": {
"avg": {
"field": "time_to_serve_request"
}
},
"2": {
"max": {
"field": "time_to_serve_request"
}


(Ritwik Sharma) #2

@rgarg If you are exporting then you need GET, if you are importing you need POST. Please clarify what you want to do.


(Ritwik Sharma) #3

@rgarg

For exporting -

https://discuss.elastic.co/t/kibana-is-there-a-way-to-get-dashboards-from-command-line/48744

Blockquote
curl -s http://localhost:9200/.kibana/dashboard/_search?pretty
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : ".kibana",
"_type" : "dashboard",
"_id" : "New-Dashboard",
"_score" : 1.0,
"_source" : {
"title" : "New Dashboard",
"hits" : 0,
"description" : "",
"panelsJSON" : "[{"id":"Visualization-VerticalBarChart","type":"visualization","panelIndex":1,"size_x":3,"size_y":2,"col":1,"row":1}]",
"optionsJSON" : "{"darkTheme":false}",
"uiStateJSON" : "{}",
"version" : 1,
"timeRestore" : false,
"kibanaSavedObjectMeta" : {
"searchSourceJSON" : "{"filter":[{"query":{"query_string":{"query":"*","analyze_wildcard":true}}}]}"
}
}
} ]
}
}

For importing -

https://www.elastic.co/guide/en/kibana/3.0/import-some-data.html

I hope that helps


(Romil) #4

@Ritwik_Sharma I want to export but since I have a big search query, I am not sure how to use that in a GET call. Also, I am aware of the curl command but I want to know if the same functionality can be achieved with a simple rest call instead. For example using SOAP UI or node js rest call.


(Ritwik Sharma) #5

@rgarg Ohk, I got it. you can do it with requests using a python script. My code is for import but the same functionality can be used for export https://github.com/ritwik12/ELK/blob/master/Kibana.py


(Ritwik Sharma) #6

@rgarg For Soap and node js rest call I don't have any idea :frowning:


(system) #7

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