forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move parts of metricset code to Elasticsearch module
This is inspired by elastic#7074. More work is needed.
- Loading branch information
Showing
4 changed files
with
78 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package elasticsearch | ||
|
||
import ( | ||
"github.com/elastic/beats/libbeat/common/cfgwarn" | ||
"github.com/elastic/beats/metricbeat/helper" | ||
"github.com/elastic/beats/metricbeat/mb" | ||
"github.com/elastic/beats/metricbeat/mb/parse" | ||
) | ||
|
||
const ( | ||
defaultScheme = "http" | ||
pathConfigKey = "management_path_prefix" | ||
) | ||
|
||
var ( | ||
// HostParser parses host urls for RabbitMQ management plugin | ||
HostParser = parse.URLHostParserBuilder{ | ||
DefaultScheme: defaultScheme, | ||
PathConfigKey: pathConfigKey, | ||
}.Build() | ||
) | ||
|
||
// MetricSet can be used to build other metric sets that query RabbitMQ | ||
// management plugin | ||
type MetricSet struct { | ||
mb.BaseMetricSet | ||
*helper.HTTP | ||
XPack bool | ||
} | ||
|
||
// NewMetricSet creates an metric set that can be used to build other metric | ||
// sets that query RabbitMQ management plugin | ||
func NewMetricSet(base mb.BaseMetricSet, subPath string) (*MetricSet, error) { | ||
http, err := helper.NewHTTP(base) | ||
if err != nil { | ||
return nil, err | ||
} | ||
http.SetURI(http.GetURI() + subPath) | ||
|
||
config := struct { | ||
XPack bool `config:"xpack.enabled"` | ||
}{ | ||
XPack: false, | ||
} | ||
if err := base.Module().UnpackConfig(&config); err != nil { | ||
return nil, err | ||
} | ||
|
||
if config.XPack { | ||
cfgwarn.Experimental("The experimental xpack.enabled flag in elasticsearch/node_stats metricset is enabled.") | ||
} | ||
|
||
return &MetricSet{ | ||
base, | ||
http, | ||
config.XPack, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters