From facc0adc8c7b768aad032d3cf9227befa58c4708 Mon Sep 17 00:00:00 2001 From: Michal Pristas Date: Mon, 4 May 2020 11:48:01 +0200 Subject: [PATCH] [Elastic-Agent] Do not require unnecessary configuration (#18003) * log paths within data * changelog * removed file * empty config allowed * configuration up to date and unified * changelog * unified * switched path * unnecessary type specifier * logs-output * var run to data path * inject run so meta.json is not created at root of data --- x-pack/elastic-agent/CHANGELOG.asciidoc | 1 + x-pack/elastic-agent/_meta/common.p2.yml | 170 +++++++++--------- .../_meta/common.reference.p2.yml | 170 +++++++++--------- .../_meta/elastic-agent.docker.yml | 152 +++++++++------- .../_meta/elastic-agent.fleet.yml | 103 ++++++----- x-pack/elastic-agent/_meta/elastic-agent.yml | 151 +++++++++------- x-pack/elastic-agent/elastic-agent.docker.yml | 152 +++++++++------- .../elastic-agent/elastic-agent.reference.yml | 170 +++++++++--------- x-pack/elastic-agent/elastic-agent.yml | 170 +++++++++--------- .../pkg/agent/application/config.go | 8 +- .../agent/application/configuration_embed.go | 2 +- .../pkg/agent/application/managed_mode.go | 6 +- .../pkg/agent/application/stream.go | 2 +- .../pkg/agent/operation/config/config.go | 9 + .../pkg/agent/operation/operator.go | 16 +- x-pack/elastic-agent/pkg/artifact/config.go | 15 ++ .../pkg/core/plugin/app/monitoring/monitor.go | 5 +- .../pkg/core/plugin/app/start.go | 2 +- .../pkg/core/plugin/process/config.go | 9 + .../pkg/core/plugin/retry/config.go | 13 +- 20 files changed, 722 insertions(+), 604 deletions(-) diff --git a/x-pack/elastic-agent/CHANGELOG.asciidoc b/x-pack/elastic-agent/CHANGELOG.asciidoc index 8b635c85ae4..998d310c74d 100644 --- a/x-pack/elastic-agent/CHANGELOG.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.asciidoc @@ -44,4 +44,5 @@ - Allow CLI overrides of paths {pull}17781[17781] - Enable Filebeat input: S3, Azureeventhub, cloudfoundry, httpjson, netflow, o365audit. {pull}17909[17909] - Use data subfolder as default for process logs {pull}17960[17960] +- Do not require unnecessary configuration {pull}18003[18003] - Enable debug log level for Metricbeat and Filebeat when run under the Elastic Agent. {pull}17935[17935] diff --git a/x-pack/elastic-agent/_meta/common.p2.yml b/x-pack/elastic-agent/_meta/common.p2.yml index 651f02282dd..6ea3b10c033 100644 --- a/x-pack/elastic-agent/_meta/common.p2.yml +++ b/x-pack/elastic-agent/_meta/common.p2.yml @@ -23,99 +23,99 @@ datasources: - metricset: filesystem dataset: system.filesystem -management: - # Mode of management, the Elastic Agent support two modes of operation: - # - # local: The Elastic Agent will expect to find the inputs configuration in the local file. - # - # Default is local. - mode: "local" +# management: +# # Mode of management, the Elastic Agent support two modes of operation: +# # +# # local: The Elastic Agent will expect to find the inputs configuration in the local file. +# # +# # Default is local. +# mode: "local" - fleet: - access_token: "" - kibana: - # kibana minimal configuration - host: "localhost:5601" - ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] +# fleet: +# access_token: "" +# kibana: +# # kibana minimal configuration +# host: "localhost:5601" +# ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] - # optional values - #protocol: "https" - #username: "elastic" - #password: "changeme" - #path: "" - #ssl.verification_mode: full - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] - #ssl.cipher_suites: [] - #ssl.curve_types: [] +# # optional values +# #protocol: "https" +# #username: "elastic" +# #password: "changeme" +# #path: "" +# #ssl.verification_mode: full +# #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] +# #ssl.cipher_suites: [] +# #ssl.curve_types: [] - reporting: - log: - # format in which logs will be written, options are json or default. - format: "default" - fleet: - # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. - enabled: false +# reporting: +# log: +# # format in which logs will be written, options are json or default. +# format: "default" +# fleet: +# # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. +# enabled: false - # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. - reporting_threshold: 10000 +# # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. +# reporting_threshold: 10000 - # Frequency used to check the queue of events to be sent out to fleet. - reporting_check_frequency_sec: 30 +# # Frequency used to check the queue of events to be sent out to fleet. +# reporting_check_frequency_sec: 30 - # Allow fleet to reload his configuration locally on disk. - # Notes: Only specific process configuration will be reloaded. - reload: - # enabled configure the Elastic Agent to reload or not the local configuration. - # - # Default is true - enabled: true +# # Allow fleet to reload his configuration locally on disk. +# # Notes: Only specific process configuration will be reloaded. +# reload: +# # enabled configure the Elastic Agent to reload or not the local configuration. +# # +# # Default is true +# enabled: true - # period define how frequent we should look for changes in the configuration. - period: 10s +# # period define how frequent we should look for changes in the configuration. +# period: 10s -download: - # source of the artifacts, requires elastic like structure and naming of the binaries - # e.g /windows-x86.zip - sourceURI: "https://artifacts.elastic.co/downloads/beats/" - # path to the directory containing downloaded packages - target_directory: "${path.data}/downloads" - # timeout for downloading package - timeout: 30s - # file path to a public key used for verifying downloaded artifacts - # if not file is present agent will try to load public key from elastic.co website. - pgpfile: "${path.data}/elastic.pgp" - # install_path describes the location of installed packages/programs. It is also used - # for reading program specifications. - install_path: "${path.data}/install" +# download: +# # source of the artifacts, requires elastic like structure and naming of the binaries +# # e.g /windows-x86.zip +# sourceURI: "https://artifacts.elastic.co/downloads/beats/" +# # path to the directory containing downloaded packages +# target_directory: "${path.data}/downloads" +# # timeout for downloading package +# timeout: 30s +# # file path to a public key used for verifying downloaded artifacts +# # if not file is present agent will try to load public key from elastic.co website. +# pgpfile: "${path.data}/elastic.pgp" +# # install_path describes the location of installed packages/programs. It is also used +# # for reading program specifications. +# install_path: "${path.data}/install" -process: - # minimal port number for spawned processes - min_port: 10000 - # maximum port number for spawned processes - max_port: 30000 - # timeout for creating new processes. when process is not successfully created by this timeout - # start operation is considered a failure - spawn_timeout: 30s +# process: +# # minimal port number for spawned processes +# min_port: 10000 +# # maximum port number for spawned processes +# max_port: 30000 +# # timeout for creating new processes. when process is not successfully created by this timeout +# # start operation is considered a failure +# spawn_timeout: 30s -retry: - # Enabled determines whether retry is possible. Default is false. - enabled: true - # RetriesCount specifies number of retries. Default is 3. - # Retry count of 1 means it will be retried one time after one failure. - retriesCount: 3 - # Delay specifies delay in ms between retries. Default is 30s - delay: 30s - # MaxDelay specifies maximum delay in ms between retries. Default is 300s - maxDelay: 5m - # Exponential determines whether delay is treated as exponential. - # With 30s delay and 3 retries: 30, 60, 120s - # Default is false - exponential: false +# retry: +# # Enabled determines whether retry is possible. Default is false. +# enabled: true +# # RetriesCount specifies number of retries. Default is 3. +# # Retry count of 1 means it will be retried one time after one failure. +# retriesCount: 3 +# # Delay specifies delay in ms between retries. Default is 30s +# delay: 30s +# # MaxDelay specifies maximum delay in ms between retries. Default is 300s +# maxDelay: 5m +# # Exponential determines whether delay is treated as exponential. +# # With 30s delay and 3 retries: 30, 60, 120s +# # Default is false +# exponential: false -settings.monitoring: - # enabled turns on monitoring of running processes - enabled: false - # enables log monitoring - logs: false - # enables metrics monitoring - metrics: false +# settings.monitoring: +# # enabled turns on monitoring of running processes +# enabled: false +# # enables log monitoring +# logs: false +# # enables metrics monitoring +# metrics: false diff --git a/x-pack/elastic-agent/_meta/common.reference.p2.yml b/x-pack/elastic-agent/_meta/common.reference.p2.yml index eaa97536e0b..6ea3b10c033 100644 --- a/x-pack/elastic-agent/_meta/common.reference.p2.yml +++ b/x-pack/elastic-agent/_meta/common.reference.p2.yml @@ -23,99 +23,99 @@ datasources: - metricset: filesystem dataset: system.filesystem -management: - # Mode of management, the Elastic Agent currently only support the following mode: - # - # local: The Elastic Agent will expect to find the inputs configuration in the local file. - # - # Default is local. - mode: local +# management: +# # Mode of management, the Elastic Agent support two modes of operation: +# # +# # local: The Elastic Agent will expect to find the inputs configuration in the local file. +# # +# # Default is local. +# mode: "local" - fleet: - access_token: "" - kibana: - # kibana minimal configuration - host: "localhost:5601" - ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] +# fleet: +# access_token: "" +# kibana: +# # kibana minimal configuration +# host: "localhost:5601" +# ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] - # optional values - #protocol: "https" - #username: "elastic" - #password: "changeme" - #path: "" - #ssl.verification_mode: full - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] - #ssl.cipher_suites: [] - #ssl.curve_types: [] +# # optional values +# #protocol: "https" +# #username: "elastic" +# #password: "changeme" +# #path: "" +# #ssl.verification_mode: full +# #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] +# #ssl.cipher_suites: [] +# #ssl.curve_types: [] - reporting: - log: - # format in which logs will be written, options are json or default. - format: "default" - fleet: - # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. - enabled: false +# reporting: +# log: +# # format in which logs will be written, options are json or default. +# format: "default" +# fleet: +# # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. +# enabled: false - # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. - reporting_threshold: 10000 +# # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. +# reporting_threshold: 10000 - # Frequency used to check the queue of events to be sent out to fleet. - reporting_check_frequency_sec: 30 +# # Frequency used to check the queue of events to be sent out to fleet. +# reporting_check_frequency_sec: 30 - # Allow fleet to reload his configuration locally on disk. - # Notes: Only specific process configuration will be reloaded. - reload: - # enabled configure the Elastic Agent to reload or not the local configuration. - # - # Default is true - enabled: true +# # Allow fleet to reload his configuration locally on disk. +# # Notes: Only specific process configuration will be reloaded. +# reload: +# # enabled configure the Elastic Agent to reload or not the local configuration. +# # +# # Default is true +# enabled: true - # period define how frequent we should look for changes in the configuration. - period: 10s +# # period define how frequent we should look for changes in the configuration. +# period: 10s -download: - # source of the artifacts, requires elastic like structure and naming of the binaries - # e.g /windows-x86.zip - sourceURI: "https://artifacts.elastic.co/downloads/beats/" - # path to the directory containing downloaded packages - target_directory: "${path.data}/downloads" - # timeout for downloading package - timeout: 30s - # file path to a public key used for verifying downloaded artifacts - # if not file is present agent will try to load public key from elastic.co website. - pgpfile: "${path.data}/elastic.pgp" - # install_path describes the location of installed packages/programs. It is also used - # for reading program specifications. - install_path: "${path.data}/install" +# download: +# # source of the artifacts, requires elastic like structure and naming of the binaries +# # e.g /windows-x86.zip +# sourceURI: "https://artifacts.elastic.co/downloads/beats/" +# # path to the directory containing downloaded packages +# target_directory: "${path.data}/downloads" +# # timeout for downloading package +# timeout: 30s +# # file path to a public key used for verifying downloaded artifacts +# # if not file is present agent will try to load public key from elastic.co website. +# pgpfile: "${path.data}/elastic.pgp" +# # install_path describes the location of installed packages/programs. It is also used +# # for reading program specifications. +# install_path: "${path.data}/install" -process: - # minimal port number for spawned processes - min_port: 10000 - # maximum port number for spawned processes - max_port: 30000 - # timeout for creating new processes. when process is not successfully created by this timeout - # start operation is considered a failure - spawn_timeout: 30s +# process: +# # minimal port number for spawned processes +# min_port: 10000 +# # maximum port number for spawned processes +# max_port: 30000 +# # timeout for creating new processes. when process is not successfully created by this timeout +# # start operation is considered a failure +# spawn_timeout: 30s -retry: - # enabled determines whether retry is possible. Default is false. - enabled: true - # retries_count specifies number of retries. Default is 3. - # Retry count of 1 means it will be retried one time after one failure. - retries_count: 3 - # delay specifies delay in ms between retries. Default is 30s - delay: 30s - # max_delay specifies maximum delay in ms between retries. Default is 300s - max_delay: 5m - # Exponential determines whether delay is treated as exponential. - # With 30s delay and 3 retries: 30, 60, 120s - # Default is false - exponential: false +# retry: +# # Enabled determines whether retry is possible. Default is false. +# enabled: true +# # RetriesCount specifies number of retries. Default is 3. +# # Retry count of 1 means it will be retried one time after one failure. +# retriesCount: 3 +# # Delay specifies delay in ms between retries. Default is 30s +# delay: 30s +# # MaxDelay specifies maximum delay in ms between retries. Default is 300s +# maxDelay: 5m +# # Exponential determines whether delay is treated as exponential. +# # With 30s delay and 3 retries: 30, 60, 120s +# # Default is false +# exponential: false -settings.monitoring: - # enabled turns on monitoring of running processes - enabled: false - # enables log monitoring - logs: false - # enables metrics monitoring - metrics: false +# settings.monitoring: +# # enabled turns on monitoring of running processes +# enabled: false +# # enables log monitoring +# logs: false +# # enables metrics monitoring +# metrics: false diff --git a/x-pack/elastic-agent/_meta/elastic-agent.docker.yml b/x-pack/elastic-agent/_meta/elastic-agent.docker.yml index dbf7931b690..bccefc9b92d 100644 --- a/x-pack/elastic-agent/_meta/elastic-agent.docker.yml +++ b/x-pack/elastic-agent/_meta/elastic-agent.docker.yml @@ -23,73 +23,99 @@ datasources: - metricset: filesystem dataset: system.filesystem -management: - # Mode of management, the Elastic Agent support two modes of operation: - # - # local: The Elastic Agent will expect to find the inputs configuration in the local file. - # - # Default is local. - mode: "local" +# management: +# # Mode of management, the Elastic Agent support two modes of operation: +# # +# # local: The Elastic Agent will expect to find the inputs configuration in the local file. +# # +# # Default is local. +# mode: "local" - reporting: - log: - # format in which logs will be written, options are json or default. - format: "default" +# fleet: +# access_token: "" +# kibana: +# # kibana minimal configuration +# host: "localhost:5601" +# ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] - # Allow the Elastic Agent to reload his configuration locally on disk. - # Notes: Only specific process configuration will be reloaded. - reload: - # enabled configure the Elastic Agent to reload or not the local configuration. - # - # Default is true - enabled: true +# # optional values +# #protocol: "https" +# #username: "elastic" +# #password: "changeme" +# #path: "" +# #ssl.verification_mode: full +# #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] +# #ssl.cipher_suites: [] +# #ssl.curve_types: [] - # period define how frequent we should look for changes in the configuration. - period: 10s +# reporting: +# log: +# # format in which logs will be written, options are json or default. +# format: "default" +# fleet: +# # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. +# enabled: false -download: - # source of the artifacts, requires elastic like structure and naming of the binaries - # e.g /windows-x86.zip - sourceURI: "https://artifacts.elastic.co/downloads/beats/" - # path to the directory containing downloaded packages - target_directory: "${path.data}/downloads" - # timeout for downloading package - timeout: 30s - # file path to a public key used for verifying downloaded artifacts - # if not file is present Elastic Agent will try to load public key from elastic.co website. - pgpfile: "${path.data}/elastic.pgp" - # install_path describes the location of installed packages/programs. It is also used - # for reading program specifications. - install_path: "${path.data}/install" +# # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. +# reporting_threshold: 10000 -process: - # minimal port number for spawned processes - min_port: 10000 - # maximum port number for spawned processes - max_port: 30000 - # timeout for creating new processes. when process is not successfully created by this timeout - # start operation is considered a failure - spawn_timeout: 30s +# # Frequency used to check the queue of events to be sent out to fleet. +# reporting_check_frequency_sec: 30 -retry: - # enabled determines whether retry is possible. Default is false. - enabled: true - # retries_count specifies number of retries. Default is 3. - # Retry count of 1 means it will be retried one time after one failure. - retries_count: 3 - # delay specifies delay in ms between retries. Default is 30s - delay: 30s - # max_delay specifies maximum delay in ms between retries. Default is 300s - max_delay: 5m - # Exponential determines whether delay is treated as exponential. - # With 30s delay and 3 retries: 30, 60, 120s - # Default is false - exponential: false +# # Allow fleet to reload his configuration locally on disk. +# # Notes: Only specific process configuration will be reloaded. +# reload: +# # enabled configure the Elastic Agent to reload or not the local configuration. +# # +# # Default is true +# enabled: true -settings.monitoring: - # enabled turns on monitoring of running processes - enabled: false - # enables log monitoring - logs: false - # enables metrics monitoring - metrics: false +# # period define how frequent we should look for changes in the configuration. +# period: 10s + +# download: +# # source of the artifacts, requires elastic like structure and naming of the binaries +# # e.g /windows-x86.zip +# sourceURI: "https://artifacts.elastic.co/downloads/beats/" +# # path to the directory containing downloaded packages +# target_directory: "${path.data}/downloads" +# # timeout for downloading package +# timeout: 30s +# # file path to a public key used for verifying downloaded artifacts +# # if not file is present agent will try to load public key from elastic.co website. +# pgpfile: "${path.data}/elastic.pgp" +# # install_path describes the location of installed packages/programs. It is also used +# # for reading program specifications. +# install_path: "${path.data}/install" + +# process: +# # minimal port number for spawned processes +# min_port: 10000 +# # maximum port number for spawned processes +# max_port: 30000 +# # timeout for creating new processes. when process is not successfully created by this timeout +# # start operation is considered a failure +# spawn_timeout: 30s + +# retry: +# # Enabled determines whether retry is possible. Default is false. +# enabled: true +# # RetriesCount specifies number of retries. Default is 3. +# # Retry count of 1 means it will be retried one time after one failure. +# retriesCount: 3 +# # Delay specifies delay in ms between retries. Default is 30s +# delay: 30s +# # MaxDelay specifies maximum delay in ms between retries. Default is 300s +# maxDelay: 5m +# # Exponential determines whether delay is treated as exponential. +# # With 30s delay and 3 retries: 30, 60, 120s +# # Default is false +# exponential: false + +# settings.monitoring: +# # enabled turns on monitoring of running processes +# enabled: false +# # enables log monitoring +# logs: false +# # enables metrics monitoring +# metrics: false diff --git a/x-pack/elastic-agent/_meta/elastic-agent.fleet.yml b/x-pack/elastic-agent/_meta/elastic-agent.fleet.yml index 8d817c8212e..b8b3eb2ac99 100644 --- a/x-pack/elastic-agent/_meta/elastic-agent.fleet.yml +++ b/x-pack/elastic-agent/_meta/elastic-agent.fleet.yml @@ -2,57 +2,62 @@ # Beats is configured under Fleet, you can define most settings # from the Kibana UI. You can update this file to configure the settings that # are not supported by Fleet. -management: - mode: "fleet" +# management: +# mode: "fleet" - # Add variance between API calls to better distribute the calls. - #jitter: 5s +# # Check in frequency configure the time between calls to fleet to retrieve the new configuration. +# # +# # Default is 30s +# #checkin_frequency: 30s - # The Elastic Agent does Exponential backoff when an error happen. - # - #backoff: - # - # Initial time to wait before retrying the call. - # init: 1s - # - # Maximum time to wait before retrying the call. - # max: 10s +# # Add variance between API calls to better distribute the calls. +# #jitter: 5s -download: - # source of the artifacts, requires elastic like structure and naming of the binaries - # e.g /windows-x86.zip - sourceURI: "https://artifacts.elastic.co/downloads/beats/" - # path to the directory containing downloaded packages - target_directory: "${path.data}/downloads" - # timeout for downloading package - timeout: 30s - # file path to a public key used for verifying downloaded artifacts - # if not file is present Elastic Agent will try to load public key from elastic.co website. - pgpfile: "${path.data}/elastic.pgp" - # install_path describes the location of installed packages/programs. It is also used - # for reading program specifications. - install_path: "${path.data}/install" +# # The Elastic Agent does Exponential backoff when an error happen. +# # +# #backoff: +# # +# # Initial time to wait before retrying the call. +# # init: 1s +# # +# # Maximum time to wait before retrying the call. +# # max: 10s -process: - # minimal port number for spawned processes - min_port: 10000 - # maximum port number for spawned processes - max_port: 30000 - # timeout for creating new processes. when process is not successfully created by this timeout - # start operation is considered a failure - spawn_timeout: 30s +# download: +# # source of the artifacts, requires elastic like structure and naming of the binaries +# # e.g /windows-x86.zip +# sourceURI: "https://artifacts.elastic.co/downloads/beats/" +# # path to the directory containing downloaded packages +# target_directory: "${path.data}/downloads" +# # timeout for downloading package +# timeout: 30s +# # file path to a public key used for verifying downloaded artifacts +# # if not file is present Elastic Agent will try to load public key from elastic.co website. +# pgpfile: "${path.data}/elastic.pgp" +# # install_path describes the location of installed packages/programs. It is also used +# # for reading program specifications. +# install_path: "${path.data}/install" -retry: - # enabled determines whether retry is possible. Default is false. - enabled: true - # retries_count specifies number of retries. Default is 3. - # Retry count of 1 means it will be retried one time after one failure. - retries_count: 3 - # delay specifies delay in ms between retries. Default is 30s - delay: 30s - # max_delay specifies maximum delay in ms between retries. Default is 300s - max_delay: 5m - # Exponential determines whether delay is treated as exponential. - # With 30s delay and 3 retries: 30, 60, 120s - # Default is false - exponential: false +# process: +# # minimal port number for spawned processes +# min_port: 10000 +# # maximum port number for spawned processes +# max_port: 30000 +# # timeout for creating new processes. when process is not successfully created by this timeout +# # start operation is considered a failure +# spawn_timeout: 30s + +# retry: +# # enabled determines whether retry is possible. Default is false. +# enabled: true +# # retries_count specifies number of retries. Default is 3. +# # Retry count of 1 means it will be retried one time after one failure. +# retries_count: 3 +# # delay specifies delay in ms between retries. Default is 30s +# delay: 30s +# # max_delay specifies maximum delay in ms between retries. Default is 300s +# max_delay: 5m +# # Exponential determines whether delay is treated as exponential. +# # With 30s delay and 3 retries: 30, 60, 120s +# # Default is false +# exponential: false diff --git a/x-pack/elastic-agent/_meta/elastic-agent.yml b/x-pack/elastic-agent/_meta/elastic-agent.yml index 12fbfabc3fe..6ea3b10c033 100644 --- a/x-pack/elastic-agent/_meta/elastic-agent.yml +++ b/x-pack/elastic-agent/_meta/elastic-agent.yml @@ -23,74 +23,99 @@ datasources: - metricset: filesystem dataset: system.filesystem -management: - # Mode of management, the Elastic Agent support two modes of operation: - # - # local: The Elastic Agent will expect to find the inputs configuration in the local file. - # - # Default is local. - mode: "local" +# management: +# # Mode of management, the Elastic Agent support two modes of operation: +# # +# # local: The Elastic Agent will expect to find the inputs configuration in the local file. +# # +# # Default is local. +# mode: "local" +# fleet: +# access_token: "" +# kibana: +# # kibana minimal configuration +# host: "localhost:5601" +# ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] - reporting: - log: - # format in which logs will be written, options are json or default. - format: "default" +# # optional values +# #protocol: "https" +# #username: "elastic" +# #password: "changeme" +# #path: "" +# #ssl.verification_mode: full +# #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] +# #ssl.cipher_suites: [] +# #ssl.curve_types: [] - # Allow the Elastic Agent to reload his configuration locally on disk. - # Notes: Only specific process configuration will be reloaded. - reload: - # enabled configure the Elastic Agent to reload or not the local configuration. - # - # Default is true - enabled: true +# reporting: +# log: +# # format in which logs will be written, options are json or default. +# format: "default" +# fleet: +# # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. +# enabled: false - # period define how frequent we should look for changes in the configuration. - period: 10s +# # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. +# reporting_threshold: 10000 -download: - # source of the artifacts, requires elastic like structure and naming of the binaries - # e.g /windows-x86.zip - sourceURI: "https://artifacts.elastic.co/downloads/beats/" - # path to the directory containing downloaded packages - target_directory: "${path.data}/downloads" - # timeout for downloading package - timeout: 30s - # file path to a public key used for verifying downloaded artifacts - # if not file is present Elastic Agent will try to load public key from elastic.co website. - pgpfile: "${path.data}/elastic.pgp" - # install_path describes the location of installed packages/programs. It is also used - # for reading program specifications. - install_path: "${path.data}/install" +# # Frequency used to check the queue of events to be sent out to fleet. +# reporting_check_frequency_sec: 30 -process: - # minimal port number for spawned processes - min_port: 10000 - # maximum port number for spawned processes - max_port: 30000 - # timeout for creating new processes. when process is not successfully created by this timeout - # start operation is considered a failure - spawn_timeout: 30s +# # Allow fleet to reload his configuration locally on disk. +# # Notes: Only specific process configuration will be reloaded. +# reload: +# # enabled configure the Elastic Agent to reload or not the local configuration. +# # +# # Default is true +# enabled: true -retry: - # enabled determines whether retry is possible. Default is false. - enabled: true - # retries_count specifies number of retries. Default is 3. - # Retry count of 1 means it will be retried one time after one failure. - retries_count: 3 - # delay specifies delay in ms between retries. Default is 30s - delay: 30s - # max_delay specifies maximum delay in ms between retries. Default is 300s - max_delay: 5m - # Exponential determines whether delay is treated as exponential. - # With 30s delay and 3 retries: 30, 60, 120s - # Default is false - exponential: false +# # period define how frequent we should look for changes in the configuration. +# period: 10s -settings.monitoring: - # enabled turns on monitoring of running processes - enabled: false - # enables log monitoring - logs: false - # enables metrics monitoring - metrics: false +# download: +# # source of the artifacts, requires elastic like structure and naming of the binaries +# # e.g /windows-x86.zip +# sourceURI: "https://artifacts.elastic.co/downloads/beats/" +# # path to the directory containing downloaded packages +# target_directory: "${path.data}/downloads" +# # timeout for downloading package +# timeout: 30s +# # file path to a public key used for verifying downloaded artifacts +# # if not file is present agent will try to load public key from elastic.co website. +# pgpfile: "${path.data}/elastic.pgp" +# # install_path describes the location of installed packages/programs. It is also used +# # for reading program specifications. +# install_path: "${path.data}/install" + +# process: +# # minimal port number for spawned processes +# min_port: 10000 +# # maximum port number for spawned processes +# max_port: 30000 +# # timeout for creating new processes. when process is not successfully created by this timeout +# # start operation is considered a failure +# spawn_timeout: 30s + +# retry: +# # Enabled determines whether retry is possible. Default is false. +# enabled: true +# # RetriesCount specifies number of retries. Default is 3. +# # Retry count of 1 means it will be retried one time after one failure. +# retriesCount: 3 +# # Delay specifies delay in ms between retries. Default is 30s +# delay: 30s +# # MaxDelay specifies maximum delay in ms between retries. Default is 300s +# maxDelay: 5m +# # Exponential determines whether delay is treated as exponential. +# # With 30s delay and 3 retries: 30, 60, 120s +# # Default is false +# exponential: false + +# settings.monitoring: +# # enabled turns on monitoring of running processes +# enabled: false +# # enables log monitoring +# logs: false +# # enables metrics monitoring +# metrics: false diff --git a/x-pack/elastic-agent/elastic-agent.docker.yml b/x-pack/elastic-agent/elastic-agent.docker.yml index dbf7931b690..bccefc9b92d 100644 --- a/x-pack/elastic-agent/elastic-agent.docker.yml +++ b/x-pack/elastic-agent/elastic-agent.docker.yml @@ -23,73 +23,99 @@ datasources: - metricset: filesystem dataset: system.filesystem -management: - # Mode of management, the Elastic Agent support two modes of operation: - # - # local: The Elastic Agent will expect to find the inputs configuration in the local file. - # - # Default is local. - mode: "local" +# management: +# # Mode of management, the Elastic Agent support two modes of operation: +# # +# # local: The Elastic Agent will expect to find the inputs configuration in the local file. +# # +# # Default is local. +# mode: "local" - reporting: - log: - # format in which logs will be written, options are json or default. - format: "default" +# fleet: +# access_token: "" +# kibana: +# # kibana minimal configuration +# host: "localhost:5601" +# ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] - # Allow the Elastic Agent to reload his configuration locally on disk. - # Notes: Only specific process configuration will be reloaded. - reload: - # enabled configure the Elastic Agent to reload or not the local configuration. - # - # Default is true - enabled: true +# # optional values +# #protocol: "https" +# #username: "elastic" +# #password: "changeme" +# #path: "" +# #ssl.verification_mode: full +# #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] +# #ssl.cipher_suites: [] +# #ssl.curve_types: [] - # period define how frequent we should look for changes in the configuration. - period: 10s +# reporting: +# log: +# # format in which logs will be written, options are json or default. +# format: "default" +# fleet: +# # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. +# enabled: false -download: - # source of the artifacts, requires elastic like structure and naming of the binaries - # e.g /windows-x86.zip - sourceURI: "https://artifacts.elastic.co/downloads/beats/" - # path to the directory containing downloaded packages - target_directory: "${path.data}/downloads" - # timeout for downloading package - timeout: 30s - # file path to a public key used for verifying downloaded artifacts - # if not file is present Elastic Agent will try to load public key from elastic.co website. - pgpfile: "${path.data}/elastic.pgp" - # install_path describes the location of installed packages/programs. It is also used - # for reading program specifications. - install_path: "${path.data}/install" +# # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. +# reporting_threshold: 10000 -process: - # minimal port number for spawned processes - min_port: 10000 - # maximum port number for spawned processes - max_port: 30000 - # timeout for creating new processes. when process is not successfully created by this timeout - # start operation is considered a failure - spawn_timeout: 30s +# # Frequency used to check the queue of events to be sent out to fleet. +# reporting_check_frequency_sec: 30 -retry: - # enabled determines whether retry is possible. Default is false. - enabled: true - # retries_count specifies number of retries. Default is 3. - # Retry count of 1 means it will be retried one time after one failure. - retries_count: 3 - # delay specifies delay in ms between retries. Default is 30s - delay: 30s - # max_delay specifies maximum delay in ms between retries. Default is 300s - max_delay: 5m - # Exponential determines whether delay is treated as exponential. - # With 30s delay and 3 retries: 30, 60, 120s - # Default is false - exponential: false +# # Allow fleet to reload his configuration locally on disk. +# # Notes: Only specific process configuration will be reloaded. +# reload: +# # enabled configure the Elastic Agent to reload or not the local configuration. +# # +# # Default is true +# enabled: true -settings.monitoring: - # enabled turns on monitoring of running processes - enabled: false - # enables log monitoring - logs: false - # enables metrics monitoring - metrics: false +# # period define how frequent we should look for changes in the configuration. +# period: 10s + +# download: +# # source of the artifacts, requires elastic like structure and naming of the binaries +# # e.g /windows-x86.zip +# sourceURI: "https://artifacts.elastic.co/downloads/beats/" +# # path to the directory containing downloaded packages +# target_directory: "${path.data}/downloads" +# # timeout for downloading package +# timeout: 30s +# # file path to a public key used for verifying downloaded artifacts +# # if not file is present agent will try to load public key from elastic.co website. +# pgpfile: "${path.data}/elastic.pgp" +# # install_path describes the location of installed packages/programs. It is also used +# # for reading program specifications. +# install_path: "${path.data}/install" + +# process: +# # minimal port number for spawned processes +# min_port: 10000 +# # maximum port number for spawned processes +# max_port: 30000 +# # timeout for creating new processes. when process is not successfully created by this timeout +# # start operation is considered a failure +# spawn_timeout: 30s + +# retry: +# # Enabled determines whether retry is possible. Default is false. +# enabled: true +# # RetriesCount specifies number of retries. Default is 3. +# # Retry count of 1 means it will be retried one time after one failure. +# retriesCount: 3 +# # Delay specifies delay in ms between retries. Default is 30s +# delay: 30s +# # MaxDelay specifies maximum delay in ms between retries. Default is 300s +# maxDelay: 5m +# # Exponential determines whether delay is treated as exponential. +# # With 30s delay and 3 retries: 30, 60, 120s +# # Default is false +# exponential: false + +# settings.monitoring: +# # enabled turns on monitoring of running processes +# enabled: false +# # enables log monitoring +# logs: false +# # enables metrics monitoring +# metrics: false diff --git a/x-pack/elastic-agent/elastic-agent.reference.yml b/x-pack/elastic-agent/elastic-agent.reference.yml index 2fb40550bc7..1db6a77cca9 100644 --- a/x-pack/elastic-agent/elastic-agent.reference.yml +++ b/x-pack/elastic-agent/elastic-agent.reference.yml @@ -28,99 +28,99 @@ datasources: - metricset: filesystem dataset: system.filesystem -management: - # Mode of management, the Elastic Agent currently only support the following mode: - # - # local: The Elastic Agent will expect to find the inputs configuration in the local file. - # - # Default is local. - mode: local +# management: +# # Mode of management, the Elastic Agent support two modes of operation: +# # +# # local: The Elastic Agent will expect to find the inputs configuration in the local file. +# # +# # Default is local. +# mode: "local" - fleet: - access_token: "" - kibana: - # kibana minimal configuration - host: "localhost:5601" - ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] +# fleet: +# access_token: "" +# kibana: +# # kibana minimal configuration +# host: "localhost:5601" +# ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] - # optional values - #protocol: "https" - #username: "elastic" - #password: "changeme" - #path: "" - #ssl.verification_mode: full - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] - #ssl.cipher_suites: [] - #ssl.curve_types: [] +# # optional values +# #protocol: "https" +# #username: "elastic" +# #password: "changeme" +# #path: "" +# #ssl.verification_mode: full +# #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] +# #ssl.cipher_suites: [] +# #ssl.curve_types: [] - reporting: - log: - # format in which logs will be written, options are json or default. - format: "default" - fleet: - # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. - enabled: false +# reporting: +# log: +# # format in which logs will be written, options are json or default. +# format: "default" +# fleet: +# # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. +# enabled: false - # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. - reporting_threshold: 10000 +# # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. +# reporting_threshold: 10000 - # Frequency used to check the queue of events to be sent out to fleet. - reporting_check_frequency_sec: 30 +# # Frequency used to check the queue of events to be sent out to fleet. +# reporting_check_frequency_sec: 30 - # Allow fleet to reload his configuration locally on disk. - # Notes: Only specific process configuration will be reloaded. - reload: - # enabled configure the Elastic Agent to reload or not the local configuration. - # - # Default is true - enabled: true +# # Allow fleet to reload his configuration locally on disk. +# # Notes: Only specific process configuration will be reloaded. +# reload: +# # enabled configure the Elastic Agent to reload or not the local configuration. +# # +# # Default is true +# enabled: true - # period define how frequent we should look for changes in the configuration. - period: 10s +# # period define how frequent we should look for changes in the configuration. +# period: 10s -download: - # source of the artifacts, requires elastic like structure and naming of the binaries - # e.g /windows-x86.zip - sourceURI: "https://artifacts.elastic.co/downloads/beats/" - # path to the directory containing downloaded packages - target_directory: "${path.data}/downloads" - # timeout for downloading package - timeout: 30s - # file path to a public key used for verifying downloaded artifacts - # if not file is present agent will try to load public key from elastic.co website. - pgpfile: "${path.data}/elastic.pgp" - # install_path describes the location of installed packages/programs. It is also used - # for reading program specifications. - install_path: "${path.data}/install" +# download: +# # source of the artifacts, requires elastic like structure and naming of the binaries +# # e.g /windows-x86.zip +# sourceURI: "https://artifacts.elastic.co/downloads/beats/" +# # path to the directory containing downloaded packages +# target_directory: "${path.data}/downloads" +# # timeout for downloading package +# timeout: 30s +# # file path to a public key used for verifying downloaded artifacts +# # if not file is present agent will try to load public key from elastic.co website. +# pgpfile: "${path.data}/elastic.pgp" +# # install_path describes the location of installed packages/programs. It is also used +# # for reading program specifications. +# install_path: "${path.data}/install" -process: - # minimal port number for spawned processes - min_port: 10000 - # maximum port number for spawned processes - max_port: 30000 - # timeout for creating new processes. when process is not successfully created by this timeout - # start operation is considered a failure - spawn_timeout: 30s +# process: +# # minimal port number for spawned processes +# min_port: 10000 +# # maximum port number for spawned processes +# max_port: 30000 +# # timeout for creating new processes. when process is not successfully created by this timeout +# # start operation is considered a failure +# spawn_timeout: 30s -retry: - # enabled determines whether retry is possible. Default is false. - enabled: true - # retries_count specifies number of retries. Default is 3. - # Retry count of 1 means it will be retried one time after one failure. - retries_count: 3 - # delay specifies delay in ms between retries. Default is 30s - delay: 30s - # max_delay specifies maximum delay in ms between retries. Default is 300s - max_delay: 5m - # Exponential determines whether delay is treated as exponential. - # With 30s delay and 3 retries: 30, 60, 120s - # Default is false - exponential: false +# retry: +# # Enabled determines whether retry is possible. Default is false. +# enabled: true +# # RetriesCount specifies number of retries. Default is 3. +# # Retry count of 1 means it will be retried one time after one failure. +# retriesCount: 3 +# # Delay specifies delay in ms between retries. Default is 30s +# delay: 30s +# # MaxDelay specifies maximum delay in ms between retries. Default is 300s +# maxDelay: 5m +# # Exponential determines whether delay is treated as exponential. +# # With 30s delay and 3 retries: 30, 60, 120s +# # Default is false +# exponential: false -settings.monitoring: - # enabled turns on monitoring of running processes - enabled: false - # enables log monitoring - logs: false - # enables metrics monitoring - metrics: false +# settings.monitoring: +# # enabled turns on monitoring of running processes +# enabled: false +# # enables log monitoring +# logs: false +# # enables metrics monitoring +# metrics: false diff --git a/x-pack/elastic-agent/elastic-agent.yml b/x-pack/elastic-agent/elastic-agent.yml index 24331ef7f9f..1db6a77cca9 100644 --- a/x-pack/elastic-agent/elastic-agent.yml +++ b/x-pack/elastic-agent/elastic-agent.yml @@ -28,99 +28,99 @@ datasources: - metricset: filesystem dataset: system.filesystem -management: - # Mode of management, the Elastic Agent support two modes of operation: - # - # local: The Elastic Agent will expect to find the inputs configuration in the local file. - # - # Default is local. - mode: "local" +# management: +# # Mode of management, the Elastic Agent support two modes of operation: +# # +# # local: The Elastic Agent will expect to find the inputs configuration in the local file. +# # +# # Default is local. +# mode: "local" - fleet: - access_token: "" - kibana: - # kibana minimal configuration - host: "localhost:5601" - ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] +# fleet: +# access_token: "" +# kibana: +# # kibana minimal configuration +# host: "localhost:5601" +# ssl.certificate_authorities: ["/etc/pki/root/ca.pem"] - # optional values - #protocol: "https" - #username: "elastic" - #password: "changeme" - #path: "" - #ssl.verification_mode: full - #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] - #ssl.cipher_suites: [] - #ssl.curve_types: [] +# # optional values +# #protocol: "https" +# #username: "elastic" +# #password: "changeme" +# #path: "" +# #ssl.verification_mode: full +# #ssl.supported_protocols: [TLSv1.0, TLSv1.1, TLSv1.2] +# #ssl.cipher_suites: [] +# #ssl.curve_types: [] - reporting: - log: - # format in which logs will be written, options are json or default. - format: "default" - fleet: - # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. - enabled: false +# reporting: +# log: +# # format in which logs will be written, options are json or default. +# format: "default" +# fleet: +# # enables fleet reporter. fleet reporting can be enabled only in fleet management.mode. +# enabled: false - # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. - reporting_threshold: 10000 +# # Reporting threshold indicates how many events should be kept in-memory before reporting them to fleet. +# reporting_threshold: 10000 - # Frequency used to check the queue of events to be sent out to fleet. - reporting_check_frequency_sec: 30 +# # Frequency used to check the queue of events to be sent out to fleet. +# reporting_check_frequency_sec: 30 - # Allow fleet to reload his configuration locally on disk. - # Notes: Only specific process configuration will be reloaded. - reload: - # enabled configure the Elastic Agent to reload or not the local configuration. - # - # Default is true - enabled: true +# # Allow fleet to reload his configuration locally on disk. +# # Notes: Only specific process configuration will be reloaded. +# reload: +# # enabled configure the Elastic Agent to reload or not the local configuration. +# # +# # Default is true +# enabled: true - # period define how frequent we should look for changes in the configuration. - period: 10s +# # period define how frequent we should look for changes in the configuration. +# period: 10s -download: - # source of the artifacts, requires elastic like structure and naming of the binaries - # e.g /windows-x86.zip - sourceURI: "https://artifacts.elastic.co/downloads/beats/" - # path to the directory containing downloaded packages - target_directory: "${path.data}/downloads" - # timeout for downloading package - timeout: 30s - # file path to a public key used for verifying downloaded artifacts - # if not file is present agent will try to load public key from elastic.co website. - pgpfile: "${path.data}/elastic.pgp" - # install_path describes the location of installed packages/programs. It is also used - # for reading program specifications. - install_path: "${path.data}/install" +# download: +# # source of the artifacts, requires elastic like structure and naming of the binaries +# # e.g /windows-x86.zip +# sourceURI: "https://artifacts.elastic.co/downloads/beats/" +# # path to the directory containing downloaded packages +# target_directory: "${path.data}/downloads" +# # timeout for downloading package +# timeout: 30s +# # file path to a public key used for verifying downloaded artifacts +# # if not file is present agent will try to load public key from elastic.co website. +# pgpfile: "${path.data}/elastic.pgp" +# # install_path describes the location of installed packages/programs. It is also used +# # for reading program specifications. +# install_path: "${path.data}/install" -process: - # minimal port number for spawned processes - min_port: 10000 - # maximum port number for spawned processes - max_port: 30000 - # timeout for creating new processes. when process is not successfully created by this timeout - # start operation is considered a failure - spawn_timeout: 30s +# process: +# # minimal port number for spawned processes +# min_port: 10000 +# # maximum port number for spawned processes +# max_port: 30000 +# # timeout for creating new processes. when process is not successfully created by this timeout +# # start operation is considered a failure +# spawn_timeout: 30s -retry: - # Enabled determines whether retry is possible. Default is false. - enabled: true - # RetriesCount specifies number of retries. Default is 3. - # Retry count of 1 means it will be retried one time after one failure. - retriesCount: 3 - # Delay specifies delay in ms between retries. Default is 30s - delay: 30s - # MaxDelay specifies maximum delay in ms between retries. Default is 300s - maxDelay: 5m - # Exponential determines whether delay is treated as exponential. - # With 30s delay and 3 retries: 30, 60, 120s - # Default is false - exponential: false +# retry: +# # Enabled determines whether retry is possible. Default is false. +# enabled: true +# # RetriesCount specifies number of retries. Default is 3. +# # Retry count of 1 means it will be retried one time after one failure. +# retriesCount: 3 +# # Delay specifies delay in ms between retries. Default is 30s +# delay: 30s +# # MaxDelay specifies maximum delay in ms between retries. Default is 300s +# maxDelay: 5m +# # Exponential determines whether delay is treated as exponential. +# # With 30s delay and 3 retries: 30, 60, 120s +# # Default is false +# exponential: false -settings.monitoring: - # enabled turns on monitoring of running processes - enabled: false - # enables log monitoring - logs: false - # enables metrics monitoring - metrics: false +# settings.monitoring: +# # enabled turns on monitoring of running processes +# enabled: false +# # enables log monitoring +# logs: false +# # enables metrics monitoring +# metrics: false diff --git a/x-pack/elastic-agent/pkg/agent/application/config.go b/x-pack/elastic-agent/pkg/agent/application/config.go index edec6b4c7f8..57945ba465b 100644 --- a/x-pack/elastic-agent/pkg/agent/application/config.go +++ b/x-pack/elastic-agent/pkg/agent/application/config.go @@ -32,7 +32,13 @@ type Config struct { } func localDefaultConfig() *Config { - return &Config{} + localModeCfg, _ := config.NewConfigFrom(map[string]interface{}{ + "mode": "local", + }) + + return &Config{ + Management: localModeCfg, + } } type managementMode int diff --git a/x-pack/elastic-agent/pkg/agent/application/configuration_embed.go b/x-pack/elastic-agent/pkg/agent/application/configuration_embed.go index db61023400e..7ccc52a40a8 100644 --- a/x-pack/elastic-agent/pkg/agent/application/configuration_embed.go +++ b/x-pack/elastic-agent/pkg/agent/application/configuration_embed.go @@ -15,7 +15,7 @@ var DefaultAgentFleetConfig []byte func init() { // Packed File // _meta/elastic-agent.fleet.yml - unpacked := packer.MustUnpack("eJyMVkGTozjSvX8/o+/fLIaidtiIOViuQog29Bp3SUiXDSS5BbZkE2sDho397xsStqt6pnZjDj4Yocx8me/l419f/mF2l+ovO12dL434/0rtjpdffujd7vLLaPSXv31Bkxf9/fuf+6FXqbnBIyWD+rN3Hr/NaY9eU03LYkJQTwjmPTesZQEeGdkoScIDK5EqzFWzcnNGie7lFuwpeVIMYlORUCO46EWwUcLHnoS6Y0H2FY3ACBNdUFKc2BasK5LW3Lwq/HboUPweQ5bgQMtC2/eqMlPM6DPbAo+PYM/90FRELoR5UxLWGiW5lknRciMn+z4tNzZPbc+5iTyU5AuRgF4cC81WoNltAeQQa7l6+spJ3FEiNSe4ky+nr2gFLtwv9Ldm2bAZW7NSJ4VWmdqQ4oASVguja25yjWCqZSI1I09qg0GKYF5zeLU19PNZoUUDDlWZe8LoRt7wMIfxehbj01e0Wu4roz0J8fitWS7EcHLPUOzeizmMJwn1Hr3GR0ZCD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4aL3BvvfcVv697Gfs6l9dKsk/mmZKM3J5Y/Z5pDX0nzXa0tjuSZkcUTv7E7DLbcvhu87DD+BpjL0c1/xLIzTE9H23d7dp6lFy90rPdhFPRs3ptjXOsLQ0FSJSw29F4yHTY8ygzbTNjunH4b/ZoErnx72ZXTjvY/n3OvuA5rjmysVNmdaHs2ahJUyupy1I/19+2Yv+deMhQkvrDt4oe9DbXV4DwrKGupPUc2X3FkvXk362LcSVop4QYH7o1zOwi75wlrbO5nLwP9fFesW/yeKqZDl0eT5tfmuWN2456zez5wudUDoOV6C6+MhK3tiVxBryC3i91bc0xiz/nqsT8pYY59E46/IVYV5GbfaI+5GHmwuyMHSSftW6tevuyR1Pq/j6OkZyRpmMVn4NF6guWO1/AqzMs76n/hsv2ack73H++dOZdb7cPgEft77ki4KIjr8u3/m3vZfzcnYML1WS9dvpl1E+4j2HGdtRIpO99HlltN2n2bDeNM5OnZcslGTz2OsWU0vscnbzdQfR/j2csMKKdYjXtlvk+Jf8RvL9oZLCfLC36j/cdqeVsfXvj5ARPT4UWA3UOXC4GC1u4G+3b6rO+63Zz/9uXff/pPAAAA//+74FmX") raw, ok := unpacked["_meta/elastic-agent.fleet.yml"] if !ok { // ensure we have something loaded. diff --git a/x-pack/elastic-agent/pkg/agent/application/managed_mode.go b/x-pack/elastic-agent/pkg/agent/application/managed_mode.go index 08ff4c7a479..c440c6e1243 100644 --- a/x-pack/elastic-agent/pkg/agent/application/managed_mode.go +++ b/x-pack/elastic-agent/pkg/agent/application/managed_mode.go @@ -24,10 +24,6 @@ import ( logreporter "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter/log" ) -type managementCfg struct { - Management *config.Config `config:"management"` -} - type apiClient interface { Send( method string, @@ -92,7 +88,7 @@ func newManaged( } // Extract only management related configuration. - managementCfg := &managementCfg{} + managementCfg := &Config{} if err := rawConfig.Unpack(managementCfg); err != nil { return nil, errors.New(err, fmt.Sprintf("fail to unpack configuration from %s", path), diff --git a/x-pack/elastic-agent/pkg/agent/application/stream.go b/x-pack/elastic-agent/pkg/agent/application/stream.go index 1e8a1f10048..5d8880a9e07 100644 --- a/x-pack/elastic-agent/pkg/agent/application/stream.go +++ b/x-pack/elastic-agent/pkg/agent/application/stream.go @@ -72,7 +72,7 @@ func streamFactory(ctx context.Context, cfg *config.Config, client sender, r rep } func newOperator(ctx context.Context, log *logger.Logger, id routingKey, config *config.Config, r reporter, m monitoring.Monitor) (*operation.Operator, error) { - operatorConfig := &operatorCfg.Config{} + operatorConfig := operatorCfg.DefaultConfig() if err := config.Unpack(&operatorConfig); err != nil { return nil, err } diff --git a/x-pack/elastic-agent/pkg/agent/operation/config/config.go b/x-pack/elastic-agent/pkg/agent/operation/config/config.go index f1c15df7007..f54737151c9 100644 --- a/x-pack/elastic-agent/pkg/agent/operation/config/config.go +++ b/x-pack/elastic-agent/pkg/agent/operation/config/config.go @@ -17,3 +17,12 @@ type Config struct { DownloadConfig *artifact.Config `yaml:"download" config:"download"` } + +// DefaultConfig creates a config with pre-set default values. +func DefaultConfig() *Config { + return &Config{ + ProcessConfig: process.DefaultConfig(), + RetryConfig: retry.DefaultConfig(), + DownloadConfig: artifact.DefaultConfig(), + } +} diff --git a/x-pack/elastic-agent/pkg/agent/operation/operator.go b/x-pack/elastic-agent/pkg/agent/operation/operator.go index 4a2b2208ee8..c6c47d444ef 100644 --- a/x-pack/elastic-agent/pkg/agent/operation/operator.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operator.go @@ -10,7 +10,6 @@ import ( "os" "strings" "sync" - "time" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/configrequest" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" @@ -23,7 +22,6 @@ import ( "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring" - "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/retry" "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/state" rconfig "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig/grpc" ) @@ -65,7 +63,7 @@ func NewOperator( eventProcessor callbackHooks, monitor monitoring.Monitor) (*Operator, error) { - operatorConfig := defaultOperatorConfig() + operatorConfig := operatorCfg.DefaultConfig() if err := config.Unpack(&operatorConfig); err != nil { return nil, err } @@ -99,18 +97,6 @@ func NewOperator( return operator, nil } -func defaultOperatorConfig() *operatorCfg.Config { - return &operatorCfg.Config{ - RetryConfig: &retry.Config{ - Enabled: false, - RetriesCount: 0, - Delay: 30 * time.Second, - MaxDelay: 5 * time.Minute, - Exponential: false, - }, - } -} - // State describes the current state of the system. // Reports all known beats and theirs states. Whether they are running // or not, and if they are information about process is also present. diff --git a/x-pack/elastic-agent/pkg/artifact/config.go b/x-pack/elastic-agent/pkg/artifact/config.go index 406677cb8aa..aefe35c26e1 100644 --- a/x-pack/elastic-agent/pkg/artifact/config.go +++ b/x-pack/elastic-agent/pkg/artifact/config.go @@ -5,9 +5,12 @@ package artifact import ( + "path/filepath" "runtime" "strings" "time" + + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/paths" ) // Config is a configuration used for verifier and downloader @@ -42,6 +45,18 @@ type Config struct { DropPath string `yaml:"dropPath" config:"drop_path"` } +// DefaultConfig creates a config with pre-set default values. +func DefaultConfig() *Config { + dataPath := paths.Data() + return &Config{ + BeatsSourceURI: "https://artifacts.elastic.co/downloads/beats/", + TargetDirectory: filepath.Join(dataPath, "downloads"), + Timeout: 30 * time.Second, + PgpFile: filepath.Join(dataPath, "elastic.pgp"), + InstallPath: filepath.Join(dataPath, "install"), + } +} + // OS return configured operating system or falls back to runtime.GOOS func (c *Config) OS() string { if c.OperatingSystem != "" { diff --git a/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/monitor.go b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/monitor.go index 67fd1a96aee..07750ff5191 100644 --- a/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/monitor.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/monitor.go @@ -32,7 +32,10 @@ type wrappedConfig struct { // NewMonitor creates a monitor based on a process configuration. func NewMonitor(config *config.Config) (Monitor, error) { - cfg := &wrappedConfig{} + cfg := &wrappedConfig{ + DownloadConfig: artifact.DefaultConfig(), + } + if err := config.Unpack(&cfg); err != nil { return nil, err } diff --git a/x-pack/elastic-agent/pkg/core/plugin/app/start.go b/x-pack/elastic-agent/pkg/core/plugin/app/start.go index 9bfc40781e2..68c9df887d4 100644 --- a/x-pack/elastic-agent/pkg/core/plugin/app/start.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/start.go @@ -211,7 +211,7 @@ func (a *Application) checkGrpcHTTP(ctx context.Context, address string, ca *aut } func injectDataPath(args []string, pipelineID, id string) []string { - dataPath := filepath.Join(paths.Data(), pipelineID, id) + dataPath := filepath.Join(paths.Data(), "run", pipelineID, id) return append(args, "-E", "path.data="+dataPath) } diff --git a/x-pack/elastic-agent/pkg/core/plugin/process/config.go b/x-pack/elastic-agent/pkg/core/plugin/process/config.go index 0791692aeb4..e8a236b5de4 100644 --- a/x-pack/elastic-agent/pkg/core/plugin/process/config.go +++ b/x-pack/elastic-agent/pkg/core/plugin/process/config.go @@ -19,3 +19,12 @@ type Config struct { // TODO: cgroups and namespaces } + +// DefaultConfig creates a config with pre-set default values. +func DefaultConfig() *Config { + return &Config{ + MinPortNumber: 10000, + MaxPortNumber: 30000, + SpawnTimeout: 30 * time.Second, + } +} diff --git a/x-pack/elastic-agent/pkg/core/plugin/retry/config.go b/x-pack/elastic-agent/pkg/core/plugin/retry/config.go index a9487792a17..11cd1e7b418 100644 --- a/x-pack/elastic-agent/pkg/core/plugin/retry/config.go +++ b/x-pack/elastic-agent/pkg/core/plugin/retry/config.go @@ -21,10 +21,21 @@ type Config struct { RetriesCount int `yaml:"retriesCount" config:"retriesCount"` // Delay specifies delay in ms between retries. Default is 30s Delay time.Duration `yaml:"delay" config:"delay"` - // MaxDelay specifies maximum delay in ms between retries. Default is 300s + // MaxDelay specifies maximum delay in ms between retries. Default is 300s (5min) MaxDelay time.Duration `yaml:"maxDelay" config:"maxDelay"` // Exponential determines whether delay is treated as exponential. // With 30s delay and 3 retries: 30, 60, 120s // Default is false Exponential bool `yaml:"exponential" config:"exponential"` } + +// DefaultConfig creates a config with pre-set default values. +func DefaultConfig() *Config { + return &Config{ + Enabled: false, + RetriesCount: 3, + Delay: 30 * time.Second, + MaxDelay: 5 * time.Minute, + Exponential: false, + } +}