Skip to content

Instantly share code, notes, and snippets.

@ftuyama
Created February 13, 2023 22:22
Show Gist options
  • Save ftuyama/0981e60daa6ff017b66b486197354b2c to your computer and use it in GitHub Desktop.
Save ftuyama/0981e60daa6ff017b66b486197354b2c to your computer and use it in GitHub Desktop.
Export data from Kibana
let match;
const text = $(".dscWrapper").text();
const regex = /TL_[A-Z0-9]{6}/g;
const matches = [];
while ((match = regex.exec(text)) !== null) {
matches.push(match[0]);
}
function download(data, filename, type) {
var file = new Blob([data], {type: type});
if (window.navigator.msSaveOrOpenBlob) // IE10+
window.navigator.msSaveOrOpenBlob(file, filename);
else { // Others
var a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
}
const data = matches.join('\n');
download(data, 'data.csv', '');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment