-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
An architecture for adhoc views #448
Comments
What about allowing dashboard config files to be javascript files that pass an object to window.loadConfig? We could probably include them as a service even, if users need to be able to specify custom filters/queries programmatically? |
so there's already a dashboard.dash_load that can take a dashboard and load it. https://github.com/elasticsearch/kibana/blob/master/js/services.js#L667-L695 Should we expose that via the URL? Should you be able to pass in the entire dashboard schema via the URL? What about parameterized views? Eg, a precomposed view that just needs a few bits of information filled in, how can we do that cleanly? Could we have some special tag you could stick in the dashboard file that would get replaced with url parameters? Should we do a hash of parameters or just do it by position in the route? |
I think that building the entire dashboard via the URL could easily be supported if that's how users want to do it, why not? I don't think it's very clean, and I wouldn't want to implement my dashboards that way but it's downright simple. I thought about some sort of mapping from panel to query string, allowing users to specify in the panel config that the "username" param sets the "querySrv.list[0].query" property, but then I figured it'd be simpler to just abstract away the core properties and write a little DSL for dynamically setting the config. I think we could go as far as parsing the query string for the users, and providing it to the dynamic config file, maybe even make it simpler for them to find the query they are interested in (via some sort of unique name/id setting), and allow them to display messages like "you need to specify a username" and such. We would see the .js in the config file name (eg. "#/dashboard/dashboards/user_records.js") execute it as js within our little sandbox and they could write things like this: // extend an existing config file, could load from file system, or they could build it from scratch.
get_es_config('user_records')
.then(function (config) {
var user_query;
if (args.username) {
user_query = config.getPanel('username_query').addQuery();
user_query.query = 'username:'+args.username;
user_query.pinned = true;
config.getPanel('timeselector').timespan = '1w' || args.timespan;
} else {
throw new Error('You must specify a username parameter in the querystring');
}
loadConfig(config);
}) |
Just pushed the first iteration of this concept here: This allows for 2 ways of building dashboards. Templated JSON, and fully custom Javascript dashboard object creation. The first method, templated JSON uses mustache style variable interpolation, eg {{query}}. For example, a snippet from logstash.json might look something like:
The value of the query could then be passed to the dashboard using this url:
A full example of this can be found at: The second method is completely custom dashboard objects built from javascript. This allows you to build complex logic into your dashboard creation, for example adding or removing panels based on URL parameters. The script must build a valid dashboard object, and return it. You can add something like logstash.js to the dashboards directory and access it via:
A full example of this approach, with comments is in: In both cases, all URL parameters are accessible via the ARGS object. Eg, in the example urls above, query would be accessible via ARGS.query |
Does this work with gists? |
I'm creating this ticket for the sake of discussion.
Kibana currently has no way of generating adhoc views. This makes the following tickets challenging to implement cleanly:
#180
#402
#168
I'm not looking for solutions for specifying a query, thats simple but inflexible. I'm looking for ideas around generating dashboards schemas on the fly.
The text was updated successfully, but these errors were encountered: