Fix and complete Uptime Kuma monitor tagging
Successfully tagged all 12 monitors with service categories: - Used add_monitor_tag API method instead of edit_monitor - All hardware/monitoring, application, and infrastructure monitors now tagged - Added verification and fix scripts for debugging New files: - check_tags.py: Verify tag assignments - fix_missing_tags.py: Add specific missing tags - test_single_tag.py: Debug single monitor tagging - TAG_SUMMARY.md: Complete documentation of all tags and assignments All monitors are now properly organized by service category.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
# Uptime Kuma Monitor Tags Summary
|
||||
|
||||
## All Tags Created
|
||||
|
||||
| Tag ID | Tag Name | Color | Category |
|
||||
|--------|----------|-------|----------|
|
||||
| 1 | hardware | 🔴 Red | Physical hardware monitoring |
|
||||
| 2 | monitoring | 🟠 Orange | Monitoring systems |
|
||||
| 3 | application | 🔵 Blue | Software applications |
|
||||
| 4 | web | 🔷 Cyan | Web services |
|
||||
| 5 | database | 🟣 Purple | Database systems |
|
||||
| 6 | media | 🌸 Pink | Media servers |
|
||||
| 7 | infrastructure | 🟢 Green | Core infrastructure |
|
||||
| 8 | storage | 🟢 Light Green | Storage systems |
|
||||
| 9 | virtualization | 🟦 Teal | Virtualization platforms |
|
||||
| 10 | vm | 🔹 Blue Grey | Virtual machines |
|
||||
|
||||
## Monitor Tag Assignments
|
||||
|
||||
### Hardware/Monitoring (4 monitors)
|
||||
| ID | Monitor Name | Tags |
|
||||
|----|--------------|------|
|
||||
| 1 | Server Fan Online | `hardware` `monitoring` |
|
||||
| 2 | Server Front Fan Stalled | `hardware` `monitoring` |
|
||||
| 3 | Server Back Fan Stalled | `hardware` `monitoring` |
|
||||
| 4 | Server Fan | `hardware` `monitoring` |
|
||||
|
||||
### Applications (3 monitors)
|
||||
| ID | Monitor Name | Tags |
|
||||
|----|--------------|------|
|
||||
| 5 | TSA Chapter Organizer RMS | `application` `web` |
|
||||
| 6 | couchdb | `application` `database` |
|
||||
| 7 | Plex | `application` `media` |
|
||||
|
||||
### Infrastructure (5 monitors)
|
||||
| ID | Monitor Name | Tags |
|
||||
|----|--------------|------|
|
||||
| 8 | unraid | `infrastructure` `storage` |
|
||||
| 10 | pallas VM | `infrastructure` `vm` |
|
||||
| 11 | NAS | `infrastructure` `storage` |
|
||||
| 13 | Proxmox | `infrastructure` `virtualization` |
|
||||
| 14 | dev-win10 VM | `infrastructure` `vm` |
|
||||
|
||||
## Using Tags in Uptime Kuma
|
||||
|
||||
1. **Filter by Tag**: In the web UI, click on a tag to filter monitors
|
||||
2. **View All Tags**: Navigate to Settings → Tags to manage
|
||||
3. **Add/Edit Tags**: Click on a monitor → Edit → Tags section
|
||||
4. **Status Pages**: Create status pages filtered by specific tags
|
||||
|
||||
## Scripts Available
|
||||
|
||||
- `add_tags.py` - Create tags and assign them to monitors
|
||||
- `check_tags.py` - Verify current tag assignments
|
||||
- `fix_missing_tags.py` - Add missing tags to specific monitors
|
||||
|
||||
## Web UI
|
||||
|
||||
Access Uptime Kuma at: https://uptime.kolpacksoftware.com
|
||||
|
||||
All tags are now visible and active in the web interface!
|
||||
+10
-17
@@ -85,27 +85,20 @@ def ensure_tags_exist(api):
|
||||
return tag_map
|
||||
|
||||
def add_tags_to_monitor(api, monitor_id, tag_names, tag_map):
|
||||
"""Add tags to a monitor"""
|
||||
# Get monitor details
|
||||
"""Add tags to a monitor using add_monitor_tag method"""
|
||||
# Get monitor details for name
|
||||
monitor = api.get_monitor(monitor_id)
|
||||
|
||||
# Build tag list
|
||||
tag_ids = []
|
||||
# Add each tag using the dedicated method
|
||||
for tag_name in tag_names:
|
||||
if tag_name in tag_map:
|
||||
tag_ids.append({'tag_id': tag_map[tag_name], 'value': ''})
|
||||
|
||||
# Preserve existing tags and add new ones
|
||||
existing_tag_ids = monitor.get('tags', [])
|
||||
existing_tag_id_set = {tag['tag_id'] for tag in existing_tag_ids}
|
||||
|
||||
for tag_info in tag_ids:
|
||||
if tag_info['tag_id'] not in existing_tag_id_set:
|
||||
existing_tag_ids.append(tag_info)
|
||||
|
||||
# Update monitor with tags
|
||||
monitor['tags'] = existing_tag_ids
|
||||
api.edit_monitor(monitor_id, **monitor)
|
||||
tag_id = tag_map[tag_name]
|
||||
try:
|
||||
api.add_monitor_tag(tag_id=tag_id, monitor_id=monitor_id, value='')
|
||||
except Exception as e:
|
||||
# Tag might already be assigned, that's okay
|
||||
if 'already exists' not in str(e).lower():
|
||||
raise
|
||||
|
||||
print(f" ✓ Monitor {monitor_id} ({monitor['name']}): Added tags {tag_names}")
|
||||
|
||||
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Check current tag assignments on monitors
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from uptime_kuma_api import UptimeKumaApi
|
||||
|
||||
UPTIME_KUMA_URL = "https://uptime.kolpacksoftware.com"
|
||||
USERNAME = os.getenv('UPTIME_KUMA_USERNAME')
|
||||
PASSWORD = os.getenv('UPTIME_KUMA_PASSWORD')
|
||||
|
||||
def connect():
|
||||
api = UptimeKumaApi(UPTIME_KUMA_URL, ssl_verify=False)
|
||||
if USERNAME and PASSWORD:
|
||||
api.login(USERNAME, PASSWORD)
|
||||
else:
|
||||
print("Error: Set UPTIME_KUMA_USERNAME and UPTIME_KUMA_PASSWORD")
|
||||
sys.exit(1)
|
||||
return api
|
||||
|
||||
def main():
|
||||
api = connect()
|
||||
|
||||
try:
|
||||
monitors = api.get_monitors()
|
||||
|
||||
print("Current Monitor Tags:\n")
|
||||
for monitor in monitors:
|
||||
tags = monitor.get('tags', [])
|
||||
tag_names = [f"ID:{tag.get('tag_id', tag.get('id'))}" for tag in tags] if tags else ['No tags']
|
||||
print(f"Monitor {monitor['id']} ({monitor['name']}): {', '.join(tag_names)}")
|
||||
|
||||
print("\n\nAvailable Tags:\n")
|
||||
all_tags = api.get_tags()
|
||||
for tag in all_tags:
|
||||
tag_id = tag.get('tag_id') or tag.get('id')
|
||||
print(f" ID {tag_id}: {tag['name']} ({tag.get('color', 'no color')})")
|
||||
|
||||
finally:
|
||||
api.disconnect()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fix missing tags on specific monitors"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from uptime_kuma_api import UptimeKumaApi
|
||||
|
||||
UPTIME_KUMA_URL = "https://uptime.kolpacksoftware.com"
|
||||
USERNAME = os.getenv('UPTIME_KUMA_USERNAME')
|
||||
PASSWORD = os.getenv('UPTIME_KUMA_PASSWORD')
|
||||
|
||||
# Missing tags to add
|
||||
MISSING_TAGS = {
|
||||
1: [2], # Server Fan Online: add monitoring
|
||||
2: [2], # Server Front Fan Stalled: add monitoring
|
||||
11: [7, 8], # NAS: add infrastructure, storage
|
||||
14: [7, 10], # dev-win10 VM: add infrastructure, vm
|
||||
}
|
||||
|
||||
def connect():
|
||||
api = UptimeKumaApi(UPTIME_KUMA_URL, ssl_verify=False)
|
||||
if USERNAME and PASSWORD:
|
||||
api.login(USERNAME, PASSWORD)
|
||||
else:
|
||||
print("Error: Set credentials")
|
||||
sys.exit(1)
|
||||
return api
|
||||
|
||||
def main():
|
||||
api = connect()
|
||||
|
||||
try:
|
||||
print("Adding missing tags...\n")
|
||||
|
||||
for monitor_id, tag_ids in MISSING_TAGS.items():
|
||||
monitor = api.get_monitor(monitor_id)
|
||||
print(f"Monitor {monitor_id} ({monitor['name']}):")
|
||||
|
||||
for tag_id in tag_ids:
|
||||
try:
|
||||
api.add_monitor_tag(tag_id=tag_id, monitor_id=monitor_id, value='')
|
||||
print(f" ✓ Added tag ID {tag_id}")
|
||||
except Exception as e:
|
||||
if 'already' in str(e).lower():
|
||||
print(f" - Tag ID {tag_id} already exists")
|
||||
else:
|
||||
print(f" ✗ Failed to add tag ID {tag_id}: {e}")
|
||||
|
||||
print("\n✅ Complete!")
|
||||
|
||||
finally:
|
||||
api.disconnect()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test tagging a single monitor to debug the issue
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
from uptime_kuma_api import UptimeKumaApi
|
||||
|
||||
UPTIME_KUMA_URL = "https://uptime.kolpacksoftware.com"
|
||||
USERNAME = os.getenv('UPTIME_KUMA_USERNAME')
|
||||
PASSWORD = os.getenv('UPTIME_KUMA_PASSWORD')
|
||||
|
||||
def connect():
|
||||
api = UptimeKumaApi(UPTIME_KUMA_URL, ssl_verify=False)
|
||||
if USERNAME and PASSWORD:
|
||||
api.login(USERNAME, PASSWORD)
|
||||
else:
|
||||
print("Error: Set credentials")
|
||||
sys.exit(1)
|
||||
return api
|
||||
|
||||
def main():
|
||||
api = connect()
|
||||
|
||||
try:
|
||||
# Test with monitor 1
|
||||
monitor_id = 1
|
||||
print(f"Testing with monitor {monitor_id}...")
|
||||
|
||||
# Get current monitor data
|
||||
monitor = api.get_monitor(monitor_id)
|
||||
print(f"\nCurrent monitor data keys: {list(monitor.keys())}")
|
||||
print(f"Current tags: {monitor.get('tags', [])}")
|
||||
|
||||
# Try to add tags - method 1: using tag list
|
||||
print("\n--- Attempting to add tags ---")
|
||||
monitor['tags'] = [
|
||||
{'tag_id': 1, 'value': ''}, # hardware
|
||||
{'tag_id': 2, 'value': ''} # monitoring
|
||||
]
|
||||
|
||||
print(f"Tags to add: {monitor['tags']}")
|
||||
|
||||
# Update the monitor
|
||||
result = api.edit_monitor(monitor_id, **monitor)
|
||||
print(f"Edit result: {result}")
|
||||
|
||||
# Verify
|
||||
updated_monitor = api.get_monitor(monitor_id)
|
||||
print(f"\nAfter update, tags: {updated_monitor.get('tags', [])}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
finally:
|
||||
api.disconnect()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user