Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there a way to get the global timeframe?


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.


Dynatrace Champion
Dynatrace Champion

hi @NeJoyer 


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?



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 though.

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.


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

Featured Posts