-
Notifications
You must be signed in to change notification settings - Fork 31
Index Pattern functions
ytzlax edited this page Nov 2, 2017
·
2 revisions
Check if index-pattern exist
Request:
this.iframeElement = document.getElementById('iframe');
this.iframeWindow = (<HTMLIFrameElement>this.iframeElement).contentWindow;
let message={actionType: "isIndexPatternExist", indexPattern: "logstash-*"}
this.iframeWindow.postMessage(message, '*');
Response:
Use the next code to listen the response from the plugin
private iFrameAddListener() {
let that = this;
let eventMethod = "addEventListener";
let eventer = window[eventMethod];
let messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
// Listen to message from parent (or any other) window
eventer(messageEvent, this.pluginNotification);
}
private pluginNotification = (e) => {
let that = this;
let func = e.data.split('##')[0];
let res = JSON.parse(e.data.split('##')[1]);
console.log("func:", func, "res:", res);
};
this.iFrameAddListener();
Create new index-pattern
Request:
this.iframeElement = document.getElementById('iframe');
this.iframeWindow = (<HTMLIFrameElement>this.iframeElement).contentWindow;
let message={actionType: "createIndexPattern", index: "logstash-*", timeField: "@timestamp"}
this.iframeWindow.postMessage(message, '*');
Response:
Use the next code to listen the response from the plugin
private iFrameAddListener() {
let that = this;
let eventMethod = "addEventListener";
let eventer = window[eventMethod];
let messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
// Listen to message from parent (or any other) window
eventer(messageEvent, this.pluginNotification);
}
private pluginNotification = (e) => {
let that = this;
let func = e.data.split('##')[0];
let res = JSON.parse(e.data.split('##')[1]);
console.log("func:", func, "res:", res);
};
this.iFrameAddListener();
If your Index not contains time-based events don't send timeField property
Set default index-pattern
Request:
this.iframeElement = document.getElementById('iframe');
this.iframeWindow = (<HTMLIFrameElement>this.iframeElement).contentWindow;
let message={actionType: "setDefaultIndexPattern", indexPattern: "logstash-*"}
this.iframeWindow.postMessage(message, '*');
Response:
Use the next code to listen the response from the plugin
private iFrameAddListener() {
let that = this;
let eventMethod = "addEventListener";
let eventer = window[eventMethod];
let messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";
// Listen to message from parent (or any other) window
eventer(messageEvent, this.pluginNotification);
}
private pluginNotification = (e) => {
let that = this;
let func = e.data.split('##')[0];
let res = JSON.parse(e.data.split('##')[1]);
console.log("func:", func, "res:", res);
};
this.iFrameAddListener();