WIP: Development changes moved from master
- Modified Grafana dashboards - Updated message sender and metrics collector - Added new rate limiting dashboard - Removed count_tests.py
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -84,7 +84,7 @@
|
||||
"unit": "percent"
|
||||
}
|
||||
},
|
||||
"gridPos": {"h": 8, "w": 6, "x": 12, "y": 0}
|
||||
"gridPos": {"h": 8, "w": 6, "x": 18, "y": 16}
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
@@ -139,7 +139,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 8}
|
||||
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 16}
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
@@ -159,7 +159,7 @@
|
||||
"unit": "s"
|
||||
}
|
||||
},
|
||||
"gridPos": {"h": 8, "w": 6, "x": 12, "y": 8}
|
||||
"gridPos": {"h": 8, "w": 6, "x": 12, "y": 16}
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
@@ -186,7 +186,7 @@
|
||||
"unit": "percent"
|
||||
}
|
||||
},
|
||||
"gridPos": {"h": 8, "w": 6, "x": 0, "y": 16}
|
||||
"gridPos": {"h": 8, "w": 6, "x": 12, "y": 16}
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
@@ -213,7 +213,154 @@
|
||||
"unit": "percent"
|
||||
}
|
||||
},
|
||||
"gridPos": {"h": 8, "w": 6, "x": 6, "y": 16}
|
||||
"gridPos": {"h": 8, "w": 6, "x": 18, "y": 16}
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "CPU Usage Gauge",
|
||||
"type": "gauge",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "cpu_usage_percent",
|
||||
"legendFormat": "CPU %"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "thresholds"
|
||||
},
|
||||
"thresholds": {
|
||||
"steps": [
|
||||
{"color": "green", "value": null},
|
||||
{"color": "yellow", "value": 70},
|
||||
{"color": "red", "value": 90}
|
||||
]
|
||||
},
|
||||
"unit": "percent",
|
||||
"min": 0,
|
||||
"max": 100
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"values": false,
|
||||
"calcs": ["lastNotNull"],
|
||||
"fields": ""
|
||||
},
|
||||
"showThresholdLabels": false,
|
||||
"showThresholdMarkers": true
|
||||
},
|
||||
"gridPos": {"h": 8, "w": 6, "x": 12, "y": 0}
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "RAM Usage Gauge",
|
||||
"type": "gauge",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "ram_usage_percent",
|
||||
"legendFormat": "RAM %"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "thresholds"
|
||||
},
|
||||
"thresholds": {
|
||||
"steps": [
|
||||
{"color": "green", "value": null},
|
||||
{"color": "yellow", "value": 70},
|
||||
{"color": "red", "value": 90}
|
||||
]
|
||||
},
|
||||
"unit": "percent",
|
||||
"min": 0,
|
||||
"max": 100
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"orientation": "auto",
|
||||
"reduceOptions": {
|
||||
"values": false,
|
||||
"calcs": ["lastNotNull"],
|
||||
"fields": ""
|
||||
},
|
||||
"showThresholdLabels": false,
|
||||
"showThresholdMarkers": true
|
||||
},
|
||||
"gridPos": {"h": 8, "w": 6, "x": 18, "y": 0}
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "System Resources Overview",
|
||||
"type": "timeseries",
|
||||
"targets": [
|
||||
{
|
||||
"expr": "cpu_usage_percent",
|
||||
"legendFormat": "CPU %"
|
||||
},
|
||||
{
|
||||
"expr": "ram_usage_percent",
|
||||
"legendFormat": "RAM %"
|
||||
},
|
||||
{
|
||||
"expr": "disk_usage_percent",
|
||||
"legendFormat": "Disk %"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisLabel": "Usage %",
|
||||
"axisPlacement": "left",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 20,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"vis": false
|
||||
},
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 2,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "never",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"unit": "percent",
|
||||
"min": 0,
|
||||
"max": 100
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 8}
|
||||
}
|
||||
],
|
||||
"time": {
|
||||
|
||||
@@ -899,6 +899,190 @@
|
||||
],
|
||||
"title": "Database Query Time (P95)",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "PBFA97CFB590B2093"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 10,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"vis": false
|
||||
},
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "never",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 40
|
||||
},
|
||||
"id": 11,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "PBFA97CFB590B2093"
|
||||
},
|
||||
"expr": "topk(5, sum by(content_type) (rate(media_processing_total[5m])))",
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Top Media Types",
|
||||
"type": "timeseries"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "PBFA97CFB590B2093"
|
||||
},
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"color": {
|
||||
"mode": "palette-classic"
|
||||
},
|
||||
"custom": {
|
||||
"axisLabel": "",
|
||||
"axisPlacement": "auto",
|
||||
"barAlignment": 0,
|
||||
"drawStyle": "line",
|
||||
"fillOpacity": 10,
|
||||
"gradientMode": "none",
|
||||
"hideFrom": {
|
||||
"legend": false,
|
||||
"tooltip": false,
|
||||
"vis": false
|
||||
},
|
||||
"lineInterpolation": "linear",
|
||||
"lineWidth": 1,
|
||||
"pointSize": 5,
|
||||
"scaleDistribution": {
|
||||
"type": "linear"
|
||||
},
|
||||
"showPoints": "never",
|
||||
"spanNulls": false,
|
||||
"stacking": {
|
||||
"group": "A",
|
||||
"mode": "none"
|
||||
},
|
||||
"thresholdsStyle": {
|
||||
"mode": "off"
|
||||
}
|
||||
},
|
||||
"mappings": [],
|
||||
"thresholds": {
|
||||
"mode": "absolute",
|
||||
"steps": [
|
||||
{
|
||||
"color": "green",
|
||||
"value": null
|
||||
},
|
||||
{
|
||||
"color": "red",
|
||||
"value": 80
|
||||
}
|
||||
]
|
||||
},
|
||||
"unit": "bytes"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 40
|
||||
},
|
||||
"id": 12,
|
||||
"options": {
|
||||
"legend": {
|
||||
"calcs": [],
|
||||
"displayMode": "list",
|
||||
"placement": "bottom"
|
||||
},
|
||||
"tooltip": {
|
||||
"mode": "single",
|
||||
"sort": "none"
|
||||
}
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "PBFA97CFB590B2093"
|
||||
},
|
||||
"expr": "histogram_quantile(0.5, rate(file_download_size_bytes_bucket[5m])) by (content_type)",
|
||||
"refId": "A",
|
||||
"legendFormat": "{{content_type}} P50"
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "PBFA97CFB590B2093"
|
||||
},
|
||||
"expr": "histogram_quantile(0.95, rate(file_download_size_bytes_bucket[5m])) by (content_type)",
|
||||
"refId": "B",
|
||||
"legendFormat": "{{content_type}} P95"
|
||||
}
|
||||
],
|
||||
"title": "File Download Size Distribution",
|
||||
"type": "timeseries"
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
|
||||
@@ -74,7 +74,6 @@ class MessageSender:
|
||||
|
||||
if self.last_status_time is None:
|
||||
logger.info(f"should_send_status: last_status_time is None, отправляем статус")
|
||||
self.last_status_time = now
|
||||
return True
|
||||
|
||||
# Вычисляем разницу в минутах
|
||||
@@ -84,7 +83,6 @@ class MessageSender:
|
||||
# Проверяем, что прошло N минут с последней отправки
|
||||
if time_diff_minutes >= self.status_update_interval_minutes:
|
||||
logger.info(f"should_send_status: отправляем статус (прошло {time_diff_minutes:.1f} минут)")
|
||||
self.last_status_time = now
|
||||
return True
|
||||
|
||||
logger.info(f"should_send_status: статус не отправляем (прошло {time_diff_minutes:.1f} минут)")
|
||||
@@ -92,7 +90,12 @@ class MessageSender:
|
||||
|
||||
def should_send_startup_status(self) -> bool:
|
||||
"""Проверка, нужно ли отправить статус при запуске"""
|
||||
return self.last_status_time is None
|
||||
# Отправляем статус при запуске только если он еще не был отправлен
|
||||
if self.last_status_time is None:
|
||||
logger.info("should_send_startup_status: отправляем статус при запуске")
|
||||
return True
|
||||
logger.info("should_send_startup_status: статус уже был отправлен, пропускаем")
|
||||
return False
|
||||
|
||||
def _get_disk_space_emoji(self, disk_percent: float) -> str:
|
||||
"""Получение эмодзи для дискового пространства"""
|
||||
@@ -257,7 +260,14 @@ Read: <b>{system_info['disk_read_speed']}</b> | Write: <b>{system_info['disk_wri
|
||||
return False
|
||||
|
||||
status_message = self.get_status_message(system_info)
|
||||
return await self.send_telegram_message(self.group_for_logs, status_message)
|
||||
success = await self.send_telegram_message(self.group_for_logs, status_message)
|
||||
|
||||
# Обновляем время последней отправки только при успешной отправке
|
||||
if success:
|
||||
self.last_status_time = datetime.now()
|
||||
logger.info("send_status_message: время последней отправки обновлено")
|
||||
|
||||
return success
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Ошибка при отправке статуса: {e}")
|
||||
|
||||
Reference in New Issue
Block a user