Input
Build a new input plugin
Overview
This guide walks you through creating a new input plugin for OM1. Input plugins allow you to integrate various data sources and sensors into your agent.
Prerequisites
Understanding of Go interfaces and structs
Familiarity with concurrent programming in Go
Knowledge of the data source you're integrating
Implementation Steps
Step 1: Create a Provider (Optional)
If your plugin requires complex initialization or external service integration, create a provider.
Location: /internal/providers/your_provider.go
Step 2: Create a new Plugin File
To proceed with a new input plugin integration, create a Go file. Location: /plugins/inputs/your_plugin/your_plugin.go
Required imports:
package your_plugin
import (
"context"
"github.com/openmind/om1/internal/inputs"
)Step 3: Implement the Sensor Interface
Your plugin must implement the Sensor interface defined in internal/inputs/sensor.go:
Step 4: Implement Your Plugin Struct
Step 5: Implement Required Methods
Plugin Registration
Plugins are registered using the inputs.Register function. Add an init() function to your plugin:
How it works:
The
inputs.Registerfunction maps your plugin type name to its factory functionThe
inputs.Loadfunction creates instances based on configurationPlugin type names in config files must match the registered name
Make sure your plugin is loaded
init() only runs if your package is imported. If you put your plugin in its own subdirectory (e.g. plugins/inputs/your_plugin/), you must blank-import that package from the aggregator plugins/inputs/inputs.go so it is compiled in:
Files placed directly under plugins/inputs/ (package inputs) are already part of the aggregator package and don't need a separate import. (The same pattern applies to actions via plugins/actions/actions.go.)
Requirements:
Implement the
Sensorinterface frominternal/inputs/sensor.goRegister your factory function with
inputs.RegisterEnsure the package is imported (directly under
plugins/inputs/, or blank-imported inplugins/inputs/inputs.go)
Last updated
Was this helpful?