<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>integration Archives | Clever Cloud</title>
	<atom:link href="https://www.clever.cloud/blog/tag/integration/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.clever.cloud/blog/tag/integration/</link>
	<description>From Code to Product</description>
	<lastBuildDate>Thu, 14 May 2020 14:46:00 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://cdn.clever-cloud.com/uploads/2023/03/cropped-cropped-favicon-32x32.png</url>
	<title>integration Archives | Clever Cloud</title>
	<link>https://www.clever.cloud/blog/tag/integration/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Integrate Metabase in Ruby on Rails</title>
		<link>https://www.clever.cloud/blog/engineering/2020/05/14/metabase-integration-ruby-rails/</link>
		
		<dc:creator><![CDATA[Valeriane Venance]]></dc:creator>
		<pubDate>Thu, 14 May 2020 14:46:00 +0000</pubDate>
				<category><![CDATA[Engineering]]></category>
		<category><![CDATA[dashboard]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[metabase]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2020/05/14/metabase-integration-ruby-rails/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="metabasebanner 1" decoding="async" fetchpriority="high" srcset="https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1.png 1400w, https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1-300x116.png 300w, https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1-1024x395.png 1024w, https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1-768x296.png 768w, https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><p>Today, I am  proposing a very simple tutorial. I needed to integrate a Metabase dashboard in one of my applications and I realized there is no article which explains how to do that. So, ta-da!</p>
<span id="more-2825"></span>

<h2 id="requirements">Requirements</h2>
<p>To follow this tutorial, you will need</p>
<ul>
<li>a Metabase dashboard (read <a href="https://www.clever.cloud/blog/engineering/2019/02/20/how-to-install-metabase/">this article</a> from my fellow Laurent Dogin to have yours set up in a few minutes)</li>
<li>a Ruby on Rails application (read <a href="https://www.clever.cloud/blog/engineering/2019/05/07/setup-your-ruby-on-rails-online-dev-environment/">this article</a> by me if you need to set up one)</li>
</ul>
<h2 id="enabling-integration-in-metabase">Enabling integration in Metabase</h2>
<p>From your Metabase, click on the top right <strong>gear icon</strong>, then <strong>Admin</strong>. On the left menu select <strong>Embedding in other Applications</strong>. Toggle the button to have it saying <strong>Enabled</strong>. You will now get an Embedding API key. Save it for later.</p>
<figure style="position:relative;width:100%;height:auto;margin:0 auto">
  <img data-action="zoom"  alt="Enable integrations on Metabase" src="https://cdn.clever-cloud.com/uploads/2021/08/metabase-integration-screenshot.png"/>
</figure>

<p>Leave Metabase admin and select the dashboard you want to integrate. Click the sharing and embedding icon on the top right of your dashboard. Now select <strong>Embed this dashboard in an Application</strong>. Finally, click on the <strong>Publish</strong> button.</p>
<h2 id="integrate-metabase-in-rails">Integrate Metabase in Rails</h2>
<p>In your Gemfile, add <code>gem &#39;jwt&#39;</code> then run <code>$ bundle install</code>. If your application is deployed on Clever Cloud go to your application&#39;s console and under your application&#39;s menu go to the <strong>environment variables</strong> menu. If you deploy locally, use the <a href="https://github.com/laserlemon/figaro">gem figaro</a> and edit your application.yml. Anyway you must add two environment variables</p>
<pre><code class="language-yaml">METABASE_SITE_URL: &lt;your metabase url&gt;
METABASE_SECRET_KEY: &lt;the API key from metabase admin&gt;
</code></pre>
<p>In the controller action where you want to integrate your metabase dashboard, add the following lines:</p>
<pre><code class="language-ruby">payload = {
          :resource =&gt; {:dashboard =&gt; &lt;your dashboard number&gt;},
          :params =&gt; { },
          :exp =&gt; Time.now.to_i + (60 * 10) # 10 minute expiration
    }
token = JWT.encode(payload, ENV[&quot;METABASE_SECRET_KEY&quot;])
@iframe_url = ENV[&quot;METABASE_SITE_URL&quot;] + &quot;/embed/dashboard/&quot; + token + &quot;#bordered=true&amp;titled=true&quot;
</code></pre>
<p>Now in your view, add</p>
<pre><code class="language-html">&lt;iframe
    src=&quot;&lt;%= @iframe_url %&gt;&quot;
    frameborder=&quot;0&quot;
    width=&quot;800&quot;
    height=&quot;600&quot;
    allowtransparency
&gt;&lt;/iframe&gt;
</code></pre>
<p>You are all set. Just restart your application so the new environment variables are taken in consideration. Voilà, your application now has an integrated Metabase dashboard.</p>
]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="metabasebanner 1" decoding="async" srcset="https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1.png 1400w, https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1-300x116.png 300w, https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1-1024x395.png 1024w, https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1-768x296.png 768w, https://cdn.clever-cloud.com/uploads/2021/08/metabasebanner-1-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><p>Today, I am  proposing a very simple tutorial. I needed to integrate a Metabase dashboard in one of my applications and I realized there is no article which explains how to do that. So, ta-da!</p>
<span id="more-2825"></span>

