Skip to content

Commit 525fbcf

Browse files
author
David Linko
committed
updated grafana to use new rptsets
1 parent 7d82f6a commit 525fbcf

File tree

4 files changed

+87
-69
lines changed

4 files changed

+87
-69
lines changed

anms-core/anms/routes/ARIs/reports.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,18 @@ async def reports_dictionary_by_name_and_report_source(agent_eid: str, source_cb
227227
async def reports_dictionary_by_search_idx(agent_idxs: list[int], source_cbors: list, start_time: datetime=None, end_time: datetime=None):
228228
reports = []
229229
for agent_idx in agent_idxs:
230+
rpt_cur = []
230231
for source_cbor in source_cbors:
231-
reports.append(await _report_from_id_source(agent_idx, source_cbor, start_time, end_time))
232-
232+
rpt_cur.append(await _report_from_id_source(agent_idx, source_cbor, start_time, end_time))
233+
reports.append({"agent": agent_idx, "reports": rpt_cur} )
233234
return reports
234235

235236
@router.post("/dictionary/search/eid/", status_code=status.HTTP_200_OK, response_model=list,
236237
tags=["REPORTS"])
237238
async def reports_dictionary_by_search_eid(agent_eids: list[str], source_cbors: list, start_time: datetime=None, end_time: datetime=None):
238-
reports = []
239+
reports = []
239240
for agent_eid in agent_eids:
241+
rpt_cur = []
240242
agent_idx = None
241243
agent_id_stmt = select(RegisteredAgent).where(RegisteredAgent.agent_endpoint_uri == unquote(agent_eid))
242244
async with get_async_session() as session:
@@ -246,6 +248,6 @@ async def reports_dictionary_by_search_eid(agent_eids: list[str], source_cbors:
246248
if(agent_idx):
247249
agent_idx = agent_idx.registered_agents_id
248250
for source_cbor in source_cbors:
249-
reports.append(await _report_from_id_source(agent_idx, source_cbor, start_time, end_time))
250-
251+
rpt_cur.append(await _report_from_id_source(agent_idx, source_cbor, start_time, end_time))
252+
reports.append({"agent": agent_eid, "reports":rpt_cur} )
251253
return reports

anms-core/anms/routes/transcoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ async def transcoder_put_await_str(input_ari: str):
143143
def transcoder_incoming_str(input_ari: str):
144144
return _transcoder_put_str(input_ari)
145145

146-
def transcoder_put_str(input_ari: str):
146+
def _transcoder_put_str(input_ari: str):
147147
input_ari = input_ari.strip()
148148
transcoder_log_id = None
149149
send_to_transcode = False

grafana/provisioning/dashboards/anms-monitor.json

Lines changed: 77 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"editable": true,
2525
"fiscalYearStartMonth": 0,
2626
"graphTooltip": 0,
27-
"id": 1,
27+
"id": 0,
2828
"links": [],
2929
"panels": [
3030
{
@@ -117,11 +117,12 @@
117117
"type": "postgres",
118118
"uid": "amp_core"
119119
},
120+
"editorMode": "code",
120121
"format": "time_series",
121122
"group": [],
122123
"metricColumn": "none",
123124
"rawQuery": true,
124-
"rawSql": "SELECT\n $__timeGroup(reference_time::timestamp,'1m') as time,\n count(report_list) as value,\n agent_endpoint_uri AS metric\nFROM ari_rptset join registered_agents on ari_rptset.agent_id = registered_agents.registered_agents_id\ngroup by 1, agent_endpoint_uri\norder by time asc",
125+
"rawSql": "SELECT\n $__timeGroup(reference_time::timestamp,'1m') as time,\n count(report_items) as value,\n agent_endpoint_uri AS metric\nFROM vw_ari_rpt_set join registered_agents on vw_ari_rpt_set.agent_id = registered_agents.registered_agents_id\ngroup by 1, agent_endpoint_uri\norder by time asc",
125126
"refId": "A",
126127
"select": [
127128
[
@@ -133,6 +134,23 @@
133134
}
134135
]
135136
],
137+
"sql": {
138+
"columns": [
139+
{
140+
"parameters": [],
141+
"type": "function"
142+
}
143+
],
144+
"groupBy": [
145+
{
146+
"property": {
147+
"type": "string"
148+
},
149+
"type": "groupBy"
150+
}
151+
],
152+
"limit": 50
153+
},
136154
"timeColumn": "time",
137155
"where": [
138156
{
@@ -458,11 +476,12 @@
458476
"type": "postgres",
459477
"uid": "amp_core"
460478
},
479+
"editorMode": "code",
461480
"format": "table",
462481
"group": [],
463482
"metricColumn": "none",
464483
"rawQuery": true,
465-
"rawSql": "-- all reports \nSELECT \n reference_time,\n agent_id, \n report_list\nFROM\n ari_rptset",
484+
"rawSql": "-- all reports \nSELECT \n reference_time,\n mgr_time,\n agent_id, \n encode(time_offset,'hex') as time_offset,\n encode(report_source,'hex') as report_source,\n report_items\nFROM\n vw_ari_rpt_set",
466485
"refId": "A",
467486
"select": [
468487
[
@@ -474,6 +493,23 @@
474493
}
475494
]
476495
],
496+
"sql": {
497+
"columns": [
498+
{
499+
"parameters": [],
500+
"type": "function"
501+
}
502+
],
503+
"groupBy": [
504+
{
505+
"property": {
506+
"type": "string"
507+
},
508+
"type": "groupBy"
509+
}
510+
],
511+
"limit": 50
512+
},
477513
"timeColumn": "time",
478514
"where": [
479515
{
@@ -574,16 +610,15 @@
574610
},
575611
{
576612
"datasource": {
577-
"type": "yesoreyeram-infinity-datasource",
578-
"uid": "PA0935669E4DE7FB6"
613+
"uid": "P1671BF01EA0D6F15"
579614
},
580615
"fieldConfig": {
581616
"defaults": {
582617
"color": {
583618
"mode": "palette-classic"
584619
},
585620
"custom": {
586-
"axisBorderShow": false,
621+
"axisBorderShow": true,
587622
"axisCenteredZero": false,
588623
"axisColorMode": "text",
589624
"axisLabel": "",
@@ -601,12 +636,12 @@
601636
"insertNulls": false,
602637
"lineInterpolation": "smooth",
603638
"lineWidth": 1,
604-
"pointSize": 5,
639+
"pointSize": 3,
605640
"scaleDistribution": {
606641
"type": "linear"
607642
},
608643
"showPoints": "auto",
609-
"showValues": false,
644+
"showValues": true,
610645
"spanNulls": false,
611646
"stacking": {
612647
"group": "A",
@@ -616,6 +651,7 @@
616651
"mode": "off"
617652
}
618653
},
654+
"fieldMinMax": true,
619655
"mappings": [],
620656
"thresholds": {
621657
"mode": "absolute",
@@ -642,10 +678,15 @@
642678
"id": 74,
643679
"options": {
644680
"legend": {
645-
"calcs": [],
681+
"calcs": [
682+
"lastNotNull",
683+
"max"
684+
],
646685
"displayMode": "table",
647686
"placement": "right",
648-
"showLegend": true
687+
"showLegend": true,
688+
"sortBy": "First *",
689+
"sortDesc": false
649690
},
650691
"tooltip": {
651692
"hideZeros": false,
@@ -657,55 +698,40 @@
657698
"targets": [
658699
{
659700
"columns": [],
660-
"datasource": {
661-
"type": "yesoreyeram-infinity-datasource",
662-
"uid": "PA0935669E4DE7FB6"
663-
},
701+
"computed_columns": [],
664702
"filters": [],
665703
"format": "table",
666704
"global_query_id": "",
667705
"parser": "backend",
668706
"refId": "A",
669-
"root_selector": "",
707+
"root_selector": "$map(reports, function($v) {\n $v.nestedArray.{\n \"value\": \"col 0\"\n }\n})\n",
670708
"source": "url",
671709
"type": "uql",
672-
"uql": "parse-json\n | scope \"b'\\\\x18{'\"\n | extend \"num_msg_rx\"=\"ari://ietf/dtnma-agent/CTRL/inspect(//ietf/dtnma-agent/EDD/num-msg-rx).0\"\n | extend \"num_msg_rx\"=split(\"num_msg_rx\",'/')\n | extend \"num_msg_rx\"=\"num_msg_rx.2\"\n | extend \"ipn_3_6\"=tonumber(\"num_msg_rx\")\n | extend \"time\"=todatetime(\"time\")\n | project \"time\", \"ipn_3_6\"\n ",
673-
"url": "1/b%27%5Cx18%7B%27",
710+
"uql": "parse-json\n| mv-expand \"reports\"\n| mv-expand \"reports\"\n| extend \"reference_time\"=todatetime(\"reports.reference_time\")\n| extend \"num_msg_rx\"=\"reports.col 0\"\n| extend \"parts\"=split(\"num_msg_rx\",'/')\n| extend \"parts\"=\"parts[2]\"\n| extend \"num_msg_rx\"=toint(\"parts\") \n| extend \"time\"=\"reference_time\"\n| extend \"value\"=\"num_msg_rx\"\n| extend \"metric\"=\"agent\"\n| project \"time\", \"value\", \"agent\"\n\n\n\n\n\n",
711+
"url": "report/dictionary/search/eid/",
674712
"url_options": {
675-
"data": "",
676-
"method": "GET"
713+
"body_content_type": "application/json",
714+
"body_type": "raw",
715+
"data": "{\n \"agent_eids\": [\n \"ipn:2.6\",\"ipn:3.6\"\n ],\n \"source_cbors\": [\n \"8564696574666b64746e6d612d6167656e742267696e7370656374818464696574666b64746e6d612d6167656e74236a6e756d2d6d73672d7278\"\n ]\n}",
716+
"method": "POST"
677717
}
678-
},
718+
}
719+
],
720+
"title": "ari://ietf/dtnma-agent/CTRL/inspect(//ietf/dtnma-agent/EDD/num-msg-rx)",
721+
"transformations": [
679722
{
680-
"columns": [],
681-
"datasource": {
682-
"type": "yesoreyeram-infinity-datasource",
683-
"uid": "PA0935669E4DE7FB6"
684-
},
685-
"filters": [],
686-
"format": "table",
687-
"global_query_id": "",
688-
"hide": false,
689-
"parser": "backend",
690-
"refId": "B",
691-
"root_selector": "",
692-
"source": "url",
693-
"type": "uql",
694-
"uql": "parse-json\n | scope \"b'\\\\x18{'\"\n | extend \"num_msg_rx\"=\"ari://ietf/dtnma-agent/CTRL/inspect(//ietf/dtnma-agent/EDD/num-msg-rx).0\"\n | extend \"num_msg_rx\"=split(\"num_msg_rx\",'/')\n | extend \"num_msg_rx\"=\"num_msg_rx.2\"\n | extend \"ipn_2_6\"=tonumber(\"num_msg_rx\")\n | extend \"time\"=todatetime(\"time\")\n | project \"time\", \"ipn_2_6\"\n ",
695-
"url": "2/b%27%5Cx18%7B%27",
696-
"url_options": {
697-
"data": "",
698-
"method": "GET"
723+
"id": "prepareTimeSeries",
724+
"options": {
725+
"format": "multi"
699726
}
700727
}
701728
],
702-
"title": "ari://ietf/dtnma-agent/CTRL/inspect(//ietf/dtnma-agent/EDD/num-msg-rx)",
703729
"type": "timeseries"
704730
},
705731
{
706732
"datasource": {
707733
"type": "yesoreyeram-infinity-datasource",
708-
"uid": "PA0935669E4DE7FB6"
734+
"uid": "P1671BF01EA0D6F15"
709735
},
710736
"fieldConfig": {
711737
"defaults": {
@@ -720,9 +746,6 @@
720746
"footer": {
721747
"reducers": []
722748
},
723-
"hideFrom": {
724-
"viz": false
725-
},
726749
"inspect": false
727750
},
728751
"mappings": [],
@@ -760,32 +783,25 @@
760783
"columns": [],
761784
"datasource": {
762785
"type": "yesoreyeram-infinity-datasource",
763-
"uid": "PA0935669E4DE7FB6"
786+
"uid": "P1671BF01EA0D6F15"
764787
},
765788
"filters": [],
766-
"format": "table",
789+
"format": "logs",
767790
"global_query_id": "",
768791
"parser": "backend",
769792
"refId": "A",
770793
"root_selector": "",
771794
"source": "url",
772795
"type": "uql",
773-
"uql": " parse-json\n | scope \"ari://ietf/dtnma-agent/CONST/hello\"\n | extend \"hello\"=array_to_map(\"ari://ietf/dtnma-agent/CONST/hello\",'sw_vendor','sw_version', 'capabilities')\n | extend \"time\"=todatetime(\"time\")\n | project \"time\", \"sw_vendor\"=\"hello.sw_vendor\", \"sw_version\"=\"hello.sw_version\", \"capabilities\"=\"hello.capabilities\"\n | order by \"time\" desc\n",
774-
"url": "http://anms-core:5555/report/entries/table/1/b%27%5Cxf6%27",
796+
"uql": " parse-json\n ",
797+
"url": "report/dictionary/eid/ipn%3A3.6/8401012100",
775798
"url_options": {
799+
"body_content_type": "text/plain",
800+
"body_type": "raw",
776801
"data": "",
777802
"headers": [],
778803
"method": "GET",
779-
"params": [
780-
{
781-
"key": "agent_id",
782-
"value": "1"
783-
},
784-
{
785-
"key": "nonce_cbor",
786-
"value": "b%27%5Cxf6%27"
787-
}
788-
]
804+
"params": []
789805
}
790806
}
791807
],
@@ -801,12 +817,12 @@
801817
"list": []
802818
},
803819
"time": {
804-
"from": "now-6h",
820+
"from": "now-24h",
805821
"to": "now"
806822
},
807823
"timepicker": {},
808824
"timezone": "",
809825
"title": "Monitor Page",
810-
"uid": "mwvijjmvk",
811-
"version": 5
826+
"uid": "mwvijjmvk2",
827+
"version": 8
812828
}

grafana/provisioning/datasources/datasource.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ datasources:
4040
editable: true
4141
isDefault: true
4242

43-
- name: report_entries_table_endpoint
43+
- name: anms-core
4444
type: yesoreyeram-infinity-datasource
4545
typeName: Infinity
4646
access: proxy
47-
url: http://anms-core:5555/report/entries/table/
47+
url: http://anms-core:5555/
4848
user:
4949
database:
5050
basicAuth: false

0 commit comments

Comments
 (0)