Hello i'm new here so if i say something wrong please let me know. I was trying to make a new beat that collects k6 metrics via rest api and then send them into Elasticsearch. I follow the 7.17 Dev Guide " Creating a Beat based on Metricbeat" documentation. I have a output but it does not show me the proper output.
package k6metricset
import (
"github.com/elastic/beats/metricbeat/helper"
"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
"github.com/elastic/elastic-agent-libs/logp"
// import from beat generator
"github.com/elastic/beats/v7/metricbeat/mb"
)
// init registers the MetricSet with the central registry as soon as the program
// starts. The New function will be called later to instantiate an instance of
// the MetricSet for each host defined in the module's configuration. After the
// MetricSet has been created then Fetch will begin to be called periodically.
func init() {
mb.Registry.MustAddMetricSet("k6module", "k6metricset", New)
}
// MetricSet holds any configuration or state information. It must implement
// the mb.MetricSet interface. And this is best achieved by embedding
// mb.BaseMetricSet because it implements all of the required mb.MetricSet
// interface methods except for Fetch.
type MetricSet struct {
mb.BaseMetricSet
http *helper.HTTP
}
// New creates a new instance of the MetricSet. New is responsible for unpacking
// any MetricSet specific configuration options if there are any.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
cfgwarn.Beta("The k6module k6metricset metricset is beta.")
logp.Info("MyMetricSet: Starting to collect metrics")
config := struct{}{}
if err := base.Module().UnpackConfig(&config); err != nil {
return nil, err
}
return &MetricSet{
BaseMetricSet: base,
}, nil
}
// Fetch methods implements the data gathering and data conversion to the right
// format. It publishes the event which is then forwarded to the output. In case
// of an error set the Error field of mb.Event or simply call report.Error().
func (m *MetricSet) Fetch(report mb.ReporterV2) error {
println(report)
return GetReport(report)
}
For example when i run the beat i expect an "MyMetricSet: Starting to collect metrics" output but there is no info about this. I have data.go file too. Can someone tell me what is the issue, did i do the configuration wrong or something?