Using Telegraf to send syslog metrics to Graphite

Using Telegraf to send syslog metrics to Graphite

Table of Contents

Introduction

When you own and operate software, it generates various types of logs from disparate sources such as databases, servers, and applications. The metrics from these critical digital assets are what companies monitor continuously. When they show you a sign of unreliability, companies must take swift action to fit the cause and prevent it from growing into a more significant problem. The key to success in this activity is owning a good Syslog application and metrics software where you can see metrics. This article discusses how we can use Telegraf - a Syslog software - to send Syslog metrics to Graphite

      

Before we begin, check out MetricFire. MetricFire offers comprehensive monitoring solutions with hosted software such as Hosted Graphite. With minimal configuration, you can gain in-depth insight into your IT resources. To learn more book a demo with us or sign up for a two-week free trial today.

         

Key Takeaways

  1. Graphite collects and stores performance metrics, offering primary graphical display and compatibility with tools like Grafana.
  2. Telegraf is a monitoring client for multiple OSs with a Graphite output plugin.
  3. Grafana enables customizable dashboard visualization with various panel types.
  4. Integration of Telegraf, Graphite, and Grafana enhances monitoring and visualization.

 

What is Graphite?

Graphite is a tool for collecting and saving system performance metrics. It has essential tools for graphically displaying stored metrics. Alternatively, you can connect Graphite to more advanced data visualization systems like Grafana.

            

What is Telegraf?

Telegraf is a monitoring client that you can easily install and configure. It works with various operating systems (Windows, MacOS, Linux, Red Hat, and CentOS) and has a Graphite output plugin. Installing and configuring Telegraf is different depending on your operating system. Despite the differences, they share the following steps in general:

         

  1. Install Telegraf.
  2. Create a configuration file.
  3. Make unique settings in the Graphite section of the generated file.
  4. Launch Telegraf.

     

Let’s go through each step in more detail.

      

Install Telegraf

Depending on your OS, installing Telegraf requires a different process. If you use Windows, you can run the following commands in Powershell.

wget https://dl.influxdata.com/telegraf/releases/telegraf-1.21.4_windows_amd64.zip -UseBasicParsing -OutFile telegraf-1.21.4_windows_amd64.zip
Expand-Archive .\telegraf-1.21.4_windows_amd64.zip -DestinationPath 'C:\Program Files\InfluxData\telegraf'

       

The download file above is the latest stable version as of February 2022. If you want to find a later version, check the Telegraf download page.

       

If you use MacOS, you can run the command below.

brew update
brew install telegraf

      

On Linux, you can execute the commands.

wget https://dl.influxdata.com/telegraf/releases/telegraf-1.21.4_linux_amd64.tar.gz
tar xf telegraf-1.21.4_linux_amd64.tar.gz

      

After you install Telegraf, you need to configure it to send Syslog metrics to Graphite.

       

Create a configuration file.

Creating a configuration file also follows different steps depending on your OS.    

  • Windows: run ./telegraf.exe --output-filter graphite config > telegraf.conf 
  • MacOS: find the configuration file at /usr/local/etc/telegraf/telegraf.conf 
  • Linux: find the configuration file at /etc/telegraf/telegraf.conf

         

Modify config to send metrics to Hosted Graphite.

The main mechanism for sending metrics to Graphite is via TCP protocol. To send metrics, you must change the config variables according to your settings within the configuration file you created or found. Below is a sample configuration: 

## This is the configuration for Graphite server to send metrics to
[[outputs.graphite]]
  ## TCP endpoint for your graphite instance.
  ## If multiple endpoints are configured, the output will be load balanced.
  ## Only one of the endpoints will be written to with each iteration.
  ## You can put your hosted graphite endpoint URL
  servers = ["carbon.hostedgraphite.com:2003"]
  ## Metrics prefix name
  prefix = "YOUR_API_KEY.telegraf"
  ## Graphite output template
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
  template = "host.tags.measurement.field"

  ## Graphite templates patterns
  ## 1. Template for cpu
  ## 2. Template for disk*
  ## 3. Default template
  # templates = [
  #  "cpu tags.measurement.host.field",
  #  "disk* measurement.field",
  #  "host.measurement.tags.field"
  #]

  ## Enable Graphite tags support
  # graphite_tag_support = false

  ## Metric name and field separating character for Graphite tag
  # graphite_separator = "."

  ## timeout in seconds for the write connection to Graphite
  timeout = 2

  ## Optional TLS Config
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"

  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false

       

