This is an automated email from the ASF dual-hosted git repository.

lahirujayathilake pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git

commit 6e909690434fe028ad90c31d8ea490b3649022ba
Author: lahiruj <[email protected]>
AuthorDate: Mon May 4 23:47:19 2026 -0400

    updated the grafana dashboards to retrieve data from db too
---
 allocations/access-amie/amieclient/client.go |   4 +-
 allocations/devtools/amie/README.md          |  54 +++++++++-----
 allocations/devtools/amie/amie-traffic.js    |   2 +-
 compose/grafana/dashboards/amie-service.json | 101 +++++++++++++++++++--------
 4 files changed, 113 insertions(+), 48 deletions(-)

diff --git a/allocations/access-amie/amieclient/client.go 
b/allocations/access-amie/amieclient/client.go
index 034fe7a13..17d9938bb 100644
--- a/allocations/access-amie/amieclient/client.go
+++ b/allocations/access-amie/amieclient/client.go
@@ -125,12 +125,12 @@ func parsePacketsFromResponse(body []byte) 
([]map[string]any, error) {
                return packets, nil
        }
 
-       // "result" is a single value -- wrap it if it is a map.
+       // "result" is a single value - wrap it if it is a map.
        if m, ok := result.(map[string]any); ok {
                return []map[string]any{m}, nil
        }
 
-       // Scalar or unrecognised "result" -- return the envelope itself.
+       // Scalar or unrecognized "result" - return the envelope itself.
        return []map[string]any{obj}, nil
 }
 
diff --git a/allocations/devtools/amie/README.md 
b/allocations/devtools/amie/README.md
index ae87d4aaf..9c61c89d1 100644
--- a/allocations/devtools/amie/README.md
+++ b/allocations/devtools/amie/README.md
@@ -1,25 +1,47 @@
-# AMIE Traffic Simulation
+# AMIE Traffic Tools
 
-k6 load test that generates AMIE test scenarios at varying rates to simulate 
real-world traffic patterns.
+Two scripts you can use together or on their own:
 
-## Prerequisites
+- **`mock-amie-server.py`** — a local AMIE server to generate different packet 
types (valid, invalid, or a mix).
+- **`amie-traffic.js`** — a k6 load test. Use this when you want continuous 
traffic at varying rates, either against the local server or with the AMIE test 
endpoint.
+
+## Mock server (different packet types)
+
+Start it:
 
 ```bash
-# macOS
-brew install k6
+python3 mock-amie-server.py
+```
+
+```bash
+# mix of success and failure packets
+curl -X POST 'http://localhost:8180/test/TESTSITE/scenarios?type=mixed'
+
+# only success packets
+curl -X POST 'http://localhost:8180/test/TESTSITE/scenarios?type=success_only'
+
+# only failure packets
+curl -X POST 'http://localhost:8180/test/TESTSITE/scenarios?type=failures_only'
+
+# heavy batch
+curl -X POST 'http://localhost:8180/test/TESTSITE/scenarios?type=heavy'
 ```
 
-## Usage
+Point `access-amie` at it with `AMIE_BASE_URL=http://localhost:8180`.
+
+## Load test (k6)
+
+Install k6, then run it. If you're hitting the local server, start that one 
first:
 
 ```bash
-# Basic run (resets test server automatically)
-AMIE_API_KEY=<your-key> k6 run amie-traffic.js
+# macOS
+brew install k6
 
-# With Prometheus metrics export
-AMIE_API_KEY=<key> k6 run --out 
experimental-prometheus-rw=http://localhost:9090/api/v1/write amie-traffic.js
+# Against the local server
+AMIE_BASE_URL=http://localhost:8180 AMIE_API_KEY=dev AMIE_SITE=TESTSITE k6 run 
amie-traffic.js
 
-# Override AMIE endpoint
-AMIE_BASE_URL=https://custom-endpoint AMIE_SITE=MySite AMIE_API_KEY=<key> k6 
run amie-traffic.js
+# Against the AMIE test endpoint
+AMIE_API_KEY=<your-key> AMIE_SITE=<your-site> k6 run amie-traffic.js
 ```
 
 ## Traffic Profile (~20 minutes)
@@ -36,8 +58,8 @@ VUs
 
 ## Environment Variables
 
-| Variable | Default | Description |
-|----------|---------|-------------|
-| `AMIE_API_KEY` | (required) | AMIE API authentication key |
+| Variable | Default                                  | Description |
+|----------|------------------------------------------|-------------|
+| `AMIE_API_KEY` | (required)                               | AMIE API 
authentication key |
 | `AMIE_BASE_URL` | `https://a3mdev.xsede.org/amie-api-test` | AMIE test API 
