Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Add Elastic Agent #1005

Merged
merged 12 commits into from
Dec 14, 2020
Prev Previous commit
Next Next commit
use elastic-agent.yml
graphaelli committed Dec 10, 2020

Verified

This commit was signed with the committer’s verified signature.
targos Michaël Zasso
commit b3e5723c4c2b5da72b610ce05d55314f73e69f4e
140 changes: 140 additions & 0 deletions docker/elastic-agent/elastic-agent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
agent.logging.ecs: true
agent.logging.json: false
agent.logging.level: info
agent.logging.metrics.enabled: false
agent.logging.to_stderr: true

management:
mode: "local"

#outputs:
# default:
# type: elasticsearch
# hosts: [127.0.0.1:9200]
# username: elastic
# password: changeme

# Providers supply the key/values pairs that are used for variable substitution
# and conditionals. Each provider's keys are automatically prefixed with the name
# of the provider.

providers:
agent:
enabled: true

docker:
enabled: true
host: "unix:///var/run/docker.sock"
cleanup_timeout: 60

inputs:
- type: system/metrics

# The only two requirement are that it has only characters allowed in an Elasticsearch index name
# Index names must meet the following criteria:
# Lowercase only
# Cannot include \, /, *, ?, ", <, >, |, ` ` (space character), ,, #
# Cannot start with -, _, +
# Cannot be . or ..
data_stream.namespace: default
use_output: default
streams:
- metricset: cpu
# The only two requirement are that it has only characters allowed in an Elasticsearch index name
# Index names must meet the following criteria:
# Lowercase only
# Cannot include \, /, *, ?, ", <, >, |, ` ` (space character), ,, #
# Cannot start with -, _, +
# Cannot be . or ..
data_stream.dataset: system.cpu
- metricset: memory
data_stream.dataset: system.memory
- metricset: network
data_stream.dataset: system.network
- metricset: filesystem
data_stream.dataset: system.filesystem

# fleet:
# access_api_key: ""
# kibana:
# # kibana minimal configuration
# hosts: ["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: []
# reporting:
# # 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

# agent.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"

# agent.process:
# # timeout for creating new processes. when process is not successfully created by this timeout
# # start operation is considered a failure
# spawn_timeout: 30s
# # timeout for stopping processes. when process is not stopped by this timeout then the process.
# # is force killed
# stop_timeout: 30s

# agent.grpc:
# # listen address for the GRPC server that spawned processes connect back to.
# address: localhost
# # port for the GRPC server that spawned processes connect back to.
# port: 6789

# agent.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

# agent.monitoring:
# # enabled turns on monitoring of running processes
# enabled: false
# # enables log monitoring
# logs: false
# # enables metrics monitoring
# metrics: false

# # Allow fleet to reload his configuration locally on disk.
# # Notes: Only specific process configuration will be reloaded.
# agent.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
20 changes: 18 additions & 2 deletions scripts/modules/elastic_stack.py
Original file line number Diff line number Diff line change
@@ -627,18 +627,34 @@ def __init__(self, **options):
if not kibana_url.startswith("https://"):
self.environment["FLEET_ENROLL_INSECURE"] = 1

# resolve path to configuration
agent_config_path = options.get("elastic_agent_config")
if agent_config_path:
self.agent_config_path = os.path.abspath(agent_config_path)

def _content(self):
return dict(
content = dict(
depends_on=self.depends_on,
environment=self.environment,
healthcheck={
"test": ["CMD", "/bin/true"],
}
},
volumes=[
"/var/run/docker.sock:/var/run/docker.sock",
]
)
if self.agent_config_path:
content["volumes"].append("/usr/share/elastic-agent/elastic-agent.yml:" + self.agent_config_path)
return content

@classmethod
def add_arguments(cls, parser):
super(ElasticAgent, cls).add_arguments(parser)
parser.add_argument(
"--elastic-agent-config",
default="./docker/elastic-agent/elastic-agent.yml",
help="Elastic Agent config path"
)
parser.add_argument(
"--elastic-agent-kibana-url",
default="http://admin:changeme@" + cls.DEFAULT_KIBANA_HOST,