Query custom assessment data
To access assessment data, you must run a custom assessment. Logging data is not saved for automatic assessments. Follow the steps below to collect and access your custom assessment logs.
Important
KQL queries are case-sensitive and the data stored in your analytics workspace is saved as lowercase strings. Brain name and assessment name must be set as lowercase or the query options noted below will fail to find any data.
Option 1: Export data to Jupyter
Exporting custom assessment data to Jupyter is a good choice if you are familiar with Python or you want to further analyze the data with custom tools and templates. The Bonsai Log Tools repo in GitHub provides a collection of useful Jupyter templates for common data analysis tasks with Bonsai data that will import data directly into Jupyter.
- Install Jupyter.
- Clone the Bonsai Log Tools repo, microsoft/bonsai-log-tools. The Bonsai Log Tools repo in GitHub is a collection of useful Jupyter templates for common data analysis tasks with Bonsai data.
- From the cloned directory, make sure you have all the requirements installed:
pip install -r requirements.txt - Open the custom_assessment_logs.ipynb notebook template in Jupyter Lab
and set the configuration variables for the training data you want to
analyze:
- In
[2], setLOG_ANALYTICS_WORKSPACE_IDto the Azure object ID of your Log Analytics Workspace. See Get your Log Analytics Workspace ID for help. - In
[9], setbrain_namewith the object name of the brain you assessed as a lowercase string. For example,hivemind. You can find the object name by right clicking the brain and selecting Brain info. - In
[9], setbrain_versionwith the numeric version of the brain you assessed. For example,2. - In
[9], setassessment_namewith the object name of your custom assessment as a lowercase string. For examplecommoncase. You can find the object name by right clicking the assessment record in the UI and selecting Assessment info.
- In
- Run the notebook.
Option 2: Query data in Azure Log Analytics
Querying assessment data in Azure Log Analytics is a good choice if you are unfamiliar with Python or already know KQL.
Important
By default, the retention period for assessment data is 30 days. You can refer to the log analytics retention period to modify it.
Sign into the Azure Portal.
Open the list of Bonsai workspaces associated with your account.
Click on the workspace you want to query logs for.
Select Logs from the General section of the portal navigation.
Paste the KQL query below into the query panel and set:
BRAIN_NAMEwith the object name of the brain you assessed as a lowercase string. For example,hivemind. You can find the object name by right clicking the brain and selecting Brain info.BRAIN_VERSIONwith the numeric version of the brain you assessed. For example,2.ASSESSMENT_NAMEwith the object name of your custom assessment as a lowercase string. For examplecommoncase. You can find the object name by right clicking the assessment record in the UI and selecting Assessment info.
EpisodeLog_CL | where BrainName_s == 'BRAIN_NAME' and BrainVersion_d == 'BRAIN_VERSION' and AssessmentName_s == 'ASSESSMENT_NAME' | join kind=inner (IterationLog_CL) on EpisodeId_g | project AssessmentName = AssessmentName_s, EpisodeId = EpisodeId_g, IterationIndex = IterationIndex_d, Timestamp = Timestamp_t, SimConfig = parse_json(SimConfig_s), SimState = parse_json(SimState_s), SimAction = parse_json(SimAction_s), Reward = Reward_d, CumulativeReward = CumulativeReward_d, GoalMetrics = parse_json(GoalMetrics_s), Terminal = Terminal_b, FinishReason = FinishReason_s, LessonIndex = LessonIndex_d, EpisodeType = EpisodeType_s | order by EpisodeId asc, IterationIndex ascClick Export and select Export to CSV - all columns to export up to 64MB of log data to CSV. If you want to export more than 64MB, you will need to paginate the query and run it multiple times.
Note
The first time you open the Logs page, Azure will present you with an overlay full of pre-package queries. To avoid seeing this panel every time, make sure the slider at the top of the panel labeled "Show every time" is turned off.