Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a link to a search #168

Closed
look opened this issue Jun 17, 2013 · 28 comments · Fixed by #463 · May be fixed by xhad/scc#81, enterstudio/kibana#83 or 82ndAirborneDiv/kibana#43
Closed

Create a link to a search #168

look opened this issue Jun 17, 2013 · 28 comments · Fixed by #463 · May be fixed by xhad/scc#81, enterstudio/kibana#83 or 82ndAirborneDiv/kibana#43

Comments

@look
Copy link

look commented Jun 17, 2013

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.

@rashidkpc
Copy link
Contributor

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 :-)

@look
Copy link
Author

look commented Jun 17, 2013

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.

@rnavarro
Copy link

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

@rashidkpc
Copy link
Contributor

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

@look
Copy link
Author

look commented Jun 23, 2013

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

@camerondavison
Copy link

@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?

@spble
Copy link

spble commented Jul 8, 2013

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?

@rashidkpc
Copy link
Contributor

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.

@spble
Copy link

spble commented Jul 9, 2013

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 :(

@frankyaorenjie
Copy link

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. :)

@frankyaorenjie
Copy link

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

@mbicz
Copy link

mbicz commented Jul 29, 2013

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

@frankyaorenjie
Copy link

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 notifications@github.com 写道:

+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//issues/168#issuecomment-21719538
.

@devilankur18
Copy link

+1

1 similar comment
@nikicat
Copy link

nikicat commented Aug 13, 2013

+1

@frankyaorenjie
Copy link

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

@frankyaorenjie
Copy link

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

@nikicat
Copy link

nikicat commented Aug 14, 2013

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

@rashidkpc
Copy link
Contributor

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.

@rashidkpc
Copy link
Contributor

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.

@sanj75
Copy link

sanj75 commented Apr 17, 2014

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

@dshelepov
Copy link

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.

@cphillips83
Copy link

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 #662
Just my 2 cents.

@aspic
Copy link

aspic commented Jun 19, 2014

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

@vongillern
Copy link

@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

@manasdadarkar
Copy link

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 " <RANGE_GOOP> "'*' "" at line 1, column 16.
Was expecting one of:
"]" ...
"}" ...

@sanj75
Copy link

sanj75 commented Jun 13, 2015

I
On Jun 6, 2015 12:26 PM, "mdadarkar" notifications@github.com 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
#168 (comment).

@taguan
Copy link

taguan commented Jun 19, 2015

@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

spalger pushed a commit to spalger/kibana that referenced this issue Mar 3, 2016
This commit moves the logic of the request body autocomplet to use the new engine current used by url and url param suggestions.

Also change $FIELD$ & friends notation to {field}, {index} etc.

Closes elastic#168
harper-carroll pushed a commit to harper-carroll/kibana that referenced this issue Jul 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment