DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Data Engineering
  3. Databases
  4. Check Output Metric Extraction With InfluxDB and Grafana

Check Output Metric Extraction With InfluxDB and Grafana

Learn how to collect and visualize data with InfluxDB and Grafana and the support of Sensu to help you monitor and optimize performance.

Nikki Attea user avatar by
Nikki Attea
·
Sep. 14, 18 · Tutorial
Like (1)
Save
Tweet
Share
4.60K Views

Join the DZone community and get the full member experience.

Join For Free

Sensu is an extremely powerful standalone monitoring framework, but the real beauty of Sensu lies in its ability to harmoniously interact with, support, and instrument other tools to create a customized and complete monitoring solution. Take metrics, for example: Sensu offers multiple mechanisms to monitor performance metrics such as check output metric extraction and StatsD. On its own, that’s pretty cool, but combined with Sensu’s robust event pipeline, you can cater different methods of metric analysis to your specific needs. Application performance monitoring? Yas. System metrics and telemetry data? Oh yeah. Metric aggregation? We gotchu.

Raise the roof, 'cause your monitoring is all under one roof.

Sensu supports four different metric formats for check output metric extraction and can integrate with any time series database as long as there’s a handler written for it. In this post, I’m going to walk you through just one of the endless permutations of metrics software you can pair with Sensu:

  1. Collect using Sensu check output metric extraction
  2. Transform with a Sensu InfluxDB Handler
  3. Record in an InfluxDB time series database
  4. Visualize on a Grafana dashboard

This blog post assumes you have Sensu 2.0 installed. If you don’t, first of all why not? StatsD and check output metric extraction are new features to 2.0! For instructions on setting up Sensu 2.0 so you can do all the new and shiny metrics things, please see our Installation and Configuration guide.

Note: This guide will take you step by step to configure Sensu, InfluxDB, and Grafana for check output metric extraction. If you’d rather spin up pre-configured instances, Sensu Test Day has self-contained Docker containers that are pre-baked for this use case. Choose your own adventure!

Collecting Metrics

To collect metrics using Sensu check output metric extraction, you’ll first need to spin up a backend, agent, and cli.

Backend:

sensu-backend start

 Agent:

sensu-agent start --subscriptions metrics

 CLI (see Configuring sensuctl):

sensuctl configure

Once you have Sensu running on your selected host(s), you’ll want to create a check and configure it to extract metrics. The script we’re using for collection (metrics-graphite.sh) prints out several metrics in Graphite Plaintext Format. Sensu supports several other metric formats for extraction, so feel free to customize your check accordingly, or try out other example formats.

Note: The example metric extraction scripts provided are only compatible with OSX. If your agents are running on any other operating system (Sensu supports just about all of them), you’ll have to tweak your scripts for compatibility. As long as the check command prints out at least one metric in the specified output-metric-format, you should be good!

sensuctl check create collect-metrics --command metrics-graphite.sh 
--interval 1 --subscriptions metrics --output-metric-format 
graphite_plaintext

After the check has executed (this shouldn’t take too long), validate that your metrics have been collected, extracted, and stored within the check’s event.

sensuctl event info [entity-name] collect-metrics --format json

Transforming Metrics

Now that we have Sensu events from our checks and metrics, we need to handle them. Sensu-influxdb-handler, a little tool I wrote, will transform any metrics contained in a Sensu event and send them off to a configured InfluxDB. Make sure you download the newest handler from releases.

sensuctl handler create sensu-influxdb-handler --command 
"sensu-influxdb-handler --addr http://localhost:8086 --username [username] 
--password [password] --db-name [db-name]" --type pipe

Assign the handler we just created to the check from the first step.

sensuctl check set-output-metric-handlers collect-metrics 
sensu-influxdb-handler

Record Metrics

You’ll also need the InfluxDB daemon running on the configured address for the database and credentials you’ve provided to your handler command above.

influxd

You can verify that the metrics have been handled and recorded by querying your InfluxDB.

Visualize the Metrics

Now that the data is in a time series database, let’s hook it up to a dashboard. Start a Grafana server (ensure there are no port collisions with Sensu in the Grafana config file) and customize your dashboard based on the check’s outputted metrics. Depending on how you installed Grafana, start the server by the recommended method.

brew services start grafana

You can utilize this dashboard configuration, ensuring you replace [ENTITY NAME] with the hostname of the monitored entity. You’ll also need to connect your Grafana dashboard to the InfluxDB datasource named “Sensu Metrics.” If you’re unsure of how to do that, check out this guide. If all goes well, you should be able to see your real-time metrics being collected by Sensu
checks, like in the below dashboard!

Closing Thoughts

Pretty cool, right? Sensu 2.0 is not only improving infrastructure monitoring, but it’s also expanding on application performance monitoring, too! If you haven’t already, we encourage you to give 2.0 a try and send us your feedback. We can’t wait to hear what you think!

Metric (unit) InfluxDB Grafana

Published at DZone with permission of Nikki Attea, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Configure Kubernetes Health Checks
  • Host Hack Attempt Detection Using ELK
  • Documentation 101: How to Properly Document Your Cloud Infrastructure Project
  • Introduction Garbage Collection Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: