Hi,
I can't make the .net core Agent work for APM Server, I get the following error
[08:32:13 ERR] {CentralConfigFetcher} Exception was thrown while fetching configuration from APM Server and parsing it. ETag: `<null>'. URL: `http://apm:8200/config/v1/agents?service.name=ITF_Microservices_CatalogSynchronizer&service.environment=Development'. Apm Server base URL: `http://apm:8200/'. WaitInterval: 5m. dbgIterationsCount: 1.
+-> Request:
Method: GET, RequestUri: 'http://apm:8200/config/v1/agents?service.name=ITF_Microservices_CatalogSynchronizer&service.environment=Development', Version: 1.1, Content: <null>, Headers:
{
User-Agent: elasticapm-dotnet/1.6.1
User-Agent: System.Net.Http/4.700.20.47203
User-Agent: .NET_Core/3.1.9
}
+-> Response:
StatusCode: 503, ReasonPhrase: 'Service Unavailable', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Cache-Control: must-revalidate, max-age=300
X-Content-Type-Options: nosniff
Date: Mon, 19 Oct 2020 08:32:13 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 52
}
+-> Response body [length: 52]:
{"error":"unable to retrieve connection to Kibana"}
Elastic.Apm.BackendComm.CentralConfig.CentralConfigFetcher+FailedToFetchConfigException: HTTP status code is Service Unavailable (503) which most likely means that APM Server supports the central configuration endpoint and Kibana connection is enabled, but Kibana connection is unavailable
at Elastic.Apm.BackendComm.CentralConfig.CentralConfigResponseParser.InterpretResponseStatusCode(HttpResponseMessage httpResponse, WaitInfoS waitInfo)
at Elastic.Apm.BackendComm.CentralConfig.CentralConfigResponseParser.ParseHttpResponse(HttpResponseMessage httpResponse, String httpResponseBody)
at Elastic.Apm.BackendComm.CentralConfig.CentralConfigFetcher.WorkLoopIteration()
I use a docker-compose file
version: '3.4'
services:
myMicroservice:
image: ${DOCKER_REGISTRY-}myMicroservice
container_name: myMicroservice
build:
context: .
dockerfile: src/myMicroservice/src/Dockerfile
depends_on:
- elasticsearch
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
container_name: elasticsearch
environment:
- discovery.type=single-node
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms4g -Xmx4g"
ulimits:
memlock:
soft: -1
hard: -1
ports:
- "9200:9200"
volumes:
- ./volumes/elasticsearch:/usr/share/elasticsearch/data
apm:
image: docker.elastic.co/apm/apm-server:7.9.2
container_name: apm
command: >
apm-server -e
-E apm-server.rum.enabled=true
-E setup.kibana.host=kibana:5601
-E setup.template.settings.index.number_of_replicas=0
-E apm-server.kibana.enabled=true
-E apm-server.kibana.host=kibana:5601
-E output.elasticsearch.hosts=["elasticsearch:9200"]
ports:
- "8200:8200"
expose:
- "8200"
links:
- elasticsearch
depends_on:
- elasticsearch
- kibana
kibana:
image: docker.elastic.co/kibana/kibana:7.9.2
container_name: kibana
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
ports:
- "5601:5601"
depends_on:
- elasticsearch
And all my containers are up
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0c5ad063e58d docker.elastic.co/apm/apm-server:7.9.2 "/usr/local/bin/dock…" 10 minutes ago Up 10 minutes 0.0.0.0:8200->8200/tcp apm
ca75710de858 mymicroservice:dev "tail -f /dev/null" 11 minutes ago Up 10 minutes 443/tcp, 0.0.0.0:60713->80/tcp mymicroservice
2d1b8eaa89fe docker.elastic.co/kibana/kibana:7.9.2 "/usr/local/bin/dumb…" 11 minutes ago Up 10 minutes 0.0.0.0:5601->5601/tcp kibana
1ab4e7260aec docker.elastic.co/elasticsearch/elasticsearch:7.9.2 "/tini -- /usr/local…" 11 minutes ago Up 11 minutes 0.0.0.0:9200->9200/tcp, 9300/tcp elasticsearch
and Kibana does communicate correclty with Elk (I can use the UI to look at my collections and so on). But the APM part is still failing.
I'm using the nuget packages
Elastic.Apm.NetCoreAll v1.6.1
Elastic.Apm.SerilogEnricher v1.5.1
Elastic.CommonSchema.Serilog v1.5.1
Here is how I create my logger
return new LoggerConfiguration()
.ReadFrom.Configuration(config)
.Enrich.WithElasticApmCorrelationInfo()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("http://elasticsearch:9200/"))
{
AutoRegisterTemplate = true,
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv6,
FailureCallback = e => Console.WriteLine("Unable to submit event " + e.MessageTemplate),
EmitEventFailure = EmitEventFailureHandling.WriteToSelfLog |
EmitEventFailureHandling.WriteToFailureSink |
EmitEventFailureHandling.RaiseCallback,
CustomFormatter = new EcsTextFormatter()
})
.WriteTo.OpenTracing()
.CreateLogger();
And my appsettings.json file
"ElasticApm": {
"ServerUrls": "http://apm:8200",
"CaptureBody": "all"
}
What am I doing wrong ?
Thank you