disable xpack API and monitoring pipeline for serverless (#15277)

This commit adds a call to identify serverless cluster before fetching `/_xpack` to verify the license and supported features.
When it is serverless, the license checker uses hardcoded xpack info instead of calling xpack API. The internal pipeline of monitoring is disabled and logs error when configured to use legacy monitoring.

Fixes: 
ingest-dev#2303
ingest-dev#2284

Co-authored-by: Rob Bavey <rob.bavey@elastic.co>
This commit is contained in:
kaisecheng 2023-08-31 17:00:13 +01:00 committed by GitHub
parent da4c918122
commit 6b2fa20622
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 352 additions and 85 deletions

View file

@ -30,9 +30,9 @@ module LogStash module Monitoring
valid_basic_license?
end
def update_license_state(xpack_info)
def update_license_state(xpack_info, is_serverless)
return if valid_basic_license?
super(xpack_info) if xpack_info
super(xpack_info, is_serverless) if xpack_info
if valid_basic_license?
logger.info("Validated license for monitoring. Enabling monitoring pipeline.")
enable_monitoring
@ -48,7 +48,7 @@ module LogStash module Monitoring
@agent.converge_state_and_update_if_running
end
def populate_license_state(xpack_info)
def populate_license_state(xpack_info, is_serverless)
if xpack_info.failed?
{
:state => :error,
@ -73,6 +73,14 @@ module LogStash module Monitoring
:log_level => :error,
:log_message => "Monitoring is not available: #{xpack_info.license_type} is not a valid license for this feature."
}
elsif !xpack_info.feature_enabled?(FEATURE) && is_serverless
{
:state => :error,
:log_level => :error,
:log_message => "Internal collection for monitoring is enabled in Logstash, but is not supported in the configured version of Elasticsearch.\n"\
"This instance of Logstash will NOT send its monitoring data to Elasticsearch. Please configure Elastic Agent to monitor Logstash. Documentation can be found at: \n"\
"https://www.elastic.co/guide/en/logstash/current/monitoring-with-elastic-agent.html"
}
elsif !xpack_info.license_active?
{
:state => :ok,