StatsD Gauges, Counters, and Timers on MetricFire

StatsD Gauges, Counters, and Timers on MetricFire

Table of Contents

Great systems are not just built. They are monitored.

MetricFire is a managed observability platform that helps teams monitor production systems with clean dashboards and actionable alerts. Delivering signal, not noise. Without the operational burden of self-hosting.

Introduction

StatsD is a daemon that listens for counters, timers, and gauges of any function that you specify. For example, if you had an IoT device with a button, you could set a counter on that button to track how many times it has been pressed.

Normally, you would need to set up and configure the StatsD daemon on a server to get started. However, today we will be using MetricFire’s StatsD add-on, so we can get our stats up and running quickly.

To get started, sign up for the MetricFire free trial. The rest of this article will walk you through exactly how to send metrics to MetricFire with StatsD.

StatsD is normally set up by the user, where the user specifies a URL that acts as the StatsD endpoint. But by using MetricFire, all of that is already done for us. All we need to do is send the metrics to the given URL from MetricFire, and the information will be ready to display in Grafana.

  ‍

Key Takeaways

  1. StatsD is a daemon that tracks counters, timers, and gauges for various functions, such as monitoring button presses on IoT devices.
  2. Backend languages typically have libraries for sending StatsD metrics, which require specifying the URL, port, and prefix.
  3. The article demonstrates sending StatsD metrics to MetricFire using Python. It shows how to install the StatsD package and configure the StatsClient with the necessary parameters.
  4. The article explains how to create a Grafana dashboard and query the metric sent to MetricFire. It showcases the ability to visualize the data, making it useful for tracking user engagement or application usage.
  5. StatsD is a versatile tool that can be used for tracking various application metrics to enhance application performance.

 

How to send metrics

The chart below shows the general layout of how to send metrics to StatsD. Typically most backend languages have a library that helps send StatsD metrics to the URL, port, and prefix. Once you have installed the library for StatsD in the language that your app is written in, you can start adding code to track certain functions with counters, gauges, or timers. When using MetricFire, the URL, port, and prefix are given by the StatsD add-on in the MetricFire app.

 ‍

undefined

‍ 

Today, we will be using Python to send StatsD metrics to our MetricFire account. Let’s first get the StatsD package with:

 

sudo pip install statsd

‍ 

undefined

‍ 

Next, let’s get our URL, port, and prefix from our MetricFire account. Go to your Dashboard and Add-Ons > Add-Ons > StatsD.

‍ 

undefined

‍ 

Then there should be an Enable button. After enabling StatsD, you should see your URL, port, and prefix like below.

 ‍

undefined

‍ 

Now, with this information, we can start sending metrics to our MetricFire account. Make an executable Python file with this code in it:

‍ 

#!/usr/bin/env python3
import statsd
c = statsd.StatsClient("URL", PORT, prefix="PREFIX_KEY")
def button():
    c.incr("metric.button", 1)
    print("button has been pressed")
if __name__ == "__main__":
    for i in range(5):
        button()

‍  

undefined

‍ 

Sending metrics

Next, let’s test our counter metric. If we execute this file once, it will send metrics information to MetricFire. Specifically, the counter will count 5 button presses each time we execute the file, and send that value to MetricFire under the metric name "counters metric button count". Then we can import the value into Grafana by querying the metric name in a Grafana dashboard. Let's take a look at these steps below.

First let's execute our file:

‍ 

undefined

‍ 

Then, confirm that the metric has been sent to our metric treemap. The image below shows that MetricFire has received the metrics from our Python file.

‍ 

undefined

‍ 

Once you see it pop up on your metric treemap, we should be able to plot it on a graph in Grafana. Let’s create a new dashboard in Grafana.

 ‍

undefined

‍ 

And then we will query our metric called "counters metric button count". On the graph below, the cursor is hovering over a single dot. That query has a dot with 5.000 as a value on the graph. Which is correct, since our counter counted 5 button presses after our last execute of the Python file.

‍ 

undefined

‍ 

Let’s spam the Python file a little more to see what it looks like on the graph. The image below shows what a bunch of random executes of our Python file look like. You can also see the original 5-button presses at 14:28.

‍ 

undefined

‍ 

StatsD is useful for tracking how long a user spends time on your app, or how often something gets used. There are endless amounts of stats that you can track to help improve your application.

If you're interested in trying out StatsD in MetricFire, sign up for our free trial. Try out the StatsD add-on, and see if you can make some StatsD graphs in Grafana. You can also get us on the phone by booking a demo - feel free to talk to us directly about how MetricFire can help with your monitoring needs.

You might also like other posts...
metricfire Feb 10, 2026 · 2 min read

HG-CLIエージェント導入ツールの使い方:ステップ別ガイド

本記事では、HG-CLIの概要と、ターミナルユーザーインターフェース(TUI)モードおよびコマンドラインインターフェース(CLI)モードでの使用方法を解説します。さらに、収集されたメトリクスをHosted Graphiteアカウントに転送した後の活用方法もご紹介します。 Continue Reading

metricfire Feb 09, 2026 · 2 min read

MetricFireのログ機能をご紹介:メトリクスと並べてログを可視化

MetricFireのHosted Grafanaでログとメトリクスを統合することで、トラブルシューティングの高速化、パターンの容易な発見、性能問題やシステムイベントに関する重要な状況把握が可能になります。本記事では、この新たな統合機能の設定方法と使用方法を解説します。 Continue Reading

metricfire Jan 29, 2026 · 1 min read

MetricFireのセキュリティについて

MetricFireでは、お客様のデータを自社のデータと同様に扱い、厳重に保護しています。インフラストラクチャのあらゆるレベルでセキュリティを最優先しているため、お客様のデータは安全に送信・保管されます。お客様のメトリクスと信頼を確保することが、当社の最重要課題の一つです。 Continue Reading

header image

We strive for 99.95% uptime

Because our system is your system.

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