Automated raw CSV export of visualization [Kibana 4]

I want to automate the generation of a csv file that usually would be downloaded by clicking on the "Raw" button on the bottom of the page.
image

It would be as simple as

//Folding up the menu (in Javascript)
$("i.fa.fa-chevron-up:last").click();
//and clicking the button.
$("[ng-click='aggTable.exportAsCsv(false)']").click();

In Chrome the csv file is now being downloaded from a blob url.
But Chrome (with GUI) can't be controlled via commandline as far as I know.

But neither PhantomJS nor CasperJS allow me to run my commands and download the file.

Could you help me with this? :thinking:

Edit: The use of X-Pack currently is no option, sadly.

Hi @xenoid,

What's happening in PhantomJS/CasperJS when you execute the click on the button?

A simple click of the button sadly does not do anything.

I've been told that PhantomJS actually does not support downloading files directly.
The fact that it is generated and downloaded via Eli Grey's FileSaver.js wont make it simpler.

I'll take a look at chromedriver. It seems to be more sophisticated.

I gave up on PhantomJS and used Selenium Webdriver in combination with Python.
Heres my solution:

import time
import os
from selenium import webdriver

#xenoid 18.01.2018


#Starting the driver
chromeOptions = webdriver.ChromeOptions()

#Download directory
prefs = {"download.default_directory" : "C:/temp/KibanaExportToCSV/"}
chromeOptions.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome('C:\chromedriver\chromedriver.exe', chrome_options=chromeOptions)
driver.get("_YOUR LINK TO THE VISUALIZATION HERE_");
#Time it takes for the visualization to load
time.sleep(15)
#Open the footer menu
menu = driver.find_element_by_css_selector("i.fa.fa-chevron-up")
menu.click()
time.sleep(1)
#Click the button
exportToCsv = driver.find_element_by_css_selector(".visualize-spy-content a.small[ng-click='aggTable.exportAsCsv(false)']")
exportToCsv.click()
time.sleep(3)
driver.quit()

Hope this is useful to someone :slightly_smiling_face:

Great!

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