Skip to content

Commit

Permalink
Removing xpack.monitoring.* settings (#18608)
Browse files Browse the repository at this point in the history
* Removing xpack.monitoring.* setting and corresponding code

* Updating docs

* Adding CHANGELOG entry

* Removing ES calls to custom monitoring endpoints!

* Removing xpack monitoring API params

* Removing format from test
  • Loading branch information
ycombinator authored Jul 17, 2020
1 parent 6197850 commit a6f180e
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 512 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Remove the non-ECS `agent.hostname` field. Use the `agent.name` or `agent.id` fields for an identifier. {issue}16377[16377] {pull}18328[18328]
- Make error message about locked data path actionable. {pull}18667[18667]
- Ensure dynamic template names are unique for the same field. {pull}18849[18849]
- Remove the deprecated `xpack.monitoring.*` settings. Going forward only `monitoring.*` settings may be used. {issue}9424[9424] {pull}18608[18608]

*Auditbeat*

Expand Down
8 changes: 2 additions & 6 deletions libbeat/cmd/instance/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -888,12 +888,9 @@ func (b *Beat) clusterUUIDFetchingCallback() (elasticsearch.ConnectCallback, err
}

func (b *Beat) setupMonitoring(settings Settings) (report.Reporter, error) {
monitoringCfg, reporterSettings, err := monitoring.SelectConfig(b.Config.MonitoringBeatConfig)
if err != nil {
return nil, err
}
monitoringCfg := b.Config.MonitoringBeatConfig.Monitoring

monitoringClusterUUID, err := monitoring.GetClusterUUID(b.Config.MonitoringBeatConfig.Monitoring)
monitoringClusterUUID, err := monitoring.GetClusterUUID(monitoringCfg)
if err != nil {
return nil, err
}
Expand All @@ -914,7 +911,6 @@ func (b *Beat) setupMonitoring(settings Settings) (report.Reporter, error) {

settings := report.Settings{
DefaultUsername: settings.Monitoring.DefaultUsername,
Format: reporterSettings.Format,
ClusterUUID: monitoringClusterUUID,
}
reporter, err := report.New(b.Info, settings, monitoringCfg, b.Config.Output)
Expand Down
15 changes: 6 additions & 9 deletions libbeat/docs/monitoring/monitoring-beats.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

You can use the {stack} {monitor-features} to gain insight into the health of
ifndef::apm-server[]
{beatname_uc} instances running in your environment.
{beatname_uc} instances running in your environment.
endif::[]
ifdef::apm-server[]
{beatname_uc}.
{beatname_uc}.
endif::[]

To monitor {beatname_uc}, make sure monitoring is enabled on your {es} cluster,
Expand All @@ -23,18 +23,15 @@ of following methods:
* <<monitoring-internal-collection,Internal collection>> - Internal
collectors send monitoring data directly to your monitoring cluster.
ifndef::serverless[]
* <<monitoring-metricbeat-collection, {metricbeat} collection>> -
* <<monitoring-metricbeat-collection, {metricbeat} collection>> -
{metricbeat} collects monitoring data from your {beatname_uc} instance
and sends it directly to your monitoring cluster.
endif::[]
* <<monitoring-internal-collection-legacy,Legacy collection (deprecated)>> -
Legacy collectors send monitoring data to your production cluster.


//Commenting out this link temporarily until the general monitoring docs can be
//updated.
//To learn about monitoring in general, see
//{ref}/monitor-elasticsearch-cluster.html[Monitor a cluster].
//updated.
//To learn about monitoring in general, see
//{ref}/monitor-elasticsearch-cluster.html[Monitor a cluster].

--

Expand Down

This file was deleted.

138 changes: 0 additions & 138 deletions libbeat/docs/monitoring/shared-monitor-config-legacy.asciidoc

This file was deleted.

52 changes: 0 additions & 52 deletions libbeat/esleg/eslegclient/bulkapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"go.elastic.co/apm"
"go.elastic.co/apm/module/apmhttp"

"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/logp"
)

Expand Down Expand Up @@ -94,43 +93,6 @@ func (conn *Connection) Bulk(
return conn.sendBulkRequest(requ)
}

// SendMonitoringBulk creates a HTTP request to the X-Pack Monitoring API containing a bunch of
// operations and sends them to Elasticsearch. The request is retransmitted up to max_retries
// before returning an error.
func (conn *Connection) SendMonitoringBulk(
params map[string]string,
body []interface{},
) (BulkResult, error) {
if len(body) == 0 {
return nil, nil
}

enc := conn.Encoder
enc.Reset()
if err := bulkEncode(conn.log, enc, body); err != nil {
return nil, err
}

if !conn.version.IsValid() {
if err := conn.Connect(); err != nil {
return nil, err
}
}

mergedParams := mergeParams(conn.ConnectionSettings.Parameters, params)

requ, err := newMonitoringBulkRequest(conn.GetVersion(), conn.URL, mergedParams, enc)
if err != nil {
return nil, err
}

_, result, err := conn.sendBulkRequest(requ)
if err != nil {
return nil, err
}
return result, nil
}

func newBulkRequest(
urlStr string,
index, docType string,
Expand All @@ -145,20 +107,6 @@ func newBulkRequest(
return newBulkRequestWithPath(urlStr, path, params, body)
}

func newMonitoringBulkRequest(
esVersion common.Version,
urlStr string,
params map[string]string,
body BodyEncoder,
) (*bulkRequest, error) {
path, err := makePath("_monitoring", "bulk", "")
if err != nil {
return nil, err
}

return newBulkRequestWithPath(urlStr, path, params, body)
}

func newBulkRequestWithPath(
urlStr string,
path string,
Expand Down
28 changes: 1 addition & 27 deletions libbeat/monitoring/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,11 @@ import (
"errors"

"github.com/elastic/beats/v7/libbeat/common"
"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
"github.com/elastic/beats/v7/libbeat/monitoring/report"
)

// BeatConfig represents the part of the $BEAT.yml to do with monitoring settings
type BeatConfig struct {
XPackMonitoring *common.Config `config:"xpack.monitoring"`
Monitoring *common.Config `config:"monitoring"`
Monitoring *common.Config `config:"monitoring"`
}

type Mode uint8
Expand All @@ -42,11 +39,6 @@ const (
Full
)

var (
errMonitoringBothConfigEnabled = errors.New("both xpack.monitoring.* and monitoring.* cannot be set. Prefer to set monitoring.* and set monitoring.elasticsearch.hosts to monitoring cluster hosts")
warnMonitoringDeprecatedConfig = "xpack.monitoring.* settings are deprecated. Use monitoring.* instead, but set monitoring.elasticsearch.hosts to monitoring cluster hosts."
)

// Default is the global default metrics registry provided by the monitoring package.
var Default = NewRegistry()

Expand Down Expand Up @@ -85,24 +77,6 @@ func Clear() error {
return Default.Clear()
}

// SelectConfig selects the appropriate monitoring configuration based on the user's settings in $BEAT.yml. Users may either
// use xpack.monitoring.* settings OR monitoring.* settings but not both.
func SelectConfig(beatCfg BeatConfig) (*common.Config, *report.Settings, error) {
switch {
case beatCfg.Monitoring.Enabled() && beatCfg.XPackMonitoring.Enabled():
return nil, nil, errMonitoringBothConfigEnabled
case beatCfg.XPackMonitoring.Enabled():
cfgwarn.Deprecate("8.0.0", warnMonitoringDeprecatedConfig)
monitoringCfg := beatCfg.XPackMonitoring
return monitoringCfg, &report.Settings{Format: report.FormatXPackMonitoringBulk}, nil
case beatCfg.Monitoring.Enabled():
monitoringCfg := beatCfg.Monitoring
return monitoringCfg, &report.Settings{Format: report.FormatBulk}, nil
default:
return nil, nil, nil
}
}

// GetClusterUUID returns the value of the monitoring.cluster_uuid setting, if it is set.
func GetClusterUUID(monitoringCfg *common.Config) (string, error) {
if monitoringCfg == nil {
Expand Down
Loading

0 comments on commit a6f180e

Please sign in to comment.