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
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
  1. DZone
  2. Data Engineering
  3. Databases
  4. The Sensu Prometheus Collector

The Sensu Prometheus Collector

Check out how the Sensu-Prometheus integration can collect information from Prometheus and output the data in multiple formats.

Sean Porter user avatar by
Sean Porter
·
Jul. 20, 18 · Tutorial
Like (1)
Save
Tweet
Share
3.83K Views

Join the DZone community and get the full member experience.

Join For Free

I am very excited to share with you a little project that I started on Monday, the Sensu Prometheus Collector! I have wanted to create something like this for a long time now and I finally found the time to do it.

The Sensu Prometheus Collector is a Sensu Check Plugin that collects metrics from a Prometheus exporter, metric HTTP endpoint, or the HTTP Query API. The collected metrics are outputted to STDOUT in one of three formats: Influx (the default), Graphite, or JSON. Sensu can then deliver the outputted/collected metrics to one or more time-series databases, like InfluxDB or Graphite! Choose your TSDB!

How Sensu Complements Prometheus

The Sensu Prometheus Collector turns Sensu into a SUPER POWERED Prometheus metric poller, leveraging Sensu's PubSub design and client auto-registration. Sensu is able to automatically discover and begin polling metric HTTP endpoints, securely transporting collected metrics to a desired time-series database. Sensu's client connections traverse complex network topologies, including those that use NAT and VPNs, eliminating any need to punch holes in firewalls for metric scraping.

Connecting projects with Sensu makes me this happy


Usage Examples

Operating the Sensu Prometheus Collector is very straightforward and configuring a Sensu Check to run it is easy. Simply poll metrics from a Prometheus exporter or an application's metric HTTP endpoint and output them in the Influx Line Protocol format:

$ sensu-prometheus-collector -exporter-url \ http://localhost:8080/metrics
go_memstats_last_gc_time_seconds value=0 1506991233
go_memstats_mspan_sys_bytes value=32768 1506991233
...
Now we're cooking up some

Sensu Configuration Examples

A Sensu Check named " prometheus_metrics ", that collects metrics from a metric HTTP endpoint on application tier systems, and sends them to a Sensu Event Handler named "influx":

{
 "checks": {
   "prometheus_metrics": {
     "type": "metric",
      "command": "sensu-prometheus-collector -exporter-url http://localhost:8080/metrics",
      "subscribers": ["app_tier"],
      "interval": 10,
      "handler": "influx"
    }
  }
}


A Sensu Event Handler named " influx ", that sends collected metrics in the Influx Line Protocol format to a Influx UDP listener:

{
   "handlers": {
     "influx": {
       "type": "udp",
       "mutator": "only_check_output",
       "socket": {
         "host": "influx.example.com",
         "port": 8189
      }
    }
  }
}


Hopefully, these examples helped you get an idea of how the Sensu Prometheus Collector works and how to configure Sensu to use it.

The full power of the Sensu Prometheus Collector can be found in the help output:

$ sensu-prometheus-collector -h
Usage of ./sensu-prometheus-collector:
 -exporter-url string
 Prometheus exporter URL to pull metrics from.
 -metric-prefix string
 Metric name prefix, only supported by line protocol output formats.
 -output-format string
 The check output format to use for metrics {influx|graphite|json}. (default “influx”)
 -prom-query string
 Prometheus API query string. (default “up”)
 -prom-url string
 Prometheus API URL. (default “http://localhost:9090”)


For more examples and documentation, please check out the project's README.

Contributing

The Sensu Prometheus Collector is very new (and raw), making for many opportunities to contribute to the project! I have begun to create GitHub issues for desirable features and enhancements, labeling some of them with "good first issue" to help identify issues that are more approachable. I hope you find this little project as exciting as I do, help me improve it and give it the polish that it deserves!

Try It!

The Sensu Prometheus Collector is rad and ready for you to try! Use Prometheus instrumentation libraries and exporters with Sensu and store the collected metrics in your favourite time-series database. The more of us using the plugin and experimenting, the better!

The Sensu Prometheus Collector can be found on my GitHub.

Thanks to Matthew (Brender) Broberg and Jason Dixon.

Metric (unit) Time series

Published at DZone with permission of Sean Porter, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • SAST: How Code Analysis Tools Look for Security Flaws
  • How To Generate Code Coverage Report Using JaCoCo-Maven Plugin
  • Streamlining Your Workflow With the Jenkins HTTP Request Plugin: A Guide to Replacing CURL in Scripts
  • Top Authentication Trends to Watch Out for in 2023

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: