Successfully reported this slideshow.

Sebastian Spaink [InfluxData] | Layer by Layer: Printing Your Own External Input Plugin for Telegraf | InfluxDays EMEA 2021

1

Share

Loading in …3
×
1 of 37
1 of 37

Sebastian Spaink [InfluxData] | Layer by Layer: Printing Your Own External Input Plugin for Telegraf | InfluxDays EMEA 2021

1

Share

Download to read offline

Layer by Layer: Printing Your Own External Input Plugin for Telegraf
The goal of this talk is to give listeners the context they need to create their own external plugin today. Sebastian provides the how-to knowledge by going over an external input plugin he created for monitoring 3D printing, starting with the minimum requirements to get started and then showing how he extended it for his own personal use case. The talk highlights how choosing to create your plugin idea externally lets you own your plugin’s full lifecycle and is a great way to immediately begin using it with Telegraf.

Layer by Layer: Printing Your Own External Input Plugin for Telegraf
The goal of this talk is to give listeners the context they need to create their own external plugin today. Sebastian provides the how-to knowledge by going over an external input plugin he created for monitoring 3D printing, starting with the minimum requirements to get started and then showing how he extended it for his own personal use case. The talk highlights how choosing to create your plugin idea externally lets you own your plugin’s full lifecycle and is a great way to immediately begin using it with Telegraf.

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Sebastian Spaink [InfluxData] | Layer by Layer: Printing Your Own External Input Plugin for Telegraf | InfluxDays EMEA 2021

  1. 1. Presented by: Sebastian Spaink Layer by Layer: Printing your own external input plugin for Telegraf
  2. 2. © 2021 InfluxData. All rights reserved. 2 • My Name: Sebastian Spaink • Team: Data Acquisition • Quarantine Craft: 3D printing | Introduction 3D printed Gopher!
  3. 3. © 2021 InfluxData. All rights reserved. 3 • Share how AWESOME external plugins are in Telegraf! • Give you the knowledge you need to make your own! | Goal?
  4. 4. © 2021 InfluxData. All rights reserved. 4 1. What and Why of external plugins 2. Show basic example 3. Walkthrough practical example 4. How to start with a new language? | Overview
  5. 5. © 2021 InfluxData. All rights reserved. 5 ● Telegraf: The plugin-driven agent for collecting & reporting metrics ● Hundreds of internal plugins included! | Overview of Telegraf and its plugins
  6. 6. © 2021 InfluxData. All rights reserved. 6 Definition: An external plugin is a program outside of Telegraf that can communicate and be run by a Telegraf plugin called execd ● There is a execd plugin for: input, processor, output ● Communicates through STDOUT with supported data format External Plugins: https:/ /github.com/influxdata/telegraf/blob/master/EXTERNAL_PLUGINS.md | What is an external plugin?
  7. 7. © 2021 InfluxData. All rights reserved. 7 • Benefits: – Create a plugin that covers your unique use case – Begin using it immediately – Write it in any language, not limited to Go | Why would you want to make one? For example a external plugin written in Python: • https:/ /github.com/jhpope/smc_ipmi
  8. 8. © 2021 InfluxData. All rights reserved. 8 | Keep it simple, a basic example Straight from the README: https:/ /github.com/influxdata/telegraf/tree/master/pl ugins/inputs/execd#daemon-written-in-bash-using-st din-signaling A simple bash script that blocks, waiting for input from STDIN, incrementing a counter. Done. You have an external plugin!
  9. 9. © 2021 InfluxData. All rights reserved. 9 | Configure it with Telegraf Telegraf Config
  10. 10. © 2021 InfluxData. All rights reserved. 10 PLACEHOLDER FOR OUTPUT ANIMATION
  11. 11. © 2021 InfluxData. All rights reserved. 11 | Signals accepted by execd plugin ● "none" : Do not signal anything. (Recommended for service inputs) The process must output metrics by itself. ● "STDIN" : Send a newline on STDIN. (Recommended for gather inputs) ● “SIGHUP" : Send a HUP signal. Not available on Windows. (not recommended) ● "SIGUSR1" : Send a USR1 signal. Not available on Windows. ● "SIGUSR2" : Send a USR2 signal. Not available on Windows.
  12. 12. © 2021 InfluxData. All rights reserved. 12 | Getting started with a practical example ● Octoprint: open source 3D printer controller application, which provides a web interface for the connected printers ● Information you can get: ○ Printing state: paused or ready ○ Current temperature of nozzle/printing bed ● All you need is an API to make an input plugin!
  13. 13. © 2021 InfluxData. All rights reserved. 13 | Easy start to an external plugin, the Go Shim ● The Telegraf execd Go shim is a great way to start! ● A scaffolding created to make plugins as if they were in Telegraf ○ Provides same structures used in the internal project ○ Provides logic to interact with the execd plugin
  14. 14. © 2021 InfluxData. All rights reserved. 14 | Go Shim Versus Execd Plugin ● Go Shim: A utility tool to help start external plugins ● Execd Plugin: A Telegraf plugin to manage external plugins Go Shim Execd Plugin Telegraf
  15. 15. © 2021 InfluxData. All rights reserved. 15 Get the main.go from the examples/cmd directory and place it in your project. Then you just need to edit the file to import the package containing your plugin code, such as so: | Quick step overview to use Go shim Reference link: https:/ /github.com/influxdata/telegraf/tree/master/plugins/common/shim
  16. 16. © 2021 InfluxData. All rights reserved. 16 | Gather the data Screenshot #1 Screenshot #2
  17. 17. © 2021 InfluxData. All rights reserved. 17 | Custom configuration ● Optionally, you can create a separate config file for your external plugin ● It is required this config is completely separate from the main config and lives in another directory
  18. 18. © 2021 InfluxData. All rights reserved. 18 | Configuring the Octoprint plugin with Telegraf 1. Build the external plugin you’ve made to an executable binary 2. Then update the main Telegraf config such as below: Note: The signal is set to “none” instead of “STDIN” ● The execd Go shim has a default polling interval of 1 second ○ can be adjusted by passing the flag poll_interval
  19. 19. © 2021 InfluxData. All rights reserved. 19 PLACEHOLDER FOR ANIMATION
  20. 20. © 2021 InfluxData. All rights reserved. 20 | Temperature data! Nozzle Build Plate
  21. 21. © 2021 InfluxData. All rights reserved. 21 | Extend Octoprint with plugins! ● Not Telegraf plugins, but different plugins! ● Display Layer Progress ○ https:/ /plugins.octoprint.org/plugins/DisplayLayerProgress/ ● Filament Manager ○ https:/ /plugins.octoprint.org/plugins/filamentmanager/
  22. 22. © 2021 InfluxData. All rights reserved. 22 | Display Layer Progress ● This plugin displays the current layer being printed! ● Fun to know and helpful!
  23. 23. © 2021 InfluxData. All rights reserved. 23 | Display Layer Progress ● New API endpoint: /plugin/DisplayLayerProgress/values
  24. 24. © 2021 InfluxData. All rights reserved. 24 | Filament Manager ● To get the filament data we need a postgres database!
  25. 25. © 2021 InfluxData. All rights reserved. 25 | Filament Manager
  26. 26. © 2021 InfluxData. All rights reserved. 26 | Demo Time!
  27. 27. © 2021 InfluxData. All rights reserved. 27 PLACEHOLDER FOR ANIMATION
  28. 28. © 2021 InfluxData. All rights reserved. 28 | End result!
  29. 29. © 2021 InfluxData. All rights reserved. 29 | Overview Components inputs.execd outputs.influxdb_v2 Octoprint external plugin Telegraf API Display Layer Progress API Filament Manager Postgres DB Octoprint InfluxDB 2.0
  30. 30. © 2021 InfluxData. All rights reserved. 30 | Try it for yourself! ● Source Code: https:/ /github.com/sspaink/octoprint-telegraf-plugin ● Feel free to make a pull request with changes!
  31. 31. © 2021 InfluxData. All rights reserved. 31 | Creating your own plugin ● With the structure defined, the rest is just regular fun coding! ● Tip: Following the plugin guidelines are a great way to work! ○ when external, they are more “guidelines” then actual rules… Guidelines: ● https:/ /github.com/influxdata/telegraf/blob/master/docs/INPUTS.md ● https:/ /github.com/influxdata/telegraf/blob/master/docs/PROCESSORS.md ● https:/ /github.com/influxdata/telegraf/blob/master/docs/OUTPUTS.md
  32. 32. © 2021 InfluxData. All rights reserved. 32 • No shim?!?! What to do! • Let’s try to re-implement the octoprint plugin in Rust! | What if I want to use a different language?
  33. 33. © 2021 InfluxData. All rights reserved. 33 | Let’s try to implement octoprint plugin in Rust! Output in influxdb line protocol Loop in one second intervals Set configuration Gather data
  34. 34. © 2021 InfluxData. All rights reserved. 34 | demo placeholder
  35. 35. © 2021 InfluxData. All rights reserved. 35 | What about outputs and processors? Output Example: https:/ /github.com/morfien101/telegraf-output-kinesis Processor Example: https:/ /github.com/a-bali/telegraf-geoip
  36. 36. © 2021 InfluxData. All rights reserved. 36 • Filter issues/pr’s by the label external plugin • Suid input plugin: https:/ /github.com/influxdata/telegraf/pull/7597 • Libvirt input plugin: https:/ /github.com/influxdata/telegraf/issues/690 • Jira input plugin: https:/ /github.com/influxdata/telegraf/pull/4944 | Need ideas?
  37. 37. © 2021 InfluxData. All rights reserved. 37 Thank you for watching! I hope you learned something. I look forward to seeing any external plugins you might make! If you do make one, please share it by making a pull request to update the EXTERNAL_PLUGINS.md doc in the Telegraf project!

×