Community Conundrum 25:Feature Visualization is now live! Read More

Returning the Metric Record Count in a Slack message

Level 1
Returning the Metric Record Count in a Slack message

Hello,



I have set up a scenario which returns a Slack message upon completion, along with some standard variables (e.g., ${scenarioName}). By following the documentation here https://doc.dataiku.com/dss/latest/scenarios/variables.html ("Retrieving the value of a metric") I have been able to get the entire output from the metrics computation (${stepOutput_the_metrics}).



However, I would like to limit the content of the Slack message to the number of rows of the dataset (i.e., the value of the COUNT_RECORDS metric). When I try and follow the rest of the documentation, I cannot follow; especially the section "If the goal is to retrieve the value of the metric col_stats:MIN:cost, with a bit of filtering one obtains this status with ${filter(parseJson(stepOutput_the_metrics)[‘PROJ.computed’].computed, x, x.metricId == ‘col_stats:MIN:cost’)[0].value}"



I want to replicate this, but for my circumstances, but I am unable to. What does the x refer to here? 



If I wanted to the value of the metric "metricId:records:COUNT_RECORDS", how would I do this?

0 Kudos
1 Reply
Dataiker
Dataiker

Hi Mark,



Let's assume that inside your scenario, you have one "Compute metrics" step named "the_metrics", which has one dataset called "test" in the project "SANDBOX" with the metric "records:COUNT_RECORDS" configured.





Then you can retrieve the value of the metric using:



${filter(parseJson(stepOutput_the_metrics)[‘SANDBOX.test’].computed, x, x.metricId == ‘records:COUNT_RECORDS’)[0].value}



I put in bold the parameters that you need to change:



1. Name of the "Compute metrics" step: "the_metrics"



2. Project key: "SANDBOX"



3. Dataset name: "test"



4. Metric identifier: "records:COUNT_RECORDS"



Hope it helps,



Alex

0 Kudos
Labels (3)