Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/neon-20/prom-grafana-nodejs-
https://github.com/neon-20/prom-grafana-nodejs-
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/neon-20/prom-grafana-nodejs-
- Owner: Neon-20
- Created: 2024-05-27T23:54:25.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-05-28T21:01:28.000Z (7 months ago)
- Last Synced: 2024-05-30T05:54:24.736Z (7 months ago)
- Language: TypeScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Prometheus + Grafana with Node.js (TypeScript) Service
This repository demonstrates how to set up Prometheus and Grafana to monitor a Node.js service written in TypeScript. Follow the steps below to get started.
## Prerequisites
Before you begin, ensure you have the following installed on your machine:
- Docker
- Docker Compose
- Node.js
- npm or yarn## Steps
### 1. Clone the Repository
Clone this repository to your local machine using the following command:
```bash
git clone https://github.com/Neon-20/prom-grafana-nodejs-.git
cd prometheus-grafana-nodejs
```### 2. Install Node.js Dependencies
Navigate to the nodejs-service directory and install the dependencies:
```bash
cd nodejs-service
npm install
# or if you are using yarn
yarn install
```### 3. Configure Prometheus
Prometheus configuration is located in the prometheus directory. You can modify the prometheus.yml file to scrape the Node.js service metrics:
```bash
global:
scrape_interval: 15sscrape_configs:
- job_name: 'nodejs-service'
static_configs:
- targets: ['nodejs-service:3000']
```### 4. Add DockerFile & docker-compose
Starting grafana at localhost:3001 and prometheus at localhost:9090
```bash
FROM node:20# Create app directory
WORKDIR /usr/src/app# Install app dependencies
COPY package*.json ./RUN npm install
RUN npm install --save-dev typescript
# Bundle app source
COPY . .EXPOSE 3000
CMD [ "npm","start" ]
```docker-compose.yml 👇🏻
```bash
version: '3.8'services:
node-app:
build: ./
ports:
- "3000:3000"
networks:
- monitoringprometheus:
image: prom/prometheus:latest
volumes:
- ./:/etc/prometheus
ports:
- "9090:9090"
networks:
- monitoringgrafana:
image: grafana/grafana:latest
ports:
- "3001:3000"
networks:
- monitoring
environment:
- GF_SECURITY_ADMIN_PASSWORD=adminnetworks:
monitoring:
```### 5. Start the Services
Use Docker Compose to start Prometheus, Grafana, and the Node.js service:
```bash
docker-compose up
```This command will start all the services in detached mode.
### 6. Access the ServicesPrometheus: http://localhost:9090
Grafana: http://localhost:3000
Node.js Service: http://localhost:3001