Kibana: Create a link to a search

Created on 17 Jun 2013  ·  28Comments  ·  Source: elastic/kibana

I would like to be able to create a link to a search, so I can create links to Kibana from our admin dashboard to show a particular user's logs.

I looked around for this functionality and couldn't find it, but correct me if I'm wrong.

enhancement

Most helpful comment

Just merged the branch

I'm still working on ideas for nicely allowing the configuration of template parameters via the browser. For now have 3 options:

Method 1

  1. Save a dashboard to dashboards/myDashboardName.json
  2. Open that file and change any parameters you want to be able to template to use the {{ARGS.my_url_parameter}} syntax
  3. Navigate to http://localhost:8000/index.html#/dashboard/file/myDashboardName.json?my_url_parameter=stuff

See https://github.com/elasticsearch/kibana/blob/master/dashboards/logstash.json for an example of a templated dashboard

Method 2

  1. This is sort of a work around
  2. Lets say you want to create a "query" URL parameter
  3. Enter something like this into the query panel (but do not hit search)
    kibana_3
  4. Save your dashboard to Elasticsearch with some name, say, Awesomesauce
  5. Navigate to http://localhost:8000/index.html#/dashboard/elasticsearch/Awesomesauce?query=somequeryhere

Method 3 (advanced users only)

  1. This method requires you know javascript
  2. Create a javascript file in dashboards/. Eg dashboards/awesomesauce.js
  3. In this file, use javascript to construct an object that contains a Kibana dashboard.
  4. URL parameters are available on the ARGS object
  5. Return the object as the last thing the script does
  6. Navigate to http://localhost:8000/index.html#/dashboard/script/awesomesauce.js?someparam=1,2,3,4,5

See https://github.com/elasticsearch/kibana/blob/master/dashboards/logstash.js for an example of a scripted dashboard.

All 28 comments

There is currently no way to generate links to searchs via a url parameter, but there are several ways to link to saved searches/dashboards. Queries persist on the dashboard when it is saved

Examples:
http://demo.kibana.org/#/dashboard/elasticsearch/American%20Gun%20Deaths links to dashboard saved in ES
http://demo.kibana.org/#/dashboard/file/newtown links to dashboard defined in dashboards/newtown

You can also click the share link in the Dash Control panel to generate a temp link that lives for 30 days by default.

If you were feeling particularly hacky you could write a script that generated dashboards from some parameter and stick it in the dashboards directory, but thats probably not a great idea :-)

Yeah, I want to be able to generate a link that would show all records of a certain action by a user. I saw the example in the docs of using chef to define dashboards but it seemed pretty hacky as a way to implement this.

To extend this further, it would be nice to dynamically keep the search filter in the URL temporarily such that a page refresh doesn't completely bork your results

Storing the state in the url is not feasible. Storing it in html5 localStorage might be. Something to think about.

For what is worth, we deployed Kibana 2 and are using its serialized JSON URL hash parameter to link to the logs search.

@rashidkpc Why is it not feasible? Couldn't it use something like https://github.com/browserstate/history.js and just muck with the url that way?

This feature was available in the previous version of Kibana, where you could just base64 encode a json string, tack it onto the URL and it used that as search terms.

I don't understand why the current version of Kibana can't do the same thing? Just have the JS parse an appropriate part of the URL, then put the search terms into the search box and perform the search. Surely you could just copy it straight from the URL and put it into the search box as the page loads.

Is there any intention to bring this feature back?

The reason is because there is not a single way to populate a query. It could be in a stringquery input, but it could also be on a specific panel, or it could be multiple queries, or multiple queries generated by derivequeries. So passing a single query in the URL doesn't really work out. Storing the entire state in the URL would make for a -huge- URL. A quick test of a simple dashboard works out to a ~9000 character URL, rison would make it a bit smaller. Its not technically a problem, modern browsers can handle URLs much much larger.

It would be great to have the option of supplying such a string to the URL, so that dashboards could be generated and loaded on the fly.
The lack of this feature in K3 broke one of my major use cases for Kibana and as such, I am unable to use Kibana 3 until this is resolved :(

I stand beside @spble. One of my most important use case of kibana is the url-jumping feature in previous kibana. In my situation, I'd like to wrap kibana query-semantics in my own app and pass these semantics to kibaba (just like kibana2).

It would be really cool if this feature is enable in the future. :)

I've make some simple code on panels/dashcontrol/module.js to enable this little feature. I'll complete in recent time.

+1 on this feature.. Lack of it took a big use case for us down.

i have made simple on js so that you can pass some parameters in url and
the angular.js will compose these parameters in search box.

Frank Yao
Shanghai @VIPSHOP
From my iPhone

在 2013-7-29,21:29,Michal Bicz [email protected] 写道:

+1 on this feature.. Lack of it took a big use case for us down.


Reply to this email directly or view it on
GitHubhttps://github.com/elasticsearch/kibana/issues/168#issuecomment-21719538
.

+1

+1

I'm trying to move codes on old kibana3 to new kibana3 today

I've made a pull request #361 . You can found a solution there. :)

Oh, thanks!
But I need to pass url parameter to derivequery or filter.

I've just pushed the first code to my own repo for accomplishing this in a flexible way. It allows for any dashboard or panel attribute to be set via the URL, with configurable URL parameter naming, without any panel or service needing to really know about it. The solution is comprised of 2 different ways of templating dashboards, mustache (eg {{query}}) templated JSON, and totally custom javascript dashboard building.

See #448 for usage details.

Just merged the branch

I'm still working on ideas for nicely allowing the configuration of template parameters via the browser. For now have 3 options:

Method 1

  1. Save a dashboard to dashboards/myDashboardName.json
  2. Open that file and change any parameters you want to be able to template to use the {{ARGS.my_url_parameter}} syntax
  3. Navigate to http://localhost:8000/index.html#/dashboard/file/myDashboardName.json?my_url_parameter=stuff

See https://github.com/elasticsearch/kibana/blob/master/dashboards/logstash.json for an example of a templated dashboard

Method 2

  1. This is sort of a work around
  2. Lets say you want to create a "query" URL parameter
  3. Enter something like this into the query panel (but do not hit search)
    kibana_3
  4. Save your dashboard to Elasticsearch with some name, say, Awesomesauce
  5. Navigate to http://localhost:8000/index.html#/dashboard/elasticsearch/Awesomesauce?query=somequeryhere

Method 3 (advanced users only)

  1. This method requires you know javascript
  2. Create a javascript file in dashboards/. Eg dashboards/awesomesauce.js
  3. In this file, use javascript to construct an object that contains a Kibana dashboard.
  4. URL parameters are available on the ARGS object
  5. Return the object as the last thing the script does
  6. Navigate to http://localhost:8000/index.html#/dashboard/script/awesomesauce.js?someparam=1,2,3,4,5

See https://github.com/elasticsearch/kibana/blob/master/dashboards/logstash.js for an example of a scripted dashboard.

I figured the default dashboard works but how do I specify a timerange. e.g. this is the url I have

http://plmgmtlogger2.prodlabs.local/k3/#/dashboard/file/default.json?query=field1:"value1" AND field2:"value2"
but I dont know how to specify a custom timerange

All three workarounds posted above suffer from the fact that they are not "sticky". If you open such a dashboard and then Save it, you may lose URL query substitution. So you have to remember to reapply the patch or syntax every time you define or redefine a config. This becomes a major problem if you expose configuration customization to users.

RE: query string potentially coming from multiple sources. Why not use precedence? I.e.: URL query overrides anything saved by the configuration, etc.

This has helped me tremendously and just wanted to give a thanks first.

As for the saving issue, I think the quickest and easiest way to solve it would be to have a query flag to suppress the parsing so we could get the raw template back and modify it. Maybe something like

?parseArgs=0

This is in reference to https://github.com/elasticsearch/kibana/issues/662
Just my 2 cents.

@sanj75 You could try to add @datefield:["now-1h" TO "now"] as a second parameter

@dshelepov and @cphillips83 - I too have run into this issue. My work around to prevent accidental overwriting of the the board is to turn off saving to elastic search and only allow saves via export. Click on the gears in the upper right corner of the entire board and make it look like this:

image

Is the {{ARGS=query || '_'}} option supported for Kibana 3? I am getting the following error when saving the dashboard
Caused by: org.apache.lucene.queryparser.classic.ParseException: Cannot parse '{{ARGS.query || '_'}}': Encountered " "\'*\' "" at line 1, column 16.
Was expecting one of:
"]" ...
"}" ...

I
On Jun 6, 2015 12:26 PM, "mdadarkar" [email protected] wrote:

Is the {{ARGS=query || '
_'}} option supported for Kibana 3? I am getting the following error when
saving the dashboard Caused by:
org.apache.lucene.queryparser.classic.ParseException: Cannot parse
'{{ARGS.query || '_'}}': Encountered " "\'*\' "" at line 1, column 16.
Was expecting one of:
"]" ...
"}" ...


Reply to this email directly or view it on GitHub
https://github.com/elastic/kibana/issues/168#issuecomment-109639441.

@mdadarkar I ran into the same issue.
In fact, the solution is in the documentation https://www.elastic.co/guide/en/kibana/3.0/templated-and-scripted-dashboards.html
Templates and scripts must be stored on disk, storing them to Elasticsearch is not supported.
You have to write your .json or .js file and store it on app/dashboards, you cannot just load your template on elasticsearch

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timroes picture timroes  ·  3Comments

snide picture snide  ·  3Comments

timmolter picture timmolter  ·  3Comments

socialmineruser1 picture socialmineruser1  ·  3Comments

cafuego picture cafuego  ·  3Comments