Plugin writes do not include new dsnames but instead default to value. To confirm this issue, I used the following code from the docs but changed the dsname. I listened for the messages using the amqp1.
package main
import (
"context"
"fmt"
"time"
"collectd.org/api"
"collectd.org/plugin"
)
type examplePlugin struct{}
func (examplePlugin) Read(ctx context.Context) error {
vl := &api.ValueList{
Identifier: api.Identifier{
Host: "example.com",
Plugin: "goplug",
Type: "gauge",
},
Time: time.Now(),
Interval: 10 * time.Second,
Values: []api.Value{api.Gauge(42)},
DSNames: []string{"read"},
}
if err := plugin.Write(ctx, vl); err != nil {
return fmt.Errorf("plugin.Write: %w", err)
}
return nil
}
func init() {
plugin.RegisterRead("example", examplePlugin{})
}
func main() {}
Received Message
[
{
"values": [
42
],
"dstypes": [
"gauge"
],
"dsnames": [
"value"
],
"time": 1591894480.918,
"interval": 10,
"host": "example.com",
"plugin": "goplug",
"plugin_instance": "",
"type": "gauge",
"type_instance": ""
}
]
Expected Message
[
{
"values": [
42
],
"dstypes": [
"gauge"
],
"dsnames": [
"read"
],
"time": 1591894480.918,
"interval": 10,
"host": "example.com",
"plugin": "goplug",
"plugin_instance": "",
"type": "gauge",
"type_instance": ""
}
]
The dsnames field of the message does not container read, but rather the default string value
Plugin writes do not include new dsnames but instead default to
value. To confirm this issue, I used the following code from the docs but changed the dsname. I listened for the messages using the amqp1.Received Message
[ { "values": [ 42 ], "dstypes": [ "gauge" ], "dsnames": [ "value" ], "time": 1591894480.918, "interval": 10, "host": "example.com", "plugin": "goplug", "plugin_instance": "", "type": "gauge", "type_instance": "" } ]Expected Message
[ { "values": [ 42 ], "dstypes": [ "gauge" ], "dsnames": [ "read" ], "time": 1591894480.918, "interval": 10, "host": "example.com", "plugin": "goplug", "plugin_instance": "", "type": "gauge", "type_instance": "" } ]The
dsnamesfield of the message does not containerread, but rather the default stringvalue