Javascript Webapp - Return Dataset Metrics to HTML Report

gblack686 Partner, Registered Posts: 62 Partner

What is the easiest way to load dataset metric variables into a webapp HTML? I understand how to retrieve the metrics in Python (dataset.metrics.last_values) but I can't figure out how to render them to the HTML, in fact, I can't even successfully log them in the console. Simply pasting the sample code below into my JS file fails to log anything in the console.

sampling : 'head',
limit : 15000},
function(dataFrame) {
console.log("dataset load succeed");

My html looks something like <h1>{{variable}}</h1>

Am i missing a function?


  • MickaelH
    MickaelH Dataiker, Registered Posts: 31 Dataiker


    First as a side remark, please note that the Javascript API is not as rich as:

    • the python APIs that you can use directly in the python backend code. You can take a look at the New Code Webapp > Standard > Simple web app to get started for a simple illustration
    • the REST API that you can call directly from the Javascript code. You can take a look at the New Code Webapp > Standard > Advanced web app using Dataiku REST API for a simple illustration

    For the dataiku.fetch from the Javascript API it will return a DataFrame object from which you won't be able to load the metrics.

    If you are interested in the metrics of your dataset you may want to consider creating a metrics dataset from the dataset and fetch this metrics dataset:

    • you can create a dataset from metrics data in the Status tab of a dataset and then clicking on the cogwheel on the right of the screen
    • you can also create a new metric dataset using the Create new dataset > Internal > Metrics

    That being said, if you indeed have a dataset 'mydataset' in the project where the webapp was created you should be able to perform the dataiku.fetch that you mentioned.

    Can you confirm that when you have the browser console opened you don't see the log "dataset load succeed" ? Do you have any error logged in this console?

    If not, a possible reason for that would be that the security settings for this webapp or dataset have not been properly configured. Have you configured in the Settings tab of the webapp the Security settings for the 'mydataset' so that you can actually fetch information from this dataset?

    I hope this helps.


Setup Info
      Help me…