bondib/kibana-iframe-communicator-plugin

Error: rison decoder error

Closed this issue · 3 comments

I am having following code on my iframe side:

<script type="text/javascript">
                    function setBrowserFrameSource(){
                        alert(document.getElementById("searchval").value);
                        var myIframe = document.getElementById("guestFrame");
                        iframeUrl = myIframe.src
                        alert(iframeUrl);
                        myIframe.contentWindow.postMessage('searchRequest###' + iframeUrl, '*');
                    }

                </script>

                <p>
                <form name="f">
                    <input type="text" id="searchval" name="searchval" value=""/>
                    <input style="width:8%;" type="button" value="Go" onclick="setBrowserFrameSource(); return false;"/>
                </form>
        
                </p>
                <iframe id="guestFrame" name="guestFrame" frameborder=0 src="http://localhost:5601/app/kibana#/dashboard/AWRhEW7v3SRVv-T8QsdF?embed=true&_g=(refreshInterval%3A(display%3AOff%2Cpause%3A!f%2Cvalue%3A0)%2Ctime%3A(from%3Anow-6M%2Cmode%3Aquick%2Cto%3Anow))" height="800" width="100%">
                

When I click on the button the function does get called but I get following error on the UI

Fatal Error
Error: rison decoder error: decode input must be a string (http://localhost:5601/bundles/commons.bundle.js?v=15543:69)

Version: 5.6.2
Build: 15543

Error: Error: rison decoder error: decode input must be a string (http://localhost:5601/bundles/commons.bundle.js?v=15543:69)
[2502]/window.onerror@http://localhost:5601/bundles/commons.bundle.js?v=15543:115:13807

Also I am confused where to include the search query does it go in the URL or instead of the second parameter '*' ?

Window.postMessage() - is a reg. Web APIs.
The '*' parameter stands fro cross domain communication - you should leave it as is.

Regarding the error you're getting - you can't just send in the query info like that.
Kibana expects APP-STATE-DATA and GLOBAL-STATE-DATA objects - which should be encoded using rison.

iframeFinalUrl is your kibana URI containing the complete dashboard data such as: http://{KIBANA-HOST}/app/kibana#/dashboard/{OPTIONAL-DASHBOARD-NAME}?embed&_g={GLOBAL-STATE-DATA}&_a={APP-STATE-DATA}

Closing the issue as this is the same like #2
If there was clear indication of how to use - or a more robust framework of doing so - this won't have arrived.

Do you have any example of how to send rison encoded APP-STATE-DATA and GLOBAL-STATE-DATA objects ?