Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
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?
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
Hello, I'm trying to do something very similar but in an email message and I cannot get it to work. I have a dataset called "RECORDS" and in the scenario, I am first running the metrics, then in the next step sending an email, trying to call the record count. Within my dataset RECORDS, I believe I have the record count metric turned on but when I try to call it in my email step using this:
${filter(parseJson(stepOutput_metrics)[โprojectkey.RECORDSโ].computed, x, x.metricId == โmetricId:records:COUNT_RECORDSโ)[0].value}
When I run the step, I always get the error ' freemarker.core.ParseException
Syntax error in template "tmpl0" in line 8, column 40: Lexical error: encountered "\u2018" (8216), after "".'
Any suggestions? I'm very confused about how to get the output itself from the metrics computation (${stepOutput_metrics}) as nothing returns when I call that. Please advise.
Please always start a new thread, as otherwise threads can't be marked as solved. You can reference other threads in your post if you want. Your problem is that you need to use a name without spaces for your metrics step (like Compute_metrics) and also use that name in your formula (like stepOutput_Compute_metrics). If it doesn't work start a new thread. Thanks