This is a simple example of how to use Prometheus with Express. To run this example, you need to have Docker installed.
- Clone this repository
- Clone Dockprom
- Access the
dockprom
folder - In
dockprom
folder, access theprometheus/prometheus.yml
file and add the following lines at the endscrape_configs
- job_name: nodejs
scrape_interval: 10s
honor_labels: true
static_configs:
- targets: ['172.17.0.1:3333'] # 'node-app', 'localhost:3333', 'host.docker.internal:9991'
Note: If you are using Windows or Mac and your app is running at the host machine, you need to use
host.docker.internal
instead oflocalhost
. If you are using Linux, you should use172.17.0.1
. If you are running the app together with dockprom, you can useyour-app-service
as target.
- Run
docker-compose up -d
indockprom
folder
If you are running your app at the host machine, you need to change the targets
in prometheus.yml
to host.docker.internal:9991
for Mac or Windows or 172.17.0.1:3333
for Linux.
- Access this repository folder
- Run
npm install
- Run
docker-compose up -d
- Access
http://localhost:3333
to see the app running - Access
http://localhost:9090
to see Prometheus running - Access
http://localhost:3000
to see Grafana running