base URL |
-| `AMIE_SITE` | `GaTech` | Site code for AMIE |
+| `AMIE_SITE` | `TESTSITE`                               | Site code for AMIE |
diff --git a/allocations/devtools/amie/amie-traffic.js 
b/allocations/devtools/amie/amie-traffic.js
index 68226d283..9b01276ec 100644
--- a/allocations/devtools/amie/amie-traffic.js
+++ b/allocations/devtools/amie/amie-traffic.js
@@ -23,7 +23,7 @@ import {Counter} from 'k6/metrics';
 import {randomIntBetween} from 'https://jslib.k6.io/k6-utils/1.4.0/index.js';
 
 const BASE_URL = __ENV.AMIE_BASE_URL || 
'https://a3mdev.xsede.org/amie-api-test';
-const SITE = __ENV.AMIE_SITE || 'GaTech';
+const SITE = __ENV.AMIE_SITE;
 const API_KEY = __ENV.AMIE_API_KEY;
 
 if (!API_KEY) {
diff --git a/compose/grafana/dashboards/amie-service.json 
b/compose/grafana/dashboards/amie-service.json
index 64b8e3089..32ee07de0 100644
--- a/compose/grafana/dashboards/amie-service.json
+++ b/compose/grafana/dashboards/amie-service.json
@@ -9,77 +9,113 @@
       "type": "stat",
       "title": "Total Packets Received",
       "gridPos": { "h": 4, "w": 6, "x": 0, "y": 0 },
-      "targets": [{ "expr": 
"round(sum(increase(amie_packets_received_total[$__range])))", "legendFormat": 
"Total" }],
+      "targets": [{
+        "rawSql": "SELECT COUNT(*) AS Total FROM amie_packets WHERE 
$__timeFilter(received_at)",
+        "format": "table",
+        "refId": "A"
+      }],
       "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": 
"blue", "value": null }] } } },
       "options": { "colorMode": "background", "textMode": "value_and_name" },
-      "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }
+      "datasource": { "type": "mysql", "uid": "mariadb-amie" }
     },
     {
       "type": "stat",
       "title": "Packets Succeeded",
       "gridPos": { "h": 4, "w": 6, "x": 6, "y": 0 },
-      "targets": [{ "expr": 
"round(sum(increase(amie_packets_processed_total{outcome=\"succeeded\"}[$__range])))",
 "legendFormat": "Succeeded" }],
+      "targets": [{
+        "rawSql": "SELECT COUNT(*) AS Succeeded FROM amie_processing_events 
WHERE status = 'SUCCEEDED' AND $__timeFilter(finished_at)",
+        "format": "table",
+        "refId": "A"
+      }],
       "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": 
"green", "value": null }] } } },
       "options": { "colorMode": "background", "textMode": "value_and_name" },
-      "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }
+      "datasource": { "type": "mysql", "uid": "mariadb-amie" }
     },
     {
       "type": "stat",
       "title": "Packets Failed",
       "gridPos": { "h": 4, "w": 6, "x": 12, "y": 0 },
-      "targets": [{ "expr": 
"round(sum(increase(amie_packets_processed_total{outcome=~\"permanently_failed|failed\"}[$__range])))",
 "legendFormat": "Failed" }],
+      "targets": [{
+        "rawSql": "SELECT COUNT(*) AS Failed FROM amie_processing_events WHERE 
status = 'PERMANENTLY_FAILED' AND $__timeFilter(finished_at)",
+        "format": "table",
+        "refId": "A"
+      }],
       "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": 
"green", "value": null }, { "color": "red", "value": 1 }] } } },
       "options": { "colorMode": "background", "textMode": "value_and_name" },
-      "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }
+      "datasource": { "type": "mysql", "uid": "mariadb-amie" }
     },
     {
       "type": "stat",
       "title": "Retries",
       "gridPos": { "h": 4, "w": 6, "x": 18, "y": 0 },
-      "targets": [{ "expr": 
"round(sum(increase(amie_events_retry_total[$__range]))) or vector(0)", 
"legendFormat": "Retries" }],
+      "targets": [{
+        "rawSql": "SELECT COALESCE(SUM(GREATEST(attempts - 1, 0)), 0) AS 
Retries FROM amie_processing_events WHERE $__timeFilter(created_at)",
+        "format": "table",
+        "refId": "A"
+      }],
       "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": 
"green", "value": null }, { "color": "orange", "value": 1 }, { "color": "red", 
"value": 5 }] } } },
       "options": { "colorMode": "background", "textMode": "value_and_name" },
