# How to create visualization on the fly using a script

**URL:** <https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255>\
**Category:** Kibana\
**Created:** [September 28, 2015, 11:43am UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255 "2015-09-28T11:43:21Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)\
**Post date:** [September 28, 2015, 11:43am UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/1 "2015-09-28T11:43:21Z")

</div>

Hi,

I have some requirement where I need to create different visualization for different users which will differ very slightly on the query param.So, I am considering to create a script which will enable me to do this.Have anyone done this on Kibana 4.Some pointers on how to create visualization using query would be of great help.

I would also like to create Dashboards on the fly but that can wait till I get this one sorted out.

Thanks  
Abhijit

---

<div class="post-metadata">

**Author:** ![tbragin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tbragin/32/45166_2.png) [@tbragin](https://discuss.elastic.co/u/tbragin)\
**Post date:** [October 6, 2015, 3:23am UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/2 "2015-10-06T03:23:30Z")

</div>

Most of the parameters you need to create visualizations and dashboards are stored in the URL state in Kibana 4. After creating a sample vis or dashboard, you should be able to examine the URL and decide what to parameterize.

---

<div class="post-metadata">

**Author:** ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)\
**Post date:** [October 6, 2015, 5:28am UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/3 "2015-10-06T05:28:07Z")

</div>

Thanks for the reply.I am already able to do that.  
I believe all the API's are exposed as REST urls. So, that helped me a lot to understand the workings myself.I am creating the search query first with this endpoint [http://localhost:5601/elasticsearch/.kibana/search/create\_search\_1](http://localhost:5601/elasticsearch/.kibana/search/create_search_1) with appropriate JSON input. Same goes for the Visualization and Dashboard.I am able to replicate all the three steps to create a Dashboard with my custom query. For next step I am building my custom application to generate all the Dashboards automatically.

---

<div class="post-metadata">

**Author:** ![Rajeev\_Gaurav](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@Rajeev\_Gaurav](https://discuss.elastic.co/u/Rajeev_Gaurav)\
**Post date:** [February 8, 2016, 9:57am UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/4 "2016-02-08T09:57:02Z")

</div>

Hi Abhijit,

I am working in an application in which I want to create the visualization and dashboard automatically for the index loaded in elastic search.Can you help me on it . It would be of great help.

Thanks and Best Regards,  
Rajeev

---

<div class="post-metadata">

**Author:** ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)\
**Post date:** [February 8, 2016, 10:16am UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/5 "2016-02-08T10:16:03Z")

</div>

Rajeev,  
There are three things you need to build.  
1.Search  
2.visualization  
3.Dashboard

Create JSON for all these objects and pass this to "/search/" ,"/visualization/","/dashboard/" as POST req and you will be done.Most of the work involves on building the JSON to pass to this URL.Observe some visualization in Kibana and try chaging some small param and execute it from your code. Next try building the whole JSON on our own.

---

<div class="post-metadata">

**Author:** ![Rajeev\_Gaurav](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@Rajeev\_Gaurav](https://discuss.elastic.co/u/Rajeev_Gaurav)\
**Post date:** [February 9, 2016, 5:54pm UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/6 "2016-02-09T17:54:47Z")

</div>

Thanks a lot for replying .I am able to create the json but when I am importing the visualisation in kibana manually it ask to create the index in kibana. Can you help me that How should I create index in kibana programattically and also let me know how can I automate the importing of json files of visualisation and dashboard.

---

<div class="post-metadata">

**Author:** ![tbragin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tbragin/32/45166_2.png) [@tbragin](https://discuss.elastic.co/u/tbragin)\
**Post date:** [February 9, 2016, 6:12pm UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/7 "2016-02-09T18:12:52Z")

</div>

At the moment, there is no API in the Kibana server for automatically creating index patterns, but it's coming in 5.0: [https://github.com/elastic/kibana/pull/5213](https://github.com/elastic/kibana/pull/5213)

---

<div class="post-metadata">

**Author:** ![abhijitdeka11](https://avatars.discourse-cdn.com/v4/letter/a/c5a1d2/32.png) [@abhijitdeka11](https://discuss.elastic.co/u/abhijitdeka11)\
**Post date:** [February 10, 2016, 5:18am UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/8 "2016-02-10T05:18:49Z")

</div>

I guess you can use the trick of index\* regular expression on index. I think Kibana automatically imports all indexes starting with some\_index\_name\* if you provide it manually once.  
Regarding auto imoprt of JSON you can use the rest api's "/search/" ,"/visualization/","/dashboard/"

---

<div class="post-metadata">

**Author:** ![Rajeev\_Gaurav](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@Rajeev\_Gaurav](https://discuss.elastic.co/u/Rajeev_Gaurav)\
**Post date:** [February 10, 2016, 6:24pm UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/9 "2016-02-10T18:24:42Z")

</div>

I am bit new to ELK stack and not able to understand How can I use rest api's rest api's "/search/" ,"/visualization/","/dashboard/" in my C# program to import the JSON file. At Present I am able to get the dashboard and visualisation in one JSON file Which works very well on importing manually.  
Also I tried the trick to create index on kibana but it won't work.

---

<div class="post-metadata">

**Author:** ![timtian](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@timtian](https://discuss.elastic.co/u/timtian)\
**Post date:** [February 25, 2016, 6:44am UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/10 "2016-02-25T06:44:45Z")

</div>

when will the 5.0 be released？ thxs!

---

<div class="post-metadata">

**Author:** ![timtian](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@timtian](https://discuss.elastic.co/u/timtian)\
**Post date:** [February 25, 2016, 6:50am UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/11 "2016-02-25T06:50:18Z")

</div>

Also, what's the compatible version of ES and logstash to work with kibana5?

thanks,

---

<div class="post-metadata">

**Author:** ![TonyPoiSpinner](https://avatars.discourse-cdn.com/v4/letter/t/5f8ce5/32.png) [@TonyPoiSpinner](https://discuss.elastic.co/u/TonyPoiSpinner)\
**Post date:** [April 25, 2016, 2:18pm UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/12 "2016-04-25T14:18:33Z")

</div>

Hello,

Maybe it's a bit late but I have the same need as you do 🙂  
I sorted it this way : [How to put a visualization directly in Kibana/ElasticSearch?](https://discuss.elastic.co/t/how-to-put-a-visualization-directly-in-kibana-elasticsearch/48325)

I'll soon do the dashboard part, now the visualizations part is okay 🙂

See you

Tony

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:55pm UTC](https://discuss.elastic.co/t/how-to-create-visualization-on-the-fly-using-a-script/31255/13 "2017-07-06T13:55:13Z")

</div>


