To access to prometheus go to http://localhost:9090/:
- Open the URL
- Click Status > Targets in the top menu
- You should see
spring-boot-apilisted- State:
UP(Green) means it is successfully reading data from your API - State:
DOWN(Red) means it cannot reach your API container
- State:
Login Credentials:
- Username:
admin - Password:
admin(We defined this indocker-compose.yml)
How to see your data:
- Login using the credentials above
- Add Data Source:
- Go to Connections (Or Configuration) -> Data Sources
- Click Add data source -> Select Prometheus
- Connection URL:
http://prometheus:9090(Use the container name, not localhost) - Click Save & Test. You should see a green checkmark
- Import Dashboard:
- Go to Dashboards -> Import
- Enter ID: 4701 (Standard Spring Boot Dashboard) and click Load
- Select your "Prometheus" data source at the bottom
- Click Import
The standard Spring Boot dashboard (4701) covers basic JVM/Tomcat stuff, but for databases, you often need specific dashboards or custom queries.
Here are popular Community Dashboard IDs you can import (Dashboards -> Import):
- 13107 (Neo4j)
- 2583 (MongoDB) or 11378 (Spring Boot 2.1 System Monitor - includes Mongo)
To see everything in one place, create a new Dashboard in Grafana and add these queries:
mongodb_driver_pool_checkedout{application="booknet-api"}neo4j_driver_connections_active{application="booknet-api"}redis_commons_pool2_num_active{name="main-pool", application="booknet-api"}rate(mongodb_driver_commands_seconds_count{command="find"}[1m])rate(mongodb_driver_commands_seconds_count{command=~"insert|update|delete"}[1m])rate(redis_ops_seconds_count[1m]). Legend:{{cmd}}rate(redis_ops_seconds_sum[1m]) / rate(redis_ops_seconds_count[1m])rate(mongodb_driver_commands_seconds_count[1m]). Legend:{{command}}rate(neo4j_ops_seconds_count[1m]). Legend:{{query}}