Skip to main content

Apm with elastic and kibana ( a nodejs example)


This project requires having an elk stack up and running. For our project, we have 3 servers


  •  The elk server with elasticsearch and kibana install with IP address( 192.168.208.132)

  • The fleet server  with IP address (192.168.208.134)

  • The web server where we gonna run our nodejs app







For our demonstration, we use elk version 8.5.2. In our journey, we will show you how to monitor a simple nodejs app with the elk apm.

To monitore your application, you have to create a fleet server in kibana. we will follow the steps below.

1) we have to create the fleet server, so we need to go into our kibana and in the menu on the left, click on fleet.





2) On the fleet page we have to click on settings and create hosts. this will allow us to configure the fleet server. In our case, it is an ubuntu server with the fleet server IP address 192.169.208.134.


3) We have to configure the ip address for our fleet server like below



4) For the output part we have to configure our elk IP address and because we do not use our own certificate, we have to add the flag ssl.verification_mode: none
This command tells elastic to do not to verify the SSL certificate that it receives. It is obvious that it is not something to do in a production environment. 

you have to choose a name for your policy and add the fleet server.





5) after adding the fleet server, we have to add an agent. this part will give you the command to run on your fleet server (192.168.208.134).
 In the deployment mode section, you have to choose quick start because in the beginning, we didn't configure any certificate. 






After following all these steps, kibana will provide the command to run on your fleet server at the bottom of the page. 
Remember to choose the commands related to your distribution. A simple copy-paste will get your server run and you will see your fleet server appear on the kibana page like below.



Now that you got your fleet and agent running. You will need to configure the integration.

Go to the menu on the left and go to the observability part and click on APM


You will get the page below and click on integration and add elastic APM


This will bring you to the page below,

you have to put the ip address of your fleet server and name the integration. Since you already create an agent policy, at the end of the page, click on the existing host and choose the policy you created and create the agent

On the page (Add elastic integration APM), you can give a name to the integration. 
For the server configuration, you can replace localhost with the IP address of your fleet server.
In the part where to add your integration, select the existing host and choose and select the agent policy that we configure at the beginning. and click save and configure



The agent should appear in the agent table 





In the web server 

Now we are done with the configuration in kibana. We have to create a basic nodejs app that will send the traces to the fleet server. 
-  install nodejs ( apt install nodejs )
-  install npm    ( apt install npm)
-  intstall the elastic-apm-node ( npm install elastic-apm-node --save)

create a file apm.js, you can find the code below. You can run the nodejs application with the command  the command node app.js


var apm = require('elastic-apm-node').start({
serviceName: 'mon test apm',
serverUrl: 'http://192.168.208.134:8200',
environment: 'production'
})

const express = require ('express')
const app = express()
const port = 3030

app.get('/',(req,res) => {
      res.send(' hello world')
          })

app.get('/demo',(req,res) => {
      res.send(' welcome demo for apm test')
              })

app.listen(port, () => {
      console.log (' App lsiten on port 3030')
})


at this moment your server runs the nodejs app and each time you make a request to your server, in our example you can run the command 
-  curl 192.168.208.133:3030
-  curl 192.168.208.133:3030/demo

The trace of the nodejs server will display in your kibana instance






Comments

Popular posts from this blog

FastAPI Instrumentalisation with prometheus and grafana Part1 [Counter]

welcome to this hands-on lab on API instrumentation using Prometheus and FastAPI! In the world of modern software development, real-time API monitoring is essential for understanding usage patterns, debugging issues, and ensuring optimal performance. In this lab, we’ll demonstrate how to enhance a FastAPI-based application with Prometheus metrics to monitor its behavior effectively. We’ve already set up the lab environment for you, complete with Grafana, Prometheus, and a PostgreSQL database. While FastAPI’s integration with databases is outside the scope of this lab, our focus will be entirely on instrumentation and monitoring. For those interested in exploring the database integration or testing , you can review the code in our repository: FastAPI Monitoring Repository . What You’ll Learn In this lab, we’ll walk you through: Setting up Prometheus metrics in a FastAPI application. Instrumenting API endpoints to track: Number of requests HTTP methods Request paths Using Grafana to vi...

Join Ubuntu 20.04 to Active Directory with SSSD and SSH Access

Join Ubuntu 20.04 to Active Directory with SSSD and SSH Access  Overview This guide walks you through joining an Ubuntu 20.04 machine to an Active Directory domain using SSSD, configuring PAM for AD user logins over SSH, and enabling automatic creation of home directories upon first login. We’ll also cover troubleshooting steps and verification commands. Environment Used Component Value Ubuntu Client       ubuntu-client.bazboutey.local Active Directory FQDN   bazboutey.local Realm (Kerberos)   BAZBOUTEY.LOCAL AD Admin Account   Administrator Step 1: Prerequisites and Package Installation 1.1 Update system and install required packages bash sudo apt update sudo apt install realmd sssd libnss-sss libpam-sss adcli \ samba-common-bin oddjob oddjob-mkhomedir packagekit \ libpam-modules openssh-server Step 2: Test DNS and Kerberos Configuration Ensure that the client can resolve the AD domain and discover services. 2.1 Test domain name resol...

ExternalDNS on Kubernetes - mirecloud homelab part 4

MireCloud Home Lab · DevOps ExternalDNS on Kubernetes Automatic Sync with BIND via RFC2136 How to fully automate DNS management in a bare-metal Kubernetes homelab using Cilium, BIND, and HashiCorp Vault. 📅 February 22, 2026 ⏱ ~10 min read 🔧 ExternalDNS v0.20.0 ☸ Kubernetes v1.34 Kubernetes v1.34 ExternalDNS v0.20.0 Cilium Gateway API BIND (RFC2136) TSIG / HMAC-SHA256 HashiCorp Vault External Secrets Operator ArgoCD (GitOps) cert-manager When you run a Kubernetes homelab with multiple exposed services — Grafana, Keycloak, ArgoCD, PgAdmin — you quickly find yourself maintaining DNS entries in BIND manually . It's repetitive, prone to errors, and breaks the GitOps flow. The solution is ExternalDNS . This controller monitors your Services, Ingresses, and HTTPRoutes in real-time, automatically pushing DNS updates to BIND as soon as a route is created. No mo...