<h2 id="requirements">Requirements</h2>
<p>To follow this tutorial, you will need</p>
<ul>
<li>a Metabase dashboard (read <a href="https://www.clever.cloud/blog/engineering/2019/02/20/how-to-install-metabase/">this article</a> from my fellow Laurent Dogin to have yours set up in a few minutes)</li>
<li>a Ruby on Rails application (read <a href="https://www.clever.cloud/blog/engineering/2019/05/07/setup-your-ruby-on-rails-online-dev-environment/">this article</a> by me if you need to set up one)</li>
</ul>
<h2 id="enabling-integration-in-metabase">Enabling integration in Metabase</h2>
<p>From your Metabase, click on the top right <strong>gear icon</strong>, then <strong>Admin</strong>. On the left menu select <strong>Embedding in other Applications</strong>. Toggle the button to have it saying <strong>Enabled</strong>. You will now get an Embedding API key. Save it for later.</p>
<figure style="position:relative;width:100%;height:auto;margin:0 auto">
  <img data-action="zoom"  alt="Enable integrations on Metabase" src="https://cdn.clever-cloud.com/uploads/2021/08/metabase-integration-screenshot.png"/>
</figure>

<p>Leave Metabase admin and select the dashboard you want to integrate. Click the sharing and embedding icon on the top right of your dashboard. Now select <strong>Embed this dashboard in an Application</strong>. Finally, click on the <strong>Publish</strong> button.</p>
<h2 id="integrate-metabase-in-rails">Integrate Metabase in Rails</h2>
<p>In your Gemfile, add <code>gem &#39;jwt&#39;</code> then run <code>$ bundle install</code>. If your application is deployed on Clever Cloud go to your application&#39;s console and under your application&#39;s menu go to the <strong>environment variables</strong> menu. If you deploy locally, use the <a href="https://github.com/laserlemon/figaro">gem figaro</a> and edit your application.yml. Anyway you must add two environment variables</p>
<pre><code class="language-yaml">METABASE_SITE_URL: &lt;your metabase url&gt;
METABASE_SECRET_KEY: &lt;the API key from metabase admin&gt;
</code></pre>
<p>In the controller action where you want to integrate your metabase dashboard, add the following lines:</p>
<pre><code class="language-ruby">payload = {
          :resource =&gt; {:dashboard =&gt; &lt;your dashboard number&gt;},
          :params =&gt; { },
          :exp =&gt; Time.now.to_i + (60 * 10) # 10 minute expiration
    }
token = JWT.encode(payload, ENV[&quot;METABASE_SECRET_KEY&quot;])
@iframe_url = ENV[&quot;METABASE_SITE_URL&quot;] + &quot;/embed/dashboard/&quot; + token + &quot;#bordered=true&amp;titled=true&quot;
</code></pre>
<p>Now in your view, add</p>
<pre><code class="language-html">&lt;iframe
    src=&quot;&lt;%= @iframe_url %&gt;&quot;
    frameborder=&quot;0&quot;
    width=&quot;800&quot;
    height=&quot;600&quot;
    allowtransparency
&gt;&lt;/iframe&gt;
</code></pre>
<p>You are all set. Just restart your application so the new environment variables are taken in consideration. Voilà, your application now has an integrated Metabase dashboard.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
