Couldn't find any Elasticsearch data

Hi all,

Dockerfile ->

FROM node:20

WORKDIR /src

COPY package*.json ./

RUN npm install

ADD . /src

logger.js file ->

const winston = require('winston');

const logger = winston.createLogger({
format: winston.format.combine(
winston.format.timestamp(),
winston.format.json()
),
transports:[
new winston.transports.Console(),
new winston.transports.File({filename: 'logs/shortify-logs-2024-07-27.log'})
]
})

module.exports = logger

docker-compose file ->

version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.1
ports:
- "9200:9200"
environment:
- discovery.type=single-node
kibana:
image: docker.elastic.co/kibana/kibana:7.9.1
ports:
- "5601:5601"
depends_on:
- elasticsearch

filebeat:
build:
context: ./filebeat
container_name: filebeat
command: filebeat -e -strict.perms=false
volumes:
- ./logs:/src/logs
depends_on:
- elasticsearch
- kibana

nodejs-app:
build:
context: .
dockerfile: Dockerfile
container_name: nodejs-app
ports:
- "3100:3100"
depends_on:
- elasticsearch
volumes:
- ./logs:/src/logs
command : ["node" , "app.js"]

volumes:
elasticsearch_data:
driver: local

filebeat folder Dockerfile ->
FROM docker.elastic.co/beats/filebeat-oss:7.9.1

COPY filebeat.yml /usr/share/filebeat/filebeat.yml

USER root

RUN chown -R root /usr/share/filebeat/

RUN chmod -R go-w /usr/share/filebeat/

filebeat folder filebeat.yml file->

name: "nodejs-app-filebeat"
logging.metrics.enabled: false
xpack.security.enabled: false
xpack.monitoring.enabled: false
setup.ilm.enabled: false
setup.template.enabled: false

filebeat.inputs:

  • type: log
    scan_frequency: 1s
    enabled: true
    paths:
    • /src/logs/*.log
      fields:
    • service: nodejs-app
      fields_under_root: true
      json:
      keys_under_root: true
      overwrite_keys: true
      message_key: 'message'

output.elasticsearch:
hosts: ["elasticsearch:9200"]
index: "nodejs-app"

I am able to run elastic, kibana, filebeat and nodejs app container but inside http://localhost:5601/ if i click on discover it is giving error -> Couldn't find any Elasticsearch data Please help. thanks in advance.