Skip to content

Commit

Permalink
chore(): support collect type
Browse files Browse the repository at this point in the history
  • Loading branch information
simonswu committed Dec 26, 2023
1 parent 160feb3 commit 73ab0f6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ replace (
github.com/docker/go-plugins-helpers => github.com/elastic/go-plugins-helpers v0.0.0-20200207104224-bdf17607b79f
github.com/dop251/goja => github.com/andrewkroh/goja v0.0.0-20190128172624-dd2ac4456e20
github.com/dop251/goja_nodejs => github.com/dop251/goja_nodejs v0.0.0-20171011081505-adff31b136e6
github.com/elastic/elastic-agent-system-metrics => github.com/easyops-cn/elastic-agent-system-metrics v0.0.0-20230116033658-1eb4d4676fdf
github.com/elastic/elastic-agent-system-metrics => github.com/easyops-cn/elastic-agent-system-metrics v0.0.0-20231226095934-9a9b02233d5f
github.com/fsnotify/fsevents => github.com/elastic/fsevents v0.0.0-20181029231046-e1d381a4d270
github.com/fsnotify/fsnotify => github.com/adriansr/fsnotify v1.4.8-0.20211018144411-a81f2b630e7c
github.com/godror/godror => github.com/godror/godror v0.33.2 // updating to v0.24.2 caused a breaking change
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/easyops-cn/elastic-agent-system-metrics v0.0.0-20230116033658-1eb4d4676fdf h1:9hyL+SclPudsaBCWJZ98dikpu1NKelx18dNkAY94ozs=
github.com/easyops-cn/elastic-agent-system-metrics v0.0.0-20230116033658-1eb4d4676fdf/go.mod h1:vTqfhtj83LlPKbusEwrEywZv13nhPExwINB3PkeRQeo=
github.com/easyops-cn/elastic-agent-system-metrics v0.0.0-20231226095934-9a9b02233d5f h1:SBkqjjynB80x1FAsLi07zMXeyFUrLe9Jz8KVU5nedLs=
github.com/easyops-cn/elastic-agent-system-metrics v0.0.0-20231226095934-9a9b02233d5f/go.mod h1:vTqfhtj83LlPKbusEwrEywZv13nhPExwINB3PkeRQeo=
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
github.com/eclipse/paho.mqtt.golang v1.3.5 h1:sWtmgNxYM9P2sP+xEItMozsR3w0cqZFlqnNN1bdl41Y=
github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
Expand Down
8 changes: 6 additions & 2 deletions metricbeat/module/system/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func init() {

// Config stores the metricset-local config
type Config struct {
IgnoreTypes []string `config:"filesystem.ignore_types"`
IgnoreTypes []string `config:"filesystem.ignore_types"`
CollectTypes []string `config:"filesystem.collect_types"`
}

// MetricSet for fetching filesystem metrics.
Expand All @@ -69,6 +70,9 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
if len(config.IgnoreTypes) > 0 {
logp.Info("Ignoring filesystem types: %s", strings.Join(config.IgnoreTypes, ", "))
}
if len(config.CollectTypes) > 0 {
config.CollectTypes = strings.Split(config.CollectTypes[0], ",")
}
return &MetricSet{
BaseMetricSet: base,
config: config,
Expand All @@ -79,7 +83,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Fetch fetches filesystem metrics for all mounted filesystems and returns
// an event for each mount point.
func (m *MetricSet) Fetch(r mb.ReporterV2) error {
fsList, err := fs.GetFilesystems(m.sys, fs.BuildFilterWithList(m.config.IgnoreTypes))
fsList, err := fs.GetFilesystems(m.sys, fs.BuildFilterWithList(m.config.IgnoreTypes, m.config.CollectTypes))
if err != nil {
return fmt.Errorf("error fetching filesystem list: %w", err)
}
Expand Down
6 changes: 5 additions & 1 deletion metricbeat/module/system/fsstat/fsstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
base.Logger().Info("Ignoring filesystem types: %s", strings.Join(config.IgnoreTypes, ", "))
}

if len(config.CollectTypes) > 0 {
config.CollectTypes = strings.Split(config.CollectTypes[0], ",")
}

return &MetricSet{
BaseMetricSet: base,
config: config,
Expand All @@ -70,7 +74,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Fetch fetches filesystem metrics for all mounted filesystems and returns
// a single event containing aggregated data.
func (m *MetricSet) Fetch(r mb.ReporterV2) error {
fsList, err := fs.GetFilesystems(m.sys, fs.BuildFilterWithList(m.config.IgnoreTypes))
fsList, err := fs.GetFilesystems(m.sys, fs.BuildFilterWithList(m.config.IgnoreTypes, m.config.CollectTypes))
if err != nil {
return fmt.Errorf("error fetching filesystem list: %w", err)
}
Expand Down

0 comments on commit 73ab0f6

Please sign in to comment.