How to Set Up Prometheus and Grafana with MetricFire

How to Set Up Prometheus and Grafana with MetricFire

Table of Contents

Prometheus is a great monitoring tool, but the metrics it stores and reads from are temporary. Which means you need to have Prometheus write your metrics to a storage solution. This is where MetricFire comes in.  MetricFire does long term Prometheus storage so you don’t need to worry about setting up and maintaining storage for your metrics. You can just focus on creating a Prometheus monitoring solution for your product. 

MetricFire also comes with hosted Grafana, which saves you even more time and the headache of setting up a visualizer for your metrics. For this article, we will need a MetricFire account. You can get a 14 day free trial by clicking here.

Before we get started, here's what our final product will look like:

 

undefined

 

Follow along with this tutorial to see how we did it.

‍ 

 

MetricFire’s Prometheus Config Settings

After signing up for the free trial, we will need the API key settings from the MetricFire dashboard. This information will go into the Prometheus config file of our own Prometheus installation. From the MetricFire dashboard as seen in the image below, go to Add-Ons > Prometheus. This block of code will be used later in this article.

‍ 

undefined

 ‍

If this is your first time trying out Prometheus, continue reading below. Otherwise you can skip ahead to the “Modifying prometheus.yml” section.

 

Setting up Prometheus

The chart below shows an example of how Prometheus works alongside MetricFire. We just need to set up a node to Prometheus, and then direct Prometheus to MetricFire so that MetricFire can read and write metrics.

 

undefined

‍ 

We first will download the Prometheus and the node exporter. Head on over to the download section on the Prometheus site.

 ‍

undefined

 

undefined

‍ 

Right click and copy link location on the red circled parts from the images above to get a download URL.

 

curl -LO URL_FROM_LINKS_ABOVE

 

Use the code snippet above to download Prometheus on to the machine you want to host Prometheus on, and the node exporter to the machine you want to monitor. In the command above, replace “URL_FROM_LINKS_ABOVE” with the links we grabbed from the Prometheus download section. Check out the full example in the image below.

 ‍

undefined

‍ 

Next let’s extract our tar.gz files with the code snippet below:

 

tar -xvf TAR_GZ_FILE_NAME

 

undefined

‍ 

Modifying prometheus.yml

Before running Prometheus, let’s edit its configs to collect metrics from one of our nodes. Then let’s send metrics to MetricFire so we can store and aggregate our Prometheus metrics. 

First let’s modify the .yml file to target our current node, which is on the same machine. We will need to run ifconfig to find our IP address, like in the image below.

‍ 

undefined

‍ 

Then let’s go into our .yml file and edit the contents like in the image below.

‍ 

undefined

‍ 

The job_name can be what kind of metrics your node is exporting, and the targets is a list of your nodes. You can copy and paste from the code snippet below, and replace JOB_NAME and IP_FROM_IFCONFIG appropriately.

‍ 

global:
 scrape_interval: 5s
scrape_configs:
 - job_name: 'JOB_NAME'
   static_configs:
   - targets: ['IP_FROM_IFCONFIG:9100']

‍ 

Lastly for the .yml file, let’s add our block of code that we got from the first bit in this article. We got the custom config code snippet from our MetricFire dashboard, you can check out how to do in the section “MetricFire’s Prometheus Config Settings” above. Check the image below for indentation of the code on lines 18 - 24.

‍ 

undefined

‍ 

Running Prometheus and Node Exporter

Now that we have everything set up, it’s time to run Prometheus and a node. Go into the unzipped tar.gz files we got earlier. In the Prometheus folder run ./prometheus, and in the node_exporter folder run ./node_exporter.

‍ 

undefined

 

undefined

‍ 

Now we should be sending metrics to MetricFire that will then be stored and aggregated for you. You can check to see if it worked by going to your MetricFire dashboard, where you can see when the most recent metrics were sent from your Prometheus client. See it circled in the image below.

 ‍

undefined

‍ 

Using Grafana on MetricFire

After running a node, modifying our .yml file to target our node and MetricFire, and running our Prometheus client, we should be storing and aggregating Prometheus metrics in our MetricFire account. 

MetricFire comes with hosted Grafana, so we can have a more dynamic dashboard for our Prometheus metrics. Also, since MetricFire is handling our metrics storage, our Prometheus metrics are able to show long term charts rather than only short term.

Let’s create a dashboard for our CPU data that we are receiving now. Go to “+ Add Dashboard” like in the image below.

 ‍

undefined

‍ 

Then “Add Query”.

 ‍

undefined

‍ 

And now we can add a query to our total cpu usage, like in the image below.

‍ 

undefined

‍ 

You can use the code snippet below and paste it into the query to see how it works out for you. I’m using an irate on the total cpu for only system and user.

 

irate(node_cpu_seconds_total{mode=~"system|user"}[1m])

 

Conclusion

This blog post showed how to get Prometheus and Grafana set up on MetricFire. MetricFire’s Hosted Prometheus stores metrics for up to two years with 3x redundancy for all data for all users.

To sign up for the free trial, click here to get started. Also, get the MetricFire team on a video call by booking a demo. We’re always happy to support our users to use the platform to its fullest.

You might also like other posts...
grafana Oct 30, 2023 · 2 min read

【Grafana】 導入方法を基礎から徹底解説

Grafanaは、監視と可観測性のためのオープンソースのプラットフォームです。 メトリクスが格納されている場所に関係なく、メトリクスを照会、視覚化、アラート、および理解することができます。 ダッシュボードを作成、調査、およびチームと共有し、データ主導の文化を育むこともできます。 Continue Reading

grafana Oct 23, 2023 · 3 min read

【Grafana】利用できるデータソースと可視化方法

Grafanaは、モニタリングや分析を行うための一般的なツールです。ダッシュボードを構築して、データを可視化、クエリ、分析したり、特定の条件のアラート通知を設定したりすることができます。この記事では、最も人気のあるGrafanaデータソースとその使用方法について詳しく説明します。 Continue Reading

grafana Oct 23, 2023 · 2 min read

【Grafana】超人気の可視化ツール、Grafanaとは?

データはすべて、時系列グラフや単一統計表示からヒストグラム、ヒートマップなど、さまざまなタイプのパネルを使って照会し、補完することができます。その柔軟性によりデータソースと多数の可視化パネルにより、Grafanaは、DevOpsやモニタリングエンジニアの間で大人気ツールとなっています。 Continue Reading

header image

We strive for
99.999% uptime

Because our system is your system.

14-day trial 14-day trial
No Credit Card Required No Credit Card Required