Installing and deploying Metabase via the cloud
In the last section, we learned how to install Metabase locally on our computers. We also learned the limitations of running it locally. By installing and deploying to the cloud, we unlock Metabase's true power. Let's get started.
Running software in the cloud
The good news is that it is not too much more complicated to get Metabase running on a web server. Practically, this means that when you run Metabase on a web server and close up your laptop, Metabase will stay up and running (unlike a locally installed version).
While you could go out and buy a web server and plug it in at home, today that is rarely done. Running a server in your home or office is referred to as on-premises, or on-prem. Some organizations may have their own servers on-prem for security reasons but nowadays most servers are run in the cloud. Today you can pay companies including Amazon, Microsoft, and Google a very small amount of money and they will run and maintain a virtual server that you can have access to. This is how most companies today prefer to run their software, and many of the web pages you frequent are hosted on servers in the cloud like this. Running Metabase on a cloud-based server is by far the most recommended way to go.
The Metabase team recommends using Amazon Web Services, or AWS, and we will dedicate all of the next chapter to this topic. For now, I'd like to show you the absolute simplest way to run Metabase in the cloud.
Heroku – an easy platform for cloud-based applications
Heroku is a cloud platform as a service. It helps developers in building, running, and scaling their services. Instead of setting up a web server ourselves, Heroku's platform will take care of all of that. They'll provision the web server and all the other services and processes we need to run Metabase. This includes a unique URL, which they will generate for us, that we can use to interact with our instance of Metabase. Going forward, I'll be referring to a single copy of Metabase running as an instance.
The great thing about Heroku is that they make it easy to deploy software. In fact, Metabase's Heroku deployment pipeline has been made so simple that all we really need to do is click a single button! Let's get started.
Signing up for a Heroku account
The following steps will take you through the Heroku sign-up process:
- Visit www.heroku.com in a web browser.
- At the top right you'll see a Sign up button – click it.
- Fill out the fields on the sign-up page, noting that the account is free. Heroku's Free Tier covers more than enough for us to get Metabase up and running and connect a few users to it.
- After you sign up for a Heroku account, you'll receive a confirmation email. You will need to confirm your account before proceeding.
- After clicking the confirmation email, choose a strong password and proceed onward to the welcome page:
Important Note
You may have noticed that in the sign-up flow, I selected Clojure as my primary development language. Clojure is actually a relatively obscure programming language, ranked the second least popular language among respondents in Stack Overflow's 2019 developer survey (https://insights.stackoverflow.com/survey/2019#technology).
Despite its lack of popularity, or perhaps because of it, Clojure garners a lot respect in the developer community. Clojure programmers are an elite group, and Metabase is primarily written in Clojure, making it one of the more famous Clojure projects being developed today.
Deploy Metabase to Heroku with one click
Now that we have signed up for a Heroku account, we can deploy Metabase:
- Go to https://www.metabase.com/start/oss/ and click the Get Started button.
- Scroll to the very bottom of the page and click to Read about how to run Metabase on Heroku. Alternatively you can visit https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-heroku.html.
- Find the small purple button that reads Deploy to Heroku, as in Figure 1.5. Go ahead and click it. Clicking this button will redirect you back to the Heroku website:
You'll see a form similar to Figure 1.6. All you will be required to input is a name for your app. Metabase might seem like a good name, but unfortunately, this name has to be unique, so put something meaningful to you in the field. A common convention is to use the name of your organization along with the word Metabase, all in lowercase and strung together with dashes. Since in this book we'll be working with a fictional dataset around a company that makes pies and pickles, I've chosen pickles-and-pies-metabase:
Once you've settled on an available name, you can click the Deploy app button at the bottom of the form. This will trigger the deployment pipeline. One by one, you should see green checkmarks appear next to the deployment steps. Once the final checkmark turns green, it will display a message saying Your app was successfully deployed, as in Figure 1.7. Click the View button below this to open your newly created app in a new window:
Important Note
You may notice there is an add-on called Heroku Postgres. If you are already familiar with databases, you likely know of Postgres. Postgres is a popular, open source, and widely used relational database. When we deploy Metabase, we will also get a free, Hobby-Tier version of Postgres deployed in parallel. You may think that this is to store the data we will eventually analyze with Metabase, but it is not. Rather, it is our application database, which stores things such as user information, passwords, saved definitions for charts, collections, and queries. Think of it as Metabase's database. Very meta, right?
You'll notice that the URL for your Heroku Metabase instance will look like <your_application_name>.herokuapp.com.
It may take a few seconds or even up to a minute the first time you visit your application, but soon enough you should see the welcome screen. It should look just like the welcome screen on the Mac and Java apps, which we saw in Figure 1.3.
Sign up before proceeding
And just like that, you've successfully deployed Metabase with Heroku. Note that anyone can visit this URL. If you like, test it out by having a friend open the link or try it in a private browsing session. The app is available to what we refer to as the public internet, which means that anyone with an internet connection can send a request to the server and get a response.
It's unlikely that someone you do not know will visit your uniquely created URL (how would they guess the URL?), but either way, it's smart to go through the sign-up flow to create your account immediately. This secures your instance and prevents any other visitors to the URL from signing up before you. Should this unlikely event happen, no problem – go to the next section where I explain how to manage your Heroku app, including instructions on how to delete it.
For now, though, let's sign up. Enter your name and email, choose a strong password, and enter a name for your organization. I've done my own, as shown in the following screenshot:
Next, you'll be asked to add your data. This is where we would add our database credentials. We're going to skip this step for now, as I'll be dedicating much more space for this topic later in the book in Chapter 4, Connecting to Databases. Instead, click I'll add my data later.
You will be asked whether you want to allow Metabase to collect some data. This is entirely up to you; rest assured that if you say yes, Metabase will only collect high-level information and everything will be anonymized. If you want to know exactly what they collect, you can read their documentation at https://www.metabase.com/docs/latest/information-collection.html.
The last step will give you an option to subscribe to email updates. After that, you're done. Click Take me to Metabase to conclude the sign-up flow. Next, we'll learn about some of the features and limitations that come with Heroku.
Limitations of Heroku's Free Tier
Although incredibly easy to deploy, relying on your free Heroku account to provision Metabase to many users across your organization may not be wise, as the Free Tier may not be powerful enough. In this section, we'll learn about some of the limitations you may run into.
Heroku Metabase is in beta
According to the official Metabase documentation, as of the time of writing, the ability to run Metabase on Heroku is in beta. Personally, I've seen many small start-ups run Metabase on Heroku and have no issues, but the path recommended by the Metabase team is to use AWS.
Going to sleep
Apps deployed under Heroku's Free Tier will go to sleep after 30 minutes of inactivity. In a small organization, that will probably lead to lots of sleeping. It only takes about a minute for Metabase to wake up, which doesn't seem long, but imagine if a web page you visited took a minute to load – you would probably get a little frustrated, right? So, this is one limitation to bear in mind.
Metabase also has some useful features that send out reports via email or to Slack on a scheduled basis. Most users like to schedule these so that they hit their inbox in the morning, just as they get into work or are sipping their morning coffee. If your Metabase instance is constantly going to sleep after 30 minutes of inactivity, you can expect these scheduling features not to function smoothly.
The easiest way to get around this is to upgrade to the Hobby Tier, which as of the time of writing is $7 per month.
Memory issues
Another issue you may run into, aside from your app going to sleep, is memory usage. The Free Tier gives you 512 MB of memory. That should be fine for you and perhaps a few other users. If you find that you are running out of memory and you want to stick with Heroku, upgrade to the Standard 2x tier. All tiers between Free and Standard 2x provide 512 MB of memory. You can see all the tiers at https://www.heroku.com/dynos.
SSL
SSL, or Secure Sockets Layer, is a security layer that ensures data passed between the server and client (that is, the web browser) is encrypted. You may have noticed that some websites begin with https, while others begin with http. The ones that begin with https have SSL. Most websites nowadays have SSL, including the instance of Metabase you just deployed. However, maybe one day you want to stop using the URL provided by Heroku (the one we made was https://pickles-and-pies-metabase.herokuapp.com/), and instead create a subdomain under your own website. In that case, you'd need to upgrade to the Hobby Tier to use SSL.
Upgrading and deleting your Heroku app
Let's move on. In this section, you will learn how to upgrade or delete your Heroku app. When you log into your Heroku account going forward, you'll see your Metabase app in the list of running apps and pipelines. Clicking on your app will take you to an interface with seven tabs, as in Figure 1.9, all of which allow you to configure or view your app under different conditions. There is also an activity feed on the right side of the page:
We do not need to know what is under all seven of these tabs. The most common actions you will likely make using this view are upgrading and terminating your app, so we will focus on those.
Upgrading Heroku Metabase
Metabase is under active development and the product is constantly getting new features, performance enhancements, and design updates. Just like you would update your browser or smartphone software to take advantage of new features, the same goes for Metabase. Now I am going to take you through the steps of upgrading Metabase.
Determining your Metabase version
Before you attempt to upgrade, make sure you are not on the latest version already. If you just installed Metabase, chances are that there is not a new version quite yet!
To find out which version you are using, follow these steps:
- Go to your instance and click the Settings gear in the upper-right corner.
- Click the option that reads About Metabase. A modal like that shown in Figure 1.10 will pop up displaying, among other things, the version number. Take note of it:
- Metabase posts all their releases in reverse chronological order at https://github.com/metabase/metabase/releases. Visit this URL and compare the latest version number with your version. If the version at the top of this page doesn't match your version, then it's time to upgrade.
Note that even if you are on the latest version, you can still go through the next few steps for learning purposes.
Installing the command-line interface for Heroku
To upgrade an instance of Metabase on Heroku, the first thing you need to do is install Heroku's Command-Line Interface, abbreviated as CLI:
- On the Deploy tab, you will find a link to Download and Install the Heroku CLI. Click that link or visit the page directly at https://devcenter.heroku.com/articles/heroku-command-line.
- Here you will find downloads for macOS, Windows, and Linux. Note in the instructions that one prerequisite is to have git installed. This is a good time to install git if you haven't already. You can find the download links and installation instructions for git at https://git-scm.com/book/en/v2/Getting-Started-Installing-Git. Many computers have git preinstalled, too, so downloading it may not be necessary. To check whether you have it installed, run the following command in a terminal session:
which git
- If you see no response, it means you do not have git installed. If you see something like /usr/local/bin/git, it means you do.
- Once you've installed the Heroku CLI and optionally, git, you can open up a terminal instance and run the following command:
heroku login
- You'll be prompted to enter any key, which will open a browser window allowing you to continue the login process. Then return to your terminal. If it worked, you will see a line in your terminal that reads as follows:
Logged in as <your_email_address>
Cloning Metabase's metabase-deploy Git repository
Next, you want to clone one of Metabase's Git repositories, or repos, as they are commonly referred to. Cloning means simply copying the source code maintained by the Metabase team to your computer. Let's see how it's done:
- Using the same terminal instance from the last step, run the following command:
git clone https://github.com/metabase/metabase-deploy.git
- This will create a directory called metabase-deploy in your computer's filesystem. Move into that directory with cd, the change-directory command.
cd metabase-deploy
- Then run the following line, replacing pickles-and-pies-metabase with the name of your Heroku Metabase app:
git remote add heroku https://git.heroku.com/pickles-and-pies-metabase.git
- You can find the full URL in the Settings tab on your app's configuration page in Heroku, as shown in the following screenshot:
- Finally, run the following command to deploy any updates:
git push -f heroku master
Now let's cover some different ways to take down our application.
Deleting your Metabase instance on Heroku
To take your app offline, there are two options: putting it in maintenance mode and full deletion:
- Turning maintenance mode on will take your app offline. All the configuration in Heroku will still exist, but the URL will return a Heroku-specific page reading Offline for Maintenance. You'll find this option under the Settings tab (https://dashboard.heroku.com/apps/pickles-and-pies-metabase/settings), toward the bottom of the page.
- Also, at the bottom of the Settings tab, you will find a red button to delete your app. This will remove the app entirely. It will also remove the Postgres application database.