2

I am trying to setup elastic apm for nodejs application. I followed the example explained in integration page of elk.

var apm = require('elastic-apm-node').start({

// Override the service name from package.json
// Allowed characters: a-z, A-Z, 0-9, -, _, and space
    serviceName: 'pv-server',

// Use if APM Server requires a secret token
    secretToken: '',
    logLevel:"debug",
// Set the custom APM Server URL (default: http://localhost:8200)
    serverUrl: 'http://localhost:8200',
    captureBody: 'all',
    active: true,
    usePathAsTransactionName: true,

// Set the service environment
    environment: 'dev'
})

When my service starts elastic apm is showing data for CPU usages only, there is no data in transaction/traces. I am using express web framework.

enter image description here

enter image description here

dead programmer
  • 4,223
  • 9
  • 46
  • 77
  • What web framework (express, hapi, etc.) is your service using? – Alana Storm Mar 17 '22 at 14:46
  • @AlanStorm I am using express – dead programmer Mar 18 '22 at 07:38
  • I faced same problem. I solved my problem reading docs. https://www.elastic.co/guide/en/apm/agent/nodejs/current/express.html There is mentioned very import thing _It’s important that the agent is started before you require any other modules in your Node.js application - i.e. before express, http, etc._ – Banzragch. B Apr 18 '22 at 10:25

1 Answers1

1

I was having the same problem. The solution was to put the APM config before the dependencies import.

ex:

const apm = require('elastic-apm-node').start({
    ...
})

const express = require('express');
const { Sequelize, Model, DataTypes } = require('sequelize');
RWD
  • 1,145
  • 9
  • 12