snap-plugin-lib

module
v2.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2024 License: Apache-2.0

README

Plugin library - Overview

What's a collector

Collector is a small application which gather information about the observed system. You can collect CPU utilization, database statistics, message broker queue's sizes or other type of information, in a metric form.

What's metric

Metric holds information about single measurement. It consists of:

  • name: (ie. /system/total/cpu)
  • associated value (ie. 10)
  • unit (ie. %, s.)
  • description
  • tags (additional textual data)
  • time of measurements
Snap daemon vs snap collectors

When used in production, plugins are controlled by snap daemon. Simplified algorithm may be described as follows:

  1. Snap reads and forward configuration (credentials, requested metrics etc.) to plugin
  2. Periodically (typically 60s) snap requests collection of metrics for different plugins
  3. Each plugin responds with its own set of metrics

Tutorial

This tutorial will teach you how to write a custom collector plugin in Go language, which in turn can be used in your production environment.

We will start with a very simple example - building a minimal plugin and test that it's working correctly. After you obtain the basics, we will instruct you how to write real, useful collector (gathering system metrics) utilizing advanced features that plugin-go V2 has to offer:

  • defining supported metrics
  • build-in filtering mechanism
  • defining custom configuration
  • store state between independent collection requests
  • etc.

Each part of the tutorial contain complete golang source code, which you can run and modify depending on your needs.

Only version 2 of plugin-lib-go is covered in this tutorial. Examples and plugin catalog related to version 1 can be found in the Writing a Plugin section.

Content

Directories

Path Synopsis
internal
plugins/collector/proxy
Package proxy : 1) Manages context for different task created for the same plugin 2) Serves as an entry point for any "controller" (like.
Package proxy : 1) Manages context for different task created for the same plugin 2) Serves as an entry point for any "controller" (like.
tutorial module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL