I created a python script that allows me via api to download the latest tests performed by a check, the problem is that it extracts too many, how can I extract only the fields that interest me from the last check?
this is my code:
from datadog_api_client import ApiClient, Configuration from datadog_api_client.v1.api.synthetics_api import SyntheticsApi
configuration = Configuration() with ApiClient(configuration) as api_client: api_instance = SyntheticsApi(api_client) response = api_instance.get_api_test_latest_results( public_id="insert your public id", )
print(response)
this is my result:
{'last_timestamp_fetched': 1661446082000, 'results': [{'check_time': 1663575065904.0, 'check_version': 18, 'device_id': 'chrome.laptop_large', 'probe_dc': 'aws:eu-west-1', 'result': {'device': {'browser': 'chrome', 'height': 1100, 'id': 'chrome.laptop_large', 'isMobile': False, 'name': 'Laptop Large', 'userAgent': 'Mozilla/5.0 (X11; Linux ' 'x86_64) AppleWebKit/537.36 ' '(KHTML, like Gecko) ' 'Chrome/105.0.5195.102 ' 'Safari/537.36 ' 'DatadogSynthetics', 'width': 1440}, 'deviceId': 'chrome.laptop_large', 'duration': 3333, 'errorCount': 5, 'errorMessage': None, 'passed': True, 'runType': 0, 'stepCountCompleted': 18, 'stepCountTotal': 18, 'timings': None, 'tunnel': False}, 'result_id': '234e33435654654634', 'status': 0}, {'check_time': 1663567865886.0, 'check_version': 18, 'device_id': 'chrome.laptop_large', 'probe_dc': 'aws:eu-west-1', 'result': {'device': {'browser': 'chrome', 'height': 1100, 'id': 'chrome.laptop_large', 'isMobile': False, 'name': 'Laptop Large', 'userAgent': 'Mozilla ' 'x86_64) AppleWebKit/537.36 ' '(KHTML, like Gecko) ' 'Chrome/ ' 'Safari/537.36 ' 'DatadogSynthetics', 'width': 1440},
I would like to extract only the following fields from this result:
-last_timestamp_fetched; -passed;
Thanks