Error enroll fleet-server

hey everyone,

i just try to enroll fleet-agent. but its error. here's my command

> bin/elastic-agent enroll --url=https://192.168.88.147:8220 \
>   --fleet-server-es=http://192.168.88.147:9200 \
>   --fleet-server-service-token=AAEAAWVsYXN0aWMvZmxlZXQtc2VydmVyL3Rva2VuLTE2NTQ3Nzg2MjIwNjI6UnJuVlctSFpTbmlzVUxYUGZhMnVMUQ \
>   --fleet-server-policy=499b5aa7-d214-5b5d-838b-3cd76469844e \
>   --certificate-authorities=/usr/share/elasticsearch/ca/ca.crt \
>   --fleet-server-es-ca=/usr/share/elasticsearch/elastic-stack-ca.p12 \
>   --fleet-server-cert=/usr/share/elasticsearch/ca/ca.crt \
>   --fleet-server-cert-key=/usr/share/elasticsearch/ca/ca.key

and here's the error

2022-06-09T21:11:13.688+0700    INFO    cmd/enroll_cmd.go:571   Spawning Elastic Agent daemon as a subprocess to complete bootstrap process.
2022-06-09T21:11:13.823+0700    INFO    application/application.go:67   Detecting execution mode
2022-06-09T21:11:13.823+0700    INFO    application/application.go:88   Agent is in Fleet Server bootstrap mode
2022-06-09T21:11:13.944+0700    INFO    [api]   api/server.go:62        Starting stats endpoint
2022-06-09T21:11:13.944+0700    INFO    application/fleet_server_bootstrap.go:130       Agent is starting
2022-06-09T21:11:13.944+0700    INFO    [api]   api/server.go:64        Metrics endpoint listening on: /var/lib/elastic-agent/data/tmp/elastic-agent.sock (configured: unix:///var/lib/elastic-agent/data/tmp/elastic-agent.sock)
2022-06-09T21:11:13.944+0700    INFO    application/fleet_server_bootstrap.go:140       Agent is stopped
2022-06-09T21:11:13.946+0700    INFO    stateresolver/stateresolver.go:48       New State ID is 8A25iVxA
2022-06-09T21:11:13.946+0700    INFO    stateresolver/stateresolver.go:49       Converging state requires execution of 1 step(s)
2022-06-09T21:11:13.977+0700    INFO    operation/operator.go:284       operation 'operation-install' skipped for fleet-server.7.17.4
2022-06-09T21:11:14.068+0700    INFO    log/reporter.go:40      2022-06-09T21:11:14+07:00 - message: Application: fleet-server--7.17.4[]: State changed to STARTING: Starting - type: 'STATE' - sub_type: 'STARTING'
2022-06-09T21:11:14.068+0700    INFO    stateresolver/stateresolver.go:66       Updating internal state
2022-06-09T21:11:14.587+0700    INFO    log/reporter.go:40      2022-06-09T21:11:14+07:00 - message: Application: fleet-server--7.17.4[]: State changed to RESTARTING: exited with code: 1 - type: 'STATE' - sub_type: 'STARTING'
2022-06-09T21:11:14.587+0700    INFO    log/reporter.go:40      2022-06-09T21:11:14+07:00 - message: Application: fleet-server--7.17.4[]: State changed to RESTARTING: Restarting - type: 'STATE' - sub_type: 'STARTING'
2022-06-09T21:11:14.587+0700    INFO    log/reporter.go:40      2022-06-09T21:11:14+07:00 - message: Application: fleet-server--7.17.4[]: State changed to STARTING: Starting - type: 'STATE' - sub_type: 'STARTING'
2022-06-09T21:11:14.689+0700    INFO    cmd/enroll_cmd.go:776   Fleet Server - Restarting
2022-06-09T21:11:15.104+0700    INFO    log/reporter.go:40      2022-06-09T21:11:15+07:00 - message: Application: fleet-server--7.17.4[]: State changed to STARTING: Starting - type: 'STATE' - sub_type: 'STARTING'
2022-06-09T21:11:16.695+0700    INFO    cmd/enroll_cmd.go:776   Fleet Server - Starting
2022-06-09T21:12:18.951+0700    WARN    status/reporter.go:236  Elastic Agent status changed to: 'degraded'
2022-06-09T21:12:18.951+0700    INFO    log/reporter.go:40      2022-06-09T21:12:18+07:00 - message: Application: fleet-server--7.17.4[]: State changed to DEGRADED: Missed last check-in - type: 'STATE' - sub_type: 'RUNNING'
2022-06-09T21:13:13.689+0700    INFO    cmd/run.go:184  Shutting down Elastic Agent and sending last events...
2022-06-09T21:13:13.690+0700    INFO    operation/operator.go:216       waiting for installer of pipeline 'default' to finish
2022-06-09T21:13:13.690+0700    INFO    process/app.go:176      Signaling application to stop because of shutdown: fleet-server--7.17.4
2022-06-09T21:13:18.956+0700    ERROR   status/reporter.go:236  Elastic Agent status changed to: 'error'
2022-06-09T21:13:18.957+0700    ERROR   log/reporter.go:36      2022-06-09T21:13:18+07:00 - message: Application: fleet-server--7.17.4[]: State changed to FAILED: Missed two check-ins - type: 'ERROR' - sub_type: 'FAILED'
2022-06-09T21:13:44.723+0700    INFO    status/reporter.go:236  Elastic Agent status changed to: 'online'
2022-06-09T21:13:44.723+0700    INFO    log/reporter.go:40      2022-06-09T21:13:44+07:00 - message: Application: fleet-server--7.17.4[]: State changed to STOPPED: Stopped - type: 'STATE' - sub_type: 'STOPPED'
2022-06-09T21:13:44.723+0700    INFO    cmd/run.go:192  Shutting down completed.
2022-06-09T21:13:44.723+0700    INFO    [api]   api/server.go:66        Stats endpoint (/var/lib/elastic-agent/data/tmp/elastic-agent.sock) finished: accept unix /var/lib/elastic-agent/data/tmp/elastic-agen

Hi @alipujaistopo, it seems the Elastic Agent is not able to start some related processes (the state goes to degraded before stopping).
I suggest to check if there are other errors in other log files related to the agent, as those may provide further insights.

where i should check the log?

Probably in data/elastic-agent-*/logs/elastic-agent-json.log and data/elastic-agent-*/logs/default/*-json.log, or if you have installed the Agent you can look at the Installation layout

how about this? what's wrong with this?

2022-06-16T00:17:24.656+0700    INFO    cmd/enroll_cmd.go:571   Spawning Elastic Agent daemon as a subprocess to complete bootstrap process.
2022-06-16T00:17:24.791+0700    INFO    application/application.go:67   Detecting execution mode
2022-06-16T00:17:24.792+0700    INFO    application/application.go:88   Agent is in Fleet Server bootstrap mode
2022-06-16T00:17:24.945+0700    INFO    [api]   api/server.go:62        Starting stats endpoint
2022-06-16T00:17:24.945+0700    INFO    application/fleet_server_bootstrap.go:130       Agent is starting
2022-06-16T00:17:24.945+0700    INFO    [api]   api/server.go:64        Metrics endpoint listening on: /var/lib/elastic-agent/data/tmp/elastic-agent.sock (configured: unix:///var/lib/elastic-agent/data/tmp/elastic-agent.sock)
2022-06-16T00:17:24.947+0700    INFO    application/fleet_server_bootstrap.go:140       Agent is stopped
2022-06-16T00:17:24.948+0700    INFO    stateresolver/stateresolver.go:48       New State ID is GOf8afVg
2022-06-16T00:17:24.948+0700    INFO    stateresolver/stateresolver.go:49       Converging state requires execution of 1 step(s)
2022-06-16T00:17:24.979+0700    INFO    operation/operator.go:284       operation 'operation-install' skipped for fleet-server.7.17.4
2022-06-16T00:17:25.136+0700    INFO    log/reporter.go:40      2022-06-16T00:17:25+07:00 - message: Application: fleet-server--7.17.4[]: State changed to STARTING: Starting - type: 'STATE' - sub_type: 'STARTING'
2022-06-16T00:17:25.136+0700    INFO    stateresolver/stateresolver.go:66       Updating internal state
2022-06-16T00:17:25.658+0700    INFO    cmd/enroll_cmd.go:776   Fleet Server - Starting
2022-06-16T00:17:26.655+0700    WARN    status/reporter.go:236  Elastic Agent status changed to: 'degraded'
2022-06-16T00:17:26.655+0700    INFO    log/reporter.go:40      2022-06-16T00:17:26+07:00 - message: Application: fleet-server--7.17.4[]: State changed to DEGRADED: Running on policy with Fleet Server integration: 499b5aa7-d214-5b5d-838b-3cd76469844e; missing config fleet.agent.id (expected during bootstrap process) - type: 'STATE' - sub_type: 'RUNNING'
2022-06-16T00:17:27.660+0700    INFO    cmd/enroll_cmd.go:757   Fleet Server - Running on policy with Fleet Server integration: 499b5aa7-d214-5b5d-838b-3cd76469844e; missing config fleet.agent.id (expected during bootstrap process)
2022-06-16T00:17:28.511+0700    INFO    cmd/enroll_cmd.go:454   Starting enrollment to URL: https://192.168.88.147:8220/
2022-06-16T00:17:29.236+0700    INFO    cmd/enroll_cmd.go:258   Elastic Agent has been enrolled; start Elastic Agent
Successfully enrolled the Elastic Agent.
2022-06-16T00:17:29.236+0700    INFO    cmd/run.go:184  Shutting down Elastic Agent and sending last events...
2022-06-16T00:17:29.237+0700    INFO    operation/operator.go:216       waiting for installer of pipeline 'default' to finish
2022-06-16T00:17:29.237+0700    INFO    process/app.go:176      Signaling application to stop because of shutdown: fleet-server--7.17.4
2022-06-16T00:17:30.737+0700    INFO    status/reporter.go:236  Elastic Agent status changed to: 'online'
2022-06-16T00:17:30.738+0700    INFO    cmd/run.go:192  Shutting down completed.
2022-06-16T00:17:30.738+0700    INFO    log/reporter.go:40      2022-06-16T00:17:30+07:00 - message: Application: fleet-server--7.17.4[]: State changed to STOPPED: Stopped - type: 'STATE' - sub_type: 'STOPPED'
2022-06-16T00:17:30.738+0700    INFO    [api]   api/server.go:66        Stats endpoint (/var/lib/elastic-agent/data/tmp/elastic-agent.sock) finished: accept unix /var/lib/elastic-agent/data/tmp/elastic-agent.sock: use of closed network connection