package main import ( "fmt" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/metric" "github.com/influxdata/telegraf/plugins/inputs" ) type MyInputPlugin struct { } func (p *MyInputPlugin) Description() string { return "My input plugin" } func (p *MyInputPlugin) SampleConfig() string { return "" } func (p *MyInputPlugin) Gather(acc telegraf.Accumulator) error { m := metric.New("mymetric", map[string]string{"tag1": "value1", "tag2": "value2"}, map[string]interface{}{"field1": 123}) acc.AddMetric(m) return nil } func init() { inputs.Add("myinput", func() telegraf.Input { return &MyInputPlugin{} }) } func main() { }In this example, we define an input plugin that creates a new metric called "mymetric" and adds it to the Accumulator using the AddMetric method. This metric has two tags and one field. We also define the plugin registration code using the "inputs" package provided by the telegraf library. Package library: telegraf.