# Is there a way to get the global timeframe?

**URL:** <https://community.dynatrace.com/t/is-there-a-way-to-get-the-global-timeframe/45455>\
**Category:** Developer Q&A Forum\
**Tags:** dql, custom-app, app-functions\
**Created:** [May 6, 2024, 8:51pm UTC](https://community.dynatrace.com/t/is-there-a-way-to-get-the-global-timeframe/45455 "2024-05-06T20:51:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeJoyerPB](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@NeJoyerPB](https://community.dynatrace.com/u/NeJoyerPB)\
**Post date:** [May 6, 2024, 8:51pm UTC](https://community.dynatrace.com/t/is-there-a-way-to-get-the-global-timeframe/45455/1 "2024-05-06T20:51:36Z")

</div>

If someone is investigating an issue, they’ll be drilling into a specific timeframe in Dynatrace.

I want them to be able to open my app to get additional information laid out for that timeframe.

Is there a way for me to programmatically get what global timeframe they were using before they switched to my app? That way I can perform targeted DQL queries.

---

<div class="post-metadata">

**Author:** ![sinisa\_zubic](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/sinisa_zubic/32/32498_2.png) [@sinisa\_zubic](https://community.dynatrace.com/u/sinisa_zubic)\
**Post date:** [May 8, 2024, 8:53am UTC](https://community.dynatrace.com/t/is-there-a-way-to-get-the-global-timeframe/45455/2 "2024-05-08T08:53:38Z")

</div>

hi&nbsp;[@NeJoyerPB](https://community.dynatrace.com/user/56775)

currently it depends on from which app/screen you are switching from to your app. Can you share some details about the user journey you have in mind? from which app or screen do you usually jump from to your custom app?

Best,  
Sini

---

<div class="post-metadata">

**Author:** ![rich20509](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rich20509](https://community.dynatrace.com/u/rich20509)\
**Post date:** [May 8, 2024, 11:34am UTC](https://community.dynatrace.com/t/is-there-a-way-to-get-the-global-timeframe/45455/3 "2024-05-08T11:34:01Z")

</div>

Hello mate,

You can achieve this by retrieving the global timeframe from Dynatrace programmatically before the user switches to your app.

# Pseudocode to retrieve global timeframe from Dynatrace

def get\_global\_timeframe():  
# Make API call to Dynatrace to retrieve global timeframe  
global\_timeframe = dynatrace\_api.get\_global\_timeframe()  
return global\_timeframe

# Example function to perform targeted DQL queries using the global timeframe  
def perform\_targeted\_queries():  
global\_timeframe = get\_global\_timeframe()  
# Use global\_timeframe to perform targeted DQL queries  
targeted\_queries = f"SELECT \* FROM your\_data WHERE timeframe = {global\_timeframe}"  
# Execute targeted queries  
results = execute\_queries(targeted\_queries)  
return results

Hope the above code will be helpful

---

<div class="post-metadata">

**Author:** ![NeJoyerPB](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@NeJoyerPB](https://community.dynatrace.com/u/NeJoyerPB)\
**Post date:** [May 9, 2024, 3:25pm UTC](https://community.dynatrace.com/t/is-there-a-way-to-get-the-global-timeframe/45455/4 "2024-05-09T15:25:05Z")

</div>

Our developers sometimes log really large payloads that are important for troubleshooting. The payload length exceeds the max length, so our logging package breaks it into multiple entries but stamps a guid on all the entries so that they can be correlated back together (the same unique guid on all the entries that the long one was broken into).

The application that I’m trying to build is:

They find one of their log lines that has been broken into multiple. They grab the guid that was added to their message. They go to my application and paste in the guid. The application then searches Grail for all of the entries with that guid, stitches them together, and presents them with a view of their original log entry as if it was never broken up into multiple entries.

I could just query the entire corpus of logs from all dates, but that would be an expensive query. So if they were looking at a 1 hour time period when they saw that log entry, then if I could get the timeframe that they were looking at and include it in my query, that would make it faster and cheaper. I’d rather not have to make them enter their timeframe again.

If there is a get\_global\_timeframe() command that I can run in the context of my app, I think that would be exactly what I need. I’m having trouble finding it in [the documentation](https://developer.dynatrace.com/reference/sdks/) though.

---

<div class="post-metadata">

**Author:** ![NeJoyerPB](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@NeJoyerPB](https://community.dynatrace.com/u/NeJoyerPB)\
**Post date:** [May 13, 2024, 2:39pm UTC](https://community.dynatrace.com/t/is-there-a-way-to-get-the-global-timeframe/45455/5 "2024-05-13T14:39:00Z")

</div>

What I ended up doing was changing my logger to stamp the unique guid combined with the exact timestamp into a single field. Then my app’s user just needs to paste that in and it gives me all the information that I need to find the relevant logs.