-      "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }
+      "datasource": { "type": "mysql", "uid": "mariadb-amie" }
     },
     {
       "type": "timeseries",
       "title": "Packets Processed Over Time",
       "gridPos": { "h": 8, "w": 12, "x": 0, "y": 4 },
-      "targets": [
-        { "expr": "sum by (type) 
(rate(amie_packets_processed_total{outcome=\"succeeded\"}[5m]))", 
"legendFormat": "{{type}}" }
-      ],
+      "targets": [{
+        "rawSql": "SELECT $__timeGroupAlias(e.finished_at, $__interval, 0), 
p.type AS metric, COUNT(*) AS value FROM amie_processing_events e JOIN 
amie_packets p ON p.id = e.packet_id WHERE e.status = 'SUCCEEDED' AND 
$__timeFilter(e.finished_at) GROUP BY 1, p.type ORDER BY 1",
+        "format": "time_series",
+        "refId": "A"
+      }],
       "fieldConfig": { "defaults": { "custom": { "drawStyle": "line", 
"lineWidth": 2, "fillOpacity": 15, "pointSize": 5, "showPoints": "auto" } } },
       "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": 
"table", "placement": "bottom", "calcs": ["sum"] } },
-      "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }
+      "datasource": { "type": "mysql", "uid": "mariadb-amie" }
     },
     {
       "type": "timeseries",
       "title": "Failures & Retries Over Time",
       "gridPos": { "h": 8, "w": 12, "x": 12, "y": 4 },
       "targets": [
-        { "expr": 
"sum(rate(amie_packets_processed_total{outcome=~\"permanently_failed|retry_scheduled\"}[5m]))",
 "legendFormat": "Failures" },
-        { "expr": "sum(rate(amie_events_retry_total[5m]))", "legendFormat": 
"Retries" }
+        {
+          "rawSql": "SELECT $__timeGroupAlias(occurred_at, $__interval, 0), 
COUNT(*) AS \"Failed Attempts\" FROM amie_processing_errors WHERE 
$__timeFilter(occurred_at) GROUP BY 1 ORDER BY 1",
+          "format": "time_series",
+          "refId": "A"
+        },
+        {
+          "rawSql": "SELECT $__timeGroupAlias(finished_at, $__interval, 0), 
COUNT(*) AS \"Permanent Failures\" FROM amie_processing_events WHERE status = 
'PERMANENTLY_FAILED' AND $__timeFilter(finished_at) GROUP BY 1 ORDER BY 1",
+          "format": "time_series",
+          "refId": "B"
+        }
       ],
       "fieldConfig": { "defaults": { "custom": { "drawStyle": "line", 
"lineWidth": 2, "fillOpacity": 15 }, "color": { "mode": "palette-classic" } } },
       "options": { "tooltip": { "mode": "multi" }, "legend": { "displayMode": 
"table", "placement": "bottom", "calcs": ["sum"] } },
-      "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }
+      "datasource": { "type": "mysql", "uid": "mariadb-amie" }
     },
     {
       "type": "piechart",
       "title": "Packets by Type",
       "gridPos": { "h": 8, "w": 8, "x": 0, "y": 12 },
-      "targets": [
-        { "expr": "round(sum by (type) 
(increase(amie_packets_received_total[$__range])))", "legendFormat": "{{type}}" 
}
+      "targets": [{
+        "rawSql": "SELECT type AS metric, COUNT(*) AS value FROM amie_packets 
WHERE $__timeFilter(received_at) GROUP BY type",
+        "format": "table",
+        "refId": "A"
+      }],
+      "transformations": [
+        { "id": "rowsToFields", "options": {} }
       ],
       "options": { "legend": { "displayMode": "table", "placement": "right", 
"values": ["value", "percent"] }, "pieType": "donut" },
-      "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }
+      "datasource": { "type": "mysql", "uid": "mariadb-amie" }
     },
     {
       "type": "piechart",
       "title": "Processing Outcomes",
       "gridPos": { "h": 8, "w": 8, "x": 8, "y": 12 },
-      "targets": [
-        { "expr": "round(sum by (outcome) 
(increase(amie_packets_processed_total[$__range])))", "legendFormat": 
"{{outcome}}" }
+      "targets": [{
+        "rawSql": "SELECT CASE status WHEN 'SUCCEEDED' THEN 'succeeded' WHEN 
'PERMANENTLY_FAILED' THEN 'permanently_failed' WHEN 'RETRY_SCHEDULED' THEN 
'retry_scheduled' END AS metric, COUNT(*) AS value FROM amie_processing_events 
WHERE status IN ('SUCCEEDED','PERMANENTLY_FAILED','RETRY_SCHEDULED') AND 
$__timeFilter(created_at) GROUP BY status",
+        "format": "table",
+        "refId": "A"
+      }],
+      "transformations": [
+        { "id": "rowsToFields", "options": {} }
       ],
       "fieldConfig": { "overrides": [
         { "matcher": { "id": "byName", "options": "succeeded" }, "properties": 
[{ "id": "color", "value": { "fixedColor": "green", "mode": "fixed" } }] },
@@ -87,18 +123,23 @@
         { "matcher": { "id": "byName", "options": "retry_scheduled" }, 
"properties": [{ "id": "color", "value": { "fixedColor": "orange", "mode": 
"fixed" } }] }
       ] },
       "options": { "legend": { "displayMode": "table", "placement": "right", 
"values": ["value", "percent"] }, "pieType": "donut" },
-      "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }
+      "datasource": { "type": "mysql", "uid": "mariadb-amie" }
     },
     {
       "type": "bargauge",
       "title": "Packets Received by Type",
       "gridPos": { "h": 8, "w": 8, "x": 16, "y": 12 },
-      "targets": [
-        { "expr": "round(sum by (type) 
(increase(amie_packets_received_total[$__range])))", "legendFormat": "{{type}}" 
}
+      "targets": [{
+        "rawSql": "SELECT type AS metric, COUNT(*) AS value FROM amie_packets 
WHERE $__timeFilter(received_at) GROUP BY type",
+        "format": "table",
+        "refId": "A"
+      }],
+      "transformations": [
+        { "id": "rowsToFields", "options": {} }
       ],
       "fieldConfig": { "defaults": { "thresholds": { "steps": [{ "color": 
"blue", "value": null }] } } },
       "options": { "displayMode": "gradient", "orientation": "horizontal", 
"showUnfilled": true },
-      "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }
+      "datasource": { "type": "mysql", "uid": "mariadb-amie" }
     },
     {
       "type": "timeseries",
@@ -127,16 +168,18 @@
       "type": "table",
       "title": "Processed Count by Type & Outcome",
       "gridPos": { "h": 8, "w": 24, "x": 0, "y": 28 },
-      "targets": [
-        { "expr": "round(sum by (type, outcome) 
(increase(amie_packets_processed_total[$__range])))", "legendFormat": "{{type}} 
— {{outcome}}", "format": "table", "instant": true }
-      ],
+      "targets": [{
+        "rawSql": "SELECT p.type AS type, CASE e.status WHEN 'SUCCEEDED' THEN 
'succeeded' WHEN 'PERMANENTLY_FAILED' THEN 'permanently_failed' WHEN 
'RETRY_SCHEDULED' THEN 'retry_scheduled' END AS outcome, COUNT(*) AS count FROM 
amie_processing_events e JOIN amie_packets p ON p.id = e.packet_id WHERE 
e.status IN ('SUCCEEDED','PERMANENTLY_FAILED','RETRY_SCHEDULED') AND 
$__timeFilter(e.created_at) GROUP BY p.type, e.status",
+        "format": "table",
+        "refId": "A"
+      }],
       "transformations": [
-        { "id": "organize", "options": { "excludeByName": { "Time": true }, 
"renameByName": { "type": "Packet Type", "outcome": "Outcome", "Value": "Count" 
} } }
+        { "id": "organize", "options": { "excludeByName": {}, "renameByName": 
{ "type": "Packet Type", "outcome": "Outcome", "count": "Count" } } }
       ],
       "fieldConfig": { "overrides": [
         { "matcher": { "id": "byName", "options": "Outcome" }, "properties": 
[{ "id": "custom.cellOptions", "value": { "type": "color-text" } }, { "id": 
"mappings", "value": [{ "type": "value", "options": { "succeeded": { "color": 
"green", "text": "Succeeded" }, "permanently_failed": { "color": "red", "text": 
"Failed" }, "retry_scheduled": { "color": "orange", "text": "Retried" } } }] }] 
}
       ] },
-      "datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" }
+      "datasource": { "type": "mysql", "uid": "mariadb-amie" }
     }
   ],
   "refresh": "10s",

Reply via email to