Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beats started by agent do not respect the allow_older_versions: true configuration flag #34227

Closed
cmacknz opened this issue Jan 10, 2023 · 5 comments · Fixed by #34964
Closed
Assignees
Labels
Agent bug Team:Elastic-Agent Label for the Agent team

Comments

@cmacknz
Copy link
Member

cmacknz commented Jan 10, 2023

Beats started by agent do not respect the allow_older_versions: true flag added to the output configuration. Beats by default will not connect to older versions of Elasticsearch, unless allow_older_versions: true appears in the output configuration.

Fleet managed agents will also refuse to enroll with older versions of Elasticsearch, but it is possible to configure a standalone agent to write to an older version. In this case the agent will run but the Beats will refuse to connect with the following error:

{"log.level":"error","@timestamp":"2023-01-10T17:54:57.248Z","message":"Failed to connect to backoff(elasticsearch(https://agent-8-5-3.es.us-central1.gcp.cloud.es.io:443)): Connection marked as failed because the onConnect callback failed: Elasticsearch is too old. Please upgrade the instance. If you would like to connect to older instances set output.elasticsearch.allow_older_versions to true. ES=8.5.3, Beat=8.6.0","component":{"binary":"metricbeat","dataset":"elastic_agent.metricbeat","id":"http/metrics-monitoring","type":"http/metrics"},"log.logger":"publisher_pipeline_output","log.origin":{"file.line":150,"file.name":"pipeline/client_worker.go"},"service.name":"metricbeat","ecs.version":"1.6.0","ecs.version":"1.6.0"}

Setting allow_older_versions: true in the output section of the agent policy should resolve this but it does not. This may be because the flag isn't available on this code path when the callback is first registered:

// checkElasticsearchVersion registers a global callback to make sure ES instance we are connecting
// to is at least on the same version as the Beat.
// If the check is disabled or the output is not Elasticsearch, nothing happens.
func (b *Beat) checkElasticsearchVersion() {
if b.isConnectionToOlderVersionAllowed() {
return
}
_, _ = elasticsearch.RegisterGlobalCallback(func(conn *eslegclient.Connection) error {
esVersion := conn.GetVersion()
beatVersion, err := libversion.New(b.Info.Version)
if err != nil {
return err
}
if esVersion.LessThanMajorMinor(beatVersion) {
return fmt.Errorf("%w ES=%s, Beat=%s", elasticsearch.ErrTooOld, esVersion.String(), b.Info.Version)
}
return nil
})
}
func (b *Beat) isConnectionToOlderVersionAllowed() bool {
config := struct {
AllowOlder bool `config:"allow_older_versions"`
}{false}
_ = b.Config.Output.Config().Unpack(&config)
return config.AllowOlder
}

To reproduce this:

  1. Build or obtain the latest version of the agent, e.g. 8.6.0.
  2. Create an Elasticsearch deployment for the previous minor version e.g. 8.5.3
  3. Configure a standalone agent to write to to the 8.5.3 Elasticsearch endpoint, with the allow_older_versions: true flag set on the output. For example:
outputs:
  default:
    type: elasticsearch
    hosts: [https://agent-8-5-3.es.us-central1.gcp.cloud.es.io:443]
    username: "elastic"
    password: <REDACTED>
    allow_older_versions: true
  1. Observe that the Beats refuse to connect to Elasticsearch and the allow_older_versions: true flag is configured on the generated Beat configuration in the components directory of the elastic agent diagnostics bundle. Example:
outputs:
  elasticsearch:
    allow_older_versions: true
    bulk_max_size: 50
    hosts:
    - https://agent-8-5-3.es.us-central1.gcp.cloud.es.io:443
    password: <REDACTED>
    type: elasticsearch
    username: elastic

For example configuring

@cmacknz cmacknz added bug Agent Team:Elastic-Agent Label for the Agent team labels Jan 10, 2023
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent (Team:Elastic-Agent)

@blakerouse
Copy link
Contributor

Elastic Agent itself also has checks to ensure that the version of Fleet Server is greater than the Elastic Agent. Do we really want to allow the beats to talk to an older version of elasticsearch?

@cmacknz
Copy link
Member Author

cmacknz commented Jan 10, 2023

Yes Fleet agents can't even be enrolled in this setup. The Beats themselves can currently be configured to do this, so this is a blocker for some people to switch to a standalone agent instead. This was originally reported by some of our Solution architects working with users trying to do exactly this.

@alexsapran
Copy link
Contributor

I am facing a similar issue when trying to set up Agent for some benchmark experiments I am doing.
The reasoning behind my use case is that I want to test a build of an agent that is more recent in version than the monitoring cluster I have.
This monitoring cluster collects all the monitoring data from all the experiments, running the latest version.

belimawr added a commit to belimawr/beats that referenced this issue Jan 25, 2023
This commit is a hacky quick fix to allow Beats connecting to older
versions of Elasticsearch. Currently Beats running under Elastic-Agent
do not respect `allow_older_versions`.

Issue: elastic#34227
@belimawr
Copy link
Contributor

A monkey patch to unblock @alexsapran: https:/belimawr/beats/tree/allow-older-verisons-hardcoded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agent bug Team:Elastic-Agent Label for the Agent team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants