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
Merged

Add Elastic Agent #1005

merged 12 commits into from
Dec 14, 2020

Conversation

graphaelli
Copy link
Member

@graphaelli graphaelli commented Dec 11, 2020

What does this PR do?

Adds Elastic Agent into apm-integration-testing using --with-elastic-agent option. Elastic Agent is configured in fleet mode with system logs and metrics integrations, the usual defaults.

Why is it important?

For testing integrations with Elastic Agent eg APM.

Some things to note:

  • elastic-agent.yml can't be bind mounted into the container as agent tries to move it out of the way when fleeting. As a result it seems any customizations will have to happen after the agent is running - this will be follow as a separate effort for Add Elastic Agent container #1004.
  • The kibana instance in apm-it will direct agents to use it for fleet along with the configured elasticsearch - support for using a different kibana seems unimportant right now
  • The setup and enroll commands aren't silent so docker logs for this container are not nice. This message seems to just be a warning: Elastic Agent might not be running; unable to trigger restart
  • Elastic agent logs to various files within the container and not to stdout like usual docker logging - it ships its own logs so that's nice but it's surprising while debugging unless you know this is happening
  • The APM integration is listed but can't be installed, currently showing the following. This does not block this pr:
    image

Related issues

related #1004

@apmmachine
Copy link
Collaborator

apmmachine commented Dec 11, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Started by timer

  • Start Time: 2020-12-14T04:54:00.768+0000

  • Duration: 35 min 49 sec

Test stats 🧪

Test Results
Failed 0
Passed 442
Skipped 12
Total 454

@simitt
Copy link
Contributor

simitt commented Dec 11, 2020

Great progress!

The APM integration is listed but can't be installed, currently showing the following. This does not block this pr:

I managed to install the APM integration via navigating to Policies/Add integration.
Screenshot 2020-12-11 at 10 40 19

Something is odd when downloading the packages: on the first attempt it always returns a 404 for the 0.1.0-dev1 package, on second try it finds the APM package and downloads it successfully. The package was added by @jalvz yesterday, I don't see why it shouldn't be found on first try.

The APM Server is not yet bundled nor available via the artifacts API. While I managed to install the APM integration, the APM Server cannot actually start as it is not yet available.

@simitt
Copy link
Contributor

simitt commented Dec 11, 2020

The agent could successfully enroll, also be assigned to a new policy; but when installing the APM integration to the policy, the agent went offline soon, as it couldn't successfully checkin with fleet; resulting in following log error:

{"log.level":"error","@timestamp":"2020-12-11T10:10:45.187Z","log.origin":{"file.name":"application/fleet_gateway.go","file.line":176},"message":"Could not communicate with Checking API will retry, error: fail to checkin to fleet: Post \"http://0.0.0.0:5601/api/fleet/agents/d216e510-3b8f-11eb-b13c-0ddb183c8890/checkin?\": dial tcp 0.0.0.0:5601: connect: connection refused","ecs.version":"1.6.0"}

Not an issue with this PR, just leaving the comment here in case others try it out too - needs to be fixed separately.

@simitt
Copy link
Contributor

simitt commented Dec 11, 2020

In another attempt, starting with completely fresh docker images - the APM Server integration was now successfully installed, without any further changes.

(0) Starting integration testing with your branch and elastic-agent enabled
(1) Creating a new policy and assigning policy to agent
(2) Adding APM to the policy
Error on first attempt to check APM integration, and on first attempt to apply changes:
Screenshot 2020-12-11 at 11 36 09
Screenshot 2020-12-11 at 11 37 00
Succesful on second attempt (similar as mentioned in previous comment):
Screenshot 2020-12-11 at 11 37 23

APM Server is now running, and can be reached from inside the elastic agent docker container (port is not opened yet)
Screenshot 2020-12-11 at 11 42 14
Screenshot 2020-12-11 at 11 43 32

@graphaelli
Copy link
Member Author

Nice @simitt! I haven't been able to get it to work adding the integration via a different flow:

APM Integration

I will try the method you suggested. Any changes need to this pull request?

@graphaelli
Copy link
Member Author

I was able to reproduce your result by installing the integration from the policy page:

image

Copy link
Contributor

@simitt simitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to get this in! Just left minor comments - feel free to skip.

# FLEET_TOKEN_NAME - token name for a token to be created
# KIBANA_HOST - actual kibana host [http://localhost:5601]
# KIBANA_PASSWORD - password for accessing kibana API [changeme]
# KIBANA_USERNAME - username for accessing kibana API [elastic]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't that admin instead of elastic?

parser.add_argument(
"--elastic-agent-kibana-url",
default="http://admin:changeme@" + cls.DEFAULT_KIBANA_HOST,
help="Elastic Agent's Kibana URL"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add including username + password

@graphaelli graphaelli merged commit 82efeb7 into elastic:master Dec 14, 2020
@graphaelli graphaelli deleted the elastic-agent branch December 14, 2020 14:33
@jalvz
Copy link
Contributor

jalvz commented Dec 14, 2020

Thanks @graphaelli and @simitt !
I could reproduce the same outcome as you....

@@ -859,6 +922,10 @@ def __init__(self, **options):
if self.at_least_version("7.7"):
self.environment["XPACK_SECURITY_ENCRYPTIONKEY"] = "fhjskloppd678ehkdfdlliverpoolfcr"
self.environment["XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY"] = "fhjskloppd678ehkdfdlliverpoolfcr"
if self.at_least_version("7.8"):
self.environment["XPACK_FLEET_AGENTS_ELASTICSEARCH_HOST"] = urls[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Elastic Agent container crashes in 7.8, and I suspect it might be because these settings were named differently. I just can't find it, https://www.elastic.co/guide/en/kibana/7.10/fleet-settings-kb.html doesn't exist for previous versions...

We might just as well support >=7.10 only and revisit if needed for earlier version?

The error is pretty clear, thou:

localtesting_7.8.1_elastic-agent | {"statusCode":404,"error":"Not Found","message":"Not Found"}{"statusCode":404,"error":"Not Found","message":"Not Found"}{"statusCode":404,"error":"Not Found","message":"Not Found"}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, perhaps @simitt can include it as part of the next chunk of #1004

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants