Issues in embedding charts in another application

We used a library to embed one of the charts that we created using metabase onto our own platform. Unfortunately, it says that “There is a problem displaying this chart”.

This is the link to the library.

I love Metabase and want to use it for all the visualization in our software. Pls help us do the same!
Thanks in advance.

Hi @ServerLord

Please post “Diagnostic Info” from Admin > Troubleshooting.
Check for more detailed error in Admin > Troubleshooting > Logs.
And post the code you’re using for the embed (without the secret).

Also check out some of the reference examples:
https://github.com/metabase/embedding-reference-apps

{
“browser-info”: {
“language”: “en-GB”,
“platform”: “Linux x86_64”,
“userAgent”: “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.192 Safari/537.36”,
“vendor”: “Google Inc.”
},
“system-info”: {
“file.encoding”: “UTF-8”,
“java.runtime.name”: “OpenJDK Runtime Environment”,
“java.runtime.version”: “11.0.10+9”,
“java.vendor”: “AdoptOpenJDK”,
“java.vendor.url”: “https://adoptopenjdk.net/”,
“java.version”: “11.0.10”,
“java.vm.name”: “OpenJDK 64-Bit Server VM”,
“java.vm.version”: “11.0.10+9”,
“os.name”: “Linux”,
“os.version”: “3.10.0-1160.15.2.el7.x86_64”,
“user.language”: “en”,
“user.timezone”: “GMT”
},
“metabase-info”: {
“databases”: [
“clickhouse”,
“mysql”,
“h2”
],
“hosting-env”: “unknown”,
“application-database”: “h2”,
“application-database-details”: {
“database”: {
“name”: “H2”,
“version”: “1.4.197 (2018-03-18)”
},
“jdbc-driver”: {
“name”: “H2 JDBC Driver”,
“version”: “1.4.197 (2018-03-18)”
}
},
“run-mode”: “prod”,
“version”: {
“date”: “2021-02-19”,
“tag”: “v0.38.0.1”,
“branch”: “release-x.38.x”,
“hash”: “0635914”
},
“settings”: {
“report-timezone”: “Asia/Calcutta”
}
}
}

Could not find anything in particular in the error logs. Will share the PHP code snippet for fetching the charts as soon as the developers share it with me. Thanks flamber for responding.

@ServerLord I’m 99.9% sure there’s an error in the log.
If you’re using Metabase in production, then migrate away from H2:
https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html

Thanks again flamber. We are using Clickhouse to build that chart actually. Will try to look into the logs and will share the backend code of the PHP. :slight_smile:

@ServerLord Clickhouse driver currently doesn’t work with Metabase 0.38:
https://github.com/enqueue/metabase-clickhouse-driver/issues/61

@flamber We have been able to create dashboards and charts just fine with Clickhouse thanks to a gentleman who shared an open source repo where he shared the Clickhouse driver. The issue is only pertaining to fetching the chart in another application.

@ServerLord Without the code or errors, then it’s impossible to know what’s wrong.
Have a look here: https://github.com/metabase/metabase/issues/14474

Here is the code that we are using.

$metabaseSiteUrl = “http://****:3000”;
$metabaseSecretKey = ‘*****’;
$issuedat_claim = time(); // issued at
$expire_claim = $issuedat_claim + 25200; // 25200 sec means a seven houre expire time in seconds
$signer = new \Lcobucci\JWT\Signer\Hmac\Sha256();
$token = (new \Lcobucci\JWT\Builder())
->set(‘resource’, [‘dashboard’ => 4])
->set(‘params’, [])
->set(‘exp’, $expire_claim)
->sign($signer, $metabaseSecretKey)
->getToken();

@ServerLord Then try ->set('params', (object) []) as the reference example uses:
https://github.com/metabase/embedding-reference-apps/blob/master/laravel/embedded_analytics/routes/web.php#L29

Thanks @flamber. It worked out.