Within the configuration above, you need to check the following three areas:     

  • [[outputs.graphite]]
  • The server URL in the servers list field: carbon.hostedgraphite.com:2003
  • Put your prefix following the pattern of "YOUR_API_KEY.telegraf".

       

Save the configuration file after changing the values. Next, you need to restart the Telegraf service to apply the changes. 

        

Launch Telegraf

As the final step, you must launch Telegraf to apply the changes. The starting command differs from the operating system.

      

Windows

./telegraf.exe -service install -config 'C:\Program Files\telegraf\telegraf.conf'
net start telegraf

      

MacOS

brew services restart telegraf

brew services restart telegraf

      

Linux

sudo service telegraf start

     

or

sudo systemctl start telegraf

           

When Telegraf sends out data, it can decide the output data format following your configuration. 

            

                  

Building a Grafana dashboard in a hosted environment

Visualization is an essential component when you interpret data since people can comprehend it much faster via pictures. Since you now set up the pipeline between Telegraf and Graphite, the final piece will display the metrics on dashboards. 

             

Grafana is an open-source monitoring tool that allows you to download data from different sources and visualize it on beautiful, customizable dashboards. After creating a Grafana dashboard, you need to add information panels. There are various types of panels in Grafana that you can use for different purposes. For example:     

  • Graph Panel. Time charts display data points on the time axis. You can compare different indicators on the same chart and use the timeshift functions to compare current values ​​with any past period.
  • Single stat. Used to display values ​​resulting from a query or display texts using value mapping transformation options.
  • Gauge takes one input series and displays the value in terms of its position within predefined lower and upper bounds.
  • Polystat panel displays small hexagons or circles representing single or composite indicators and their enabled states.
  • The Table provides discrete critical data for metrics and supports multiple modes for time series, annotations, and JSON data.
  • The Alert list allows you to display all triggered alerts from the control panel independently from different panels.

          

These convenient features can be a great addition to your analytics stack. However, due to the nature of open-source software, you will have to manage everything from installation to maintenance, which can burden your data team. MetricFire provides a managed service for Grafana. You can easily create an account with a pre-configured Grafana instance and start using it immediately, along with Hosted Graphite.

    

If you want to test how to monitor your system’s performance metrics using Grafana, try the MetricFire free trial or book a demo with our team.

       

The advantages of MetricFire

MetricFire offers a hosted Graphite for collecting and storing your system’s performance metrics. MetricFire configures, installs, and maintains Graphite, so you can use it as a web application without worrying about its performance.

           

Key benefits of using hosted Graphite from MetricFire:

  • Data availability: MetricFire provides permanent access to your data, which you can export anytime.
  • Affordable price: There are various tariff plans, and you can definitely choose the one that suits you.
  • Saving time and money: Investing in deploying and running monitoring systems is unnecessary.
  • Reliable support: We are always happy to answer all questions regarding working with MetricFire.
  • Redundancy storage: Graphite’s default storage is file-based and antiquated. MetricFire offers 3 times the redundant storage for seamless scaling and better data protection.
  • Control by APIs: The APIs that MetricFire provides let you control and automate the resources of Hosted Graphite.
  • Tagged metrics: Hosted Graphite stores data using tags that enable the viewing and organizing metrics with data views.

      

Hosted Graphite keeps all the benefits of open-source Graphite and further enhances the tool with the built-in agent, team accounts, granular dashboard permissions, and integrations to other major platforms and services such as AWS, Heroku, logging tools, and more.

       

Conclusion

We looked at why it is essential to monitor system performance metrics, how to send the collected metrics to Graphite, and how to visualize them using Grafana. We also listed the main benefits of using a Hosted Graphite solution from MetricFire. Telegraf is one of the most popular Syslog applications. When it is integrated into Graphite and its metric data is visualized on Grafana, you can fully utilize Telegraf's powerful features.

              

If you still have any questions, we will answer them. Book a demo with the MetricFire team or sign up for the MetricFire for free.

You might also like other posts...
metricfire Jul 26, 2024 · 8 min read

Monitor Your ZFS Volume Manager With Telegraf

Monitoring ZFS across your business's server infrastructure is crucial for ensuring data integrity, optimizing... Continue Reading

metricfire Jul 12, 2024 · 8 min read

Monitor Your Active SystemD Services Using Telegraf

Monitoring the state of your services and running processes is crucial for ensuring system... Continue Reading

metricfire Jul 03, 2024 · 9 min read

Monitor Your Socket Connections Using Telegraf and MetricFire

Monitoring socket connections in your servers is critical because it ensures network communication is... 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