Displaying logs of a NodeJS app in Grafana's Dashboard

Greetings !
I’ve been asked for a university project to display the logs of my web app (made in NodeJS) as a Dashboard with Grafana, along with the postgresql database’s logs. My whole project is in docker-compose. While doing some research on the internet, I apparently saw that Loki could solve this.

I succeeded to add Loki and Promtail in the Docker-compose file of my infrastructure, but I’m struggling to figure out how to link my NodeJs App with Grafana and Loki.

I’m totally new to all this, so please… excuse my poor vocabulary.

Would someone be kind enough to help me to display the logs of my application on Grafana please?

At your disposal for any further information you may require !
Thanks in advance,

How are you doing logging in your nodejs app? Are you logging to a file?

1 Like

Sorry for my late response sir ! There is a npm module that helps to get the logs from Express. These logs are then put into a file

What does your promtail configuration look like? Is it configured to the right path where the logs are located?

1 Like

Thanks for your willingness to help !

Well, as mentionned above, I am bit new to that ! However I just opened my promtail’s configuration file and it looks empty.

Here’s an example of a promtail config file that we use when testing Loki and Grafana. It has two scrape configs (scraping means fetching data) and fetches Grafana log files and the local system logs. You maybe only need one scrape config for your node log file.

1 Like

There is a Loki webinar coming up if you want to learn more about it: https://grafana.zoom.us/webinar/register/9115857539599/WN_jPoX1vgzTK2P65f9L949NA

1 Like

Thank you @daniellee :slight_smile: ! I’m of course interested. I’ll watch from France (hopefully)