Skip to content

Commit

Permalink
Remove calls to 6.x ES _xpack/* API endpoints (#18609)
Browse files Browse the repository at this point in the history
* Remove guard for _xpack/monitoring endpoint

* Removing guard for _xpack/license endpoint

* Removing guard for _xpack/ml/anomaly_detectors/_all/_stats endpoint
  • Loading branch information
ycombinator authored May 26, 2020
1 parent 33e323c commit ce7e2fd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
9 changes: 1 addition & 8 deletions libbeat/esleg/eslegclient/bulkapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,7 @@ func newMonitoringBulkRequest(
params map[string]string,
body BodyEncoder,
) (*bulkRequest, error) {
var path string
var err error
if esVersion.Major < 7 {
path, err = makePath("_xpack", "monitoring", "_bulk")
} else {
path, err = makePath("_monitoring", "bulk", "")
}

path, err := makePath("_monitoring", "bulk", "")
if err != nil {
return nil, err
}
Expand Down
13 changes: 1 addition & 12 deletions metricbeat/module/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,7 @@ func GetLicense(http *helper.HTTP, resetURI string) (*License, error) {
}

// License not found in cache, fetch it from Elasticsearch
info, err := GetInfo(http, resetURI)
if err != nil {
return nil, err
}
var licensePath string
if info.Version.Number.Major < 7 {
licensePath = "_xpack/license"
} else {
licensePath = "_license"
}

content, err := fetchPath(http, resetURI, licensePath, "")
content, err := fetchPath(http, resetURI, "_license", "")
if err != nil {
return nil, err
}
Expand Down
10 changes: 2 additions & 8 deletions metricbeat/module/elasticsearch/ml_job/ml_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func init() {
}

const (
jobPathSuffix = "/anomaly_detectors/_all/_stats"
statsPath = "/_ml/anomaly_detectors/_all/_stats"
)

// MetricSet for ml job
Expand All @@ -44,7 +44,7 @@ type MetricSet struct {
// any MetricSet specific configuration options if there are any.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// Get the stats from the local node
ms, err := elasticsearch.NewMetricSet(base, "") // servicePath will be set in Fetch() based on ES version
ms, err := elasticsearch.NewMetricSet(base, statsPath)
if err != nil {
return nil, err
}
Expand All @@ -71,12 +71,6 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
return err
}

if info.Version.Number.Major < 7 {
m.SetServiceURI("/_xpack/ml" + jobPathSuffix)
} else {
m.SetServiceURI("/_ml" + jobPathSuffix)
}

content, err := m.HTTP.FetchContent()
if err != nil {
return err
Expand Down

0 comments on commit ce7e2fd

Please sign in to comment.