46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""
|
|
Correct Grafana queries for the dashboard panels
|
|
"""
|
|
|
|
# Traffic Light Status Panel Query:
|
|
traffic_light_query = '''
|
|
from(bucket: "traffic_monitoring")
|
|
|> range(start: $__timeFrom, stop: $__timeTo)
|
|
|> filter(fn: (r) => r["_measurement"] == "traffic_light_status")
|
|
|> filter(fn: (r) => r["_field"] == "color_numeric")
|
|
|> last()
|
|
'''
|
|
|
|
# Red Light Violations Panel Query:
|
|
violation_query = '''
|
|
from(bucket: "traffic_monitoring")
|
|
|> range(start: $__timeFrom, stop: $__timeTo)
|
|
|> filter(fn: (r) => r["_measurement"] == "violation_events")
|
|
|> filter(fn: (r) => r["_field"] == "count")
|
|
|> count()
|
|
'''
|
|
|
|
# Device Info Panel Query:
|
|
device_query = '''
|
|
from(bucket: "traffic_monitoring")
|
|
|> range(start: $__timeFrom, stop: $__timeTo)
|
|
|> filter(fn: (r) => r["_measurement"] == "device_info")
|
|
|> filter(fn: (r) => r["_field"] == "status")
|
|
|> last()
|
|
'''
|
|
|
|
print("=== Grafana Panel Queries ===")
|
|
print("\n1. Traffic Light Status Panel:")
|
|
print(traffic_light_query)
|
|
print("\n2. Red Light Violations Panel:")
|
|
print(violation_query)
|
|
print("\n3. Device Info Panel:")
|
|
print(device_query)
|
|
|
|
print("\n=== Instructions ===")
|
|
print("1. Go to your Grafana dashboard")
|
|
print("2. Click the gear icon on each panel showing 'No data'")
|
|
print("3. Select 'Edit' from the dropdown")
|
|
print("4. Replace the query with the correct one above")
|
|
print("5. Click 'Apply' to save")
|