Hi all,
Using 7.15.1 version for all
- I am able to see only app in "Time spent by span type" section. in my case it should show app, http, redis, mongo... but not showing
- in "Trace sample" i am able to see my api's route.. but not its bifurcation(third party api's/ redis/ mongo) called inside it.
What agent are you using (type and version)? - "elastic-apm-node": "^4.7.1",
What client libraries are you using for DB, HTTP, Redis (type and version)?
DB- "mongodb": "^4.4.1"
HTTP - simple http call
Redis - "ioredis": "^4.28.5"
Did you look in your APM agent's documentation to see that the clients you are using are supported? yes supported. Supported technologies | APM Node.js Agent Reference [4.x] | Elastic
What does your APM agent log says?
{"log.level":"info","@timestamp":"2024-08-08T06:48:48.449Z","log.logger":"request","log.origin":{"file.name":"middleware/log_middleware.go","file.line":63},"message":"request accepted","service.name":"apm-server","url.original":"/intake/v2/events","http.request.method":"POST","user_agent.original":"apm-agent-nodejs/4.7.2 (Template 1.0.0)","source.address":"172.21.0.1","http.request.id":"619cda47-0046-4268-94c9-050e29c20374","event.duration":10001330339,"http.response.status_code":202,"ecs.version":"1.6.0"}
---------docker-compose.yml-------------
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.15.1
ports:
- "9200:9200"
environment:
- discovery.type=single-node
kibana:
image: docker.elastic.co/kibana/kibana:7.15.1
ports:
- "5601:5601"
depends_on:
- elasticsearch
filebeat:
build:
context: ./filebeat
container_name: filebeat
command: filebeat -e -strict.perms=false
volumes:
- path_to_log:/app/logs/template
depends_on:
- elasticsearch
- kibana
apm-server:
image: docker.elastic.co/apm/apm-server:7.15.1
environment:
- apm-server.host=0.0.0.0:8200
- output.elasticsearch.hosts=["http://elasticsearch:9200"]
ports:
- "8200:8200"
depends_on:
- elasticsearch
template:
network_mode: "host"
build:
context: .
dockerfile: Dockerfile
container_name: template
depends_on:
- elasticsearch
env_file:
- .env
volumes:
- /etc/hosts:/etc/hosts
- ./logs/template:/app/logs
volumes:
elasticsearch_data:
driver: local
-----apm code in route------
app.use((req, res, next) => {
const transaction = APM.startTransaction(req.method + ' ' + req.url, 'request')
req.setTransactionName = (name) => {
if (transaction) {
transaction.setName(name)
}
}
res.on('finish', () => {
if (transaction) {
if (res.statusCode >= 400 && res.statusCode < 600) {
// Capture error for non-200 status codes
APM.captureError(new Error(HTTP Error: ${res.statusCode}
), {
custom: {
statusCode: res.statusCode,
responseTime: transaction.duration()
}
})
transaction.result = 'HTTP ' + res.statusCode
} else {
transaction.result = 'success'
}
transaction.end()
}
})
})`
----------apm ----------------
import apm from 'elastic-apm-node'
apm.start({
serviceName: 'Template',
// Use if APM Server requires a secret token
secretToken: '',
// Set the custom APM Server URL (default: http://localhost:8200)
serverUrl: 'http://localhost:8200',
// Set the service {environment
environment: "development"
})
Please help.