# Querying History Data

**URL:** <https://community.temporal.io/t/querying-history-data/613>\
**Category:** Community Support\
**Tags:** java-sdk, history, web-ui\
**Created:** [September 12, 2020, 3:46am UTC](https://community.temporal.io/t/querying-history-data/613 "2020-09-12T03:46:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![darewreck](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@darewreck](https://community.temporal.io/u/darewreck)\
**Post date:** [September 12, 2020, 3:46am UTC](https://community.temporal.io/t/querying-history-data/613/1 "2020-09-12T03:46:46Z")

</div>

**Proto** : [api/service.proto at master · temporalio/api · GitHub](https://github.com/temporalio/api/blob/master/temporal/api/workflowservice/v1/service.proto)  
**Example** : [How can I get a workflow state/status from an external application in java?](https://community.temporal.io/t/how-can-i-get-a-workflow-state-status-from-an-external-application-in-java/390)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/1X/e97e54e914165191c93ee7973e413fdb64e8666e.jpeg)  
Hi, Is there any documentation on the params. specifically interested in how to process the different pages. Does it just return a page and i’m suppose to use the next token to grab the next? or do you have any example of processing the data.

since the UI view doesn’t really show the parent to child to child relationship clearly, i wanted to just pull the data and just render the nodes myself. Wondered if there is an easy way to do that with getting the data in one shot or will it require multiple queries

For example, on the UI I notice that you are able to filter by child, workflow, activity types. When i look at the interface, I’m only seeing the ability to filter by

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/1X/0f16095a10902041e6450bdefd0d7f50ebb20f22.png)

Also it’s not clear how you identify what event type belong to child. Do you just filter to see if “child” is in the event type?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/1X/826f53251b8239cc5b1b68c3648af74c57acdc72.png)

Example, is child workflow enum value 29 - 36, and activity is enum value 10-16, and everything else falls under workflow?,

Also how do you get the `timeElapsedDisplay `. From the json in the UI, it’s not clear how you get this value from the API other then subtracting the event time from the first event.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/1X/8af9a224086d3e2606998a9b1c2ce172a6175b8d.png)

Thanks,  
Derek

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 12, 2020, 7:39pm UTC](https://community.temporal.io/t/querying-history-data/613/2 "2020-09-12T19:39:04Z")

</div>

I would recommend against history parsing approach to render information in the UI. Have you considered maintaining a list of child workflows in the parent and returning the relevant information through a query?

Another option is to enable ElasticSearch for list queries. These queries support predicates which would allow listing all children of a given workflow.

---

<div class="post-metadata">

**Author:** ![darewreck](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@darewreck](https://community.temporal.io/u/darewreck)\
**Post date:** [September 12, 2020, 9:09pm UTC](https://community.temporal.io/t/querying-history-data/613/3 "2020-09-12T21:09:50Z")

</div>

1. Why do you recommend against using the history? It looks like the temporal UI is using the history endpoints to render the UI for summary as well and not just history. When i look at the request for temporal web, it looks like for the summary it’s pulling information from ‘’/api/namespaces/:namespace/workflows/:workflowId/:runId’’ and which make two api calls; one to `describeWorkflow` and the other to `getWorkflowExecutionHistoryAsync`. It then just aggregates the data from the history based on workflowId. Interestingly it’s not clear why that is done since it looks like all the data from describeworkflow can be derived from the history data.

2. What happens if the workflow is complete, wouldn’t the data be lost at that point and you won’t have any query endpoint to hit? I thought you could only query the workflow if it was still active?

3. When you say elastic search, are you referring to setting up Temporal service with an elastic search db correct? Right now we have it setup with a sql datastore.

Thanks  
Derek

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 12, 2020, 11:31pm UTC](https://community.temporal.io/t/querying-history-data/613/4 "2020-09-12T23:31:14Z")

</div>

> 1. Why do you recommend against using the history? It looks like the temporal UI is using the history endpoints to render the UI for summary as well and not just history. When i look at the request for temporal web, it looks like for the summary it’s pulling information from ‘’/api/namespaces/:namespace/workflows/:workflowId/:runId’’ and which make two api calls; one to `describeWorkflow` and the other to `getWorkflowExecutionHistoryAsync` . It then just aggregates the data from the history based on workflowId. Interestingly it’s not clear why that is done since it looks like all the data from describeworkflow can be derived from the history data.

It should not be done this way. Describe output should be enough for the summary page. @Ruslan could you clarify?

> What happens if the workflow is complete, wouldn’t the data be lost at that point and you won’t have any query endpoint to hit? I thought you could only query the workflow if it was still active?

You can query closed workflows without any problem up to the retention period. But after the retention period, the execution history is not available as well.

> When you say elastic search, are you referring to setting up Temporal service with an elastic search db correct? Right now we have it setup with a sql datastore.

No, ES used for visibility queries only. SQL or Cassandra are still required for all other DB operations.

---

<div class="post-metadata">

**Author:** ![darewreck](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@darewreck](https://community.temporal.io/u/darewreck)\
**Post date:** [September 12, 2020, 11:45pm UTC](https://community.temporal.io/t/querying-history-data/613/5 "2020-09-12T23:45:23Z")

</div>

What would be nice if the `describe output` also had the workflow input and output? This would help see what input is actually being passed in.

@Ruslan Here is the snippet of code that I see in the temporal web code for the summary that relies on the history API to get additional data.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/1X/81a2e93440c186c7e55df9b1cb7ab46232587bdf.png)

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 12, 2020, 11:47pm UTC](https://community.temporal.io/t/querying-history-data/613/6 "2020-09-12T23:47:58Z")

</div>

I see. Note that it does it only for the archived workflows which don’t provide any information through describe. IMHO it is not really good design. I would rather include “describe” output into the archived file.

---

<div class="post-metadata">

**Author:** ![darewreck](https://avatars.discourse-cdn.com/v4/letter/d/c37758/32.png) [@darewreck](https://community.temporal.io/u/darewreck)\
**Post date:** [September 12, 2020, 11:58pm UTC](https://community.temporal.io/t/querying-history-data/613/7 "2020-09-12T23:58:21Z")

</div>

Just to clarify, are you saying that the history data (archive) doesn’t provide any of the information in describe.

Is there any plans to move the describe output into the history data (achieve)?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [September 13, 2020, 12:07am UTC](https://community.temporal.io/t/querying-history-data/613/8 "2020-09-13T00:07:46Z")

</div>

I looked at the code more closely. It reads only the first event which I think is OK. I’m against parsing the whole history to extract some information. Assuming that history can be up to 200k events and 100mb in size it can be potential performance issue.

---

<div class="post-metadata">

**Author:** ![Ruslan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ruslan/32/66_2.png) [@Ruslan](https://community.temporal.io/u/Ruslan)\
**Post date:** [September 14, 2020, 5:15pm UTC](https://community.temporal.io/t/querying-history-data/613/9 "2020-09-14T17:15:30Z")

</div>

@darewreck  
As for the elapsed time calculation: it is done on the client/Web side using this helper [https://github.com/temporalio/web/blob/d1d9772a1482b84d5a1a7c96f13e30c7f78471c9/client/routes/workflow/helpers/get-time-elapsed-display.js](https://github.com/temporalio/web/blob/d1d9772a1482b84d5a1a7c96f13e30c7f78471c9/client/routes/workflow/helpers/get-time-elapsed-display.js)

History events filtering by type is done on the Web side as well in the view layer: [https://github.com/temporalio/web/blob/44a83dae53a9af237b1b48c786c5a3a725c9f248/client/routes/workflow/history.vue#L355](https://github.com/temporalio/web/blob/44a83dae53a9af237b1b48c786c5a3a725c9f248/client/routes/workflow/history.vue#L355) . This implementation will likely change due to performance reasons especially for large histories

---

<div class="post-metadata">

**Author:** ![Ruslan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ruslan/32/66_2.png) [@Ruslan](https://community.temporal.io/u/Ruslan)\
**Post date:** [September 15, 2020, 6:50pm UTC](https://community.temporal.io/t/querying-history-data/613/10 "2020-09-15T18:50:27Z")

</div>

@darewreck

I have an item tracking visualization of parent to child relationship on Web UI.  
For now i have some other items as top priorities to address, then as i start working on `parent-child relationship` it can be quite valuable to hear your input over the proposed UX and see whether it serves your needs 🙌

If you are interested to review and give feedback, feel free to dm me here

---

<div class="post-metadata">

**Author:** ![Ruslan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ruslan/32/66_2.png) [@Ruslan](https://community.temporal.io/u/Ruslan)\
**Post date:** [September 20, 2020, 1:00am UTC](https://community.temporal.io/t/querying-history-data/613/11 "2020-09-20T01:00:08Z")

</div>

This topic was automatically closed after 2 days. New replies are no longer allowed.
