Skip to content

Commit 764778e

Browse files
authored
Add Prometheus metrics support and update configuration (#46)
- Introduced a new metrics service for Prometheus integration, including counters and histograms for tracking tool executions, HTTP requests, and errors. - Updated the logger to record metrics for tool access, including execution duration and success/error status. - Added configuration options for enabling metrics in the YAML configuration file. - Enhanced the README with instructions on enabling and accessing Prometheus metrics. - Updated the main application to conditionally expose a metrics endpoint based on configuration.
1 parent fe2ad8a commit 764778e

File tree

7 files changed

+767
-328
lines changed

7 files changed

+767
-328
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,36 @@ The service generates tools from AAP OpenAPI specifications for:
254254

255255
Tool availability depends on your configured categories and user permissions. When the web UI is enabled, you can browse available tools at `http://localhost:3000/tools`.
256256

257+
## Prometheus Metrics
258+
259+
The service includes comprehensive Prometheus metrics for monitoring and observability. Enable metrics in your configuration:
260+
261+
```yaml
262+
# In aap-mcp.yaml
263+
enable_metrics: true
264+
```
265+
266+
Or via environment variable:
267+
268+
```bash
269+
export ENABLE_METRICS=true
270+
```
271+
272+
### Metrics Endpoint
273+
274+
When enabled, Prometheus metrics are available at:
275+
276+
```
277+
http://localhost:3000/metrics
278+
```
279+
280+
### Available Metrics
281+
282+
- **HTTP Metrics**: Request counts, duration, and status codes
283+
- **MCP Tool Metrics**: Tool execution counts, duration, success/failure rates
284+
- **System Metrics**: CPU, memory, garbage collection, event loop lag
285+
- **API Call Metrics**: AAP API calls by service, endpoint, and method
286+
257287
## Development
258288

259289
### Key Features
@@ -265,6 +295,7 @@ Tool availability depends on your configured categories and user permissions. Wh
265295
- **Role-based Access Control**: Custom categories and permission-based tool filtering
266296
- **Session Management**: Token validation and user permission detection
267297
- **API Query Logging**: Optional logging of all tool usage
298+
- **Prometheus Metrics**: Comprehensive metrics for monitoring and observability
268299
- **Health Monitoring**: Built-in health check endpoint for container orchestration
269300

270301
### Configuration Design

aap-mcp.sample.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
# Configuration for Web UI (defaults to false if not specified)
99
# enable_ui: false
1010

11+
# Configuration for Prometheus metrics endpoint (defaults to false if not specified)
12+
# enable_metrics: true
13+
1114
# Configuration for base URL (defaults to https://localhost if not specified)
1215
# Lower priority than BASE_URL environment variable
1316
# base_url: "https://localhost:8443"

0 commit comments

Comments
 (0)