# Kibana Plugins: Using \_g and \_a in URL to pass state

**URL:** <https://discuss.elastic.co/t/kibana-plugins-using-g-and-a-in-url-to-pass-state/137095>\
**Category:** Kibana\
**Created:** [June 22, 2018, 11:56pm UTC](https://discuss.elastic.co/t/kibana-plugins-using-g-and-a-in-url-to-pass-state/137095 "2018-06-22T23:56:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarajapu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jarajapu/32/28985_2.png) [@jarajapu](https://discuss.elastic.co/u/jarajapu)\
**Post date:** [June 22, 2018, 11:56pm UTC](https://discuss.elastic.co/t/kibana-plugins-using-g-and-a-in-url-to-pass-state/137095/1 "2018-06-22T23:56:03Z")

</div>

I noticed that Kibana is using the \_g and \_a parameters in the URL to let the user set a context for elements such as Time Picker and application specific controls. This seems to be the standard way to pass state through URI.

For instance, it is common for a URL such as the one below to set a time window as well as pick what columns are displayed in the discover mode.

#/discover?\_g=(refreshInterval:(display:Off,pause:!f,value:0),time:(from:now-6M,mode:quick,to:now))&\_a=(columns:!(\_source),index:dc10c5e0-758f-11e8-8d34-9705a1fc6f94,interval:auto,query:(language:lucene,query:''),sort:!(timestamp,desc))

My Question is : How does one do the same thing within the context of a Kibana plugin ? I have a plugin that works well but the user is required to change to a desired state every time, after they land on a default page. I want to provide a dynamic URL which stores session state and helps someone land directly at a desired state.

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [June 26, 2018, 12:10am UTC](https://discuss.elastic.co/t/kibana-plugins-using-g-and-a-in-url-to-pass-state/137095/2 "2018-06-26T00:10:18Z")

</div>

`_g` is global state, and it can be updated via the `globalState` angular service. Here is an example of how the timepicker updates the URL via the global service [https://github.com/elastic/kibana/blob/6.3/src/ui/public/timepicker/kbn\_global\_timepicker.js#L12](https://github.com/elastic/kibana/blob/6.3/src/ui/public/timepicker/kbn_global_timepicker.js#L12)

`_a` is the application state. You can get the application state with the `getAppState` angular service. Then just call the `save` method once you have updated the state as needed.

We are in the process of removing angular from Kibana so these will be changing over future releases so be prepared for breaks between minor Kibana releases.

---

<div class="post-metadata">

**Author:** ![jarajapu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jarajapu/32/28985_2.png) [@jarajapu](https://discuss.elastic.co/u/jarajapu)\
**Post date:** [July 2, 2018, 7:46pm UTC](https://discuss.elastic.co/t/kibana-plugins-using-g-and-a-in-url-to-pass-state/137095/3 "2018-07-02T19:46:48Z")

</div>

Thank you ! that helps.

---

<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 30, 2018, 7:46pm UTC](https://discuss.elastic.co/t/kibana-plugins-using-g-and-a-in-url-to-pass-state/137095/4 "2018-07-30T19:46:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
