-
Notifications
You must be signed in to change notification settings - Fork 802
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simple prometheus metrics collection, with a prometheus / grafana…
… instance for live dashboard. related: #22
- Loading branch information
1 parent
2e419ba
commit 4e46232
Showing
7 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: '3.8' | ||
|
||
services: | ||
prometheus: | ||
image: prom/prometheus:latest | ||
container_name: prometheus | ||
volumes: | ||
- ./prometheus.yml:/etc/prometheus/prometheus.yml | ||
command: | ||
- '--config.file=/etc/prometheus/prometheus.yml' | ||
ports: | ||
- "9090:9090" | ||
networks: | ||
- monitoring | ||
|
||
grafana: | ||
image: grafana/grafana:latest | ||
container_name: grafana | ||
ports: | ||
- "3000:3000" | ||
networks: | ||
- monitoring | ||
depends_on: | ||
- prometheus | ||
|
||
networks: | ||
monitoring: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from exo.orchestration import Node | ||
from prometheus_client import start_http_server, Counter, Histogram | ||
import json | ||
from typing import List | ||
|
||
# Create metrics to track time spent and requests made. | ||
PROCESS_PROMPT_COUNTER = Counter('process_prompt_total', 'Total number of prompts processed', ['node_id']) | ||
PROCESS_TENSOR_COUNTER = Counter('process_tensor_total', 'Total number of tensors processed', ['node_id']) | ||
PROCESS_TENSOR_TIME = Histogram('process_tensor_seconds', 'Time spent processing tensor', ['node_id']) | ||
|
||
def start_metrics_server(node: Node, port: int): | ||
start_http_server(port) | ||
|
||
def _on_opaque_status(request_id, opaque_status: str): | ||
status_data = json.loads(opaque_status) | ||
type = status_data.get("type", "") | ||
node_id = status_data.get("node_id", "") | ||
if type != "node_status": return | ||
status = status_data.get("status", "") | ||
|
||
if status == "end_process_prompt": | ||
PROCESS_PROMPT_COUNTER.labels(node_id=node_id).inc() | ||
elif status == "end_process_tensor": | ||
elapsed_time_ns = status_data.get("elapsed_time_ns", 0) | ||
PROCESS_TENSOR_COUNTER.labels(node_id=node_id).inc() | ||
PROCESS_TENSOR_TIME.labels(node_id=node_id).observe(elapsed_time_ns / 1e9) # Convert ns to seconds | ||
|
||
node.on_opaque_status.register("stats").on_next(_on_opaque_status) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
global: | ||
scrape_interval: 15s | ||
|
||
scrape_configs: | ||
- job_name: 'exo-node' | ||
static_configs: | ||
- targets: ['host.docker.internal:8005'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters