{
  "name": "SocketX WebSocket Proxy",
  "description": "SocketX WebSocket Proxy Server - MTE Encryption Metrics. All widgets are NRQL queries over SocketX structured logs; see observability/README.md in the socketx-server repository for the event catalog. Works with v1 and v2 server logs.",
  "permissions": "PUBLIC_READ_WRITE",
  "pages": [
    {
      "name": "SocketX",
      "description": "Global health, MTE performance, traffic, and session audits",
      "widgets": [
        {
          "title": "Total Connections",
          "layout": { "column": 1, "row": 1, "width": 2, "height": 3 },
          "visualization": { "id": "viz.billboard" },
          "rawConfiguration": {
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT count(*) AS 'connections' FROM Log WHERE message = 'New websocket connection'"
              }
            ]
          }
        },
        {
          "title": "Total MTE Operations",
          "layout": { "column": 3, "row": 1, "width": 2, "height": 3 },
          "visualization": { "id": "viz.billboard" },
          "rawConfiguration": {
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT count(*) AS 'MTE operations' FROM Log WHERE message IN ('MTE encryption event', 'MTE decryption event')"
              }
            ]
          }
        },
        {
          "title": "Total Bytes Processed",
          "layout": { "column": 5, "row": 1, "width": 2, "height": 3 },
          "visualization": { "id": "viz.billboard" },
          "rawConfiguration": {
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT sum(payload_size_bytes) AS 'bytes' FROM Log WHERE message IN ('MTE encryption event', 'MTE decryption event')"
              }
            ]
          }
        },
        {
          "title": "Avg Encrypt Time (ms)",
          "layout": { "column": 7, "row": 1, "width": 2, "height": 3 },
          "visualization": { "id": "viz.billboard" },
          "rawConfiguration": {
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT average(duration_ms) AS 'avg encrypt ms' FROM Log WHERE message = 'MTE encryption event'"
              }
            ]
          }
        },
        {
          "title": "Avg Decrypt Time (ms)",
          "layout": { "column": 9, "row": 1, "width": 2, "height": 3 },
          "visualization": { "id": "viz.billboard" },
          "rawConfiguration": {
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT average(duration_ms) AS 'avg decrypt ms' FROM Log WHERE message = 'MTE decryption event'"
              }
            ]
          }
        },
        {
          "title": "Avg Session Duration (s)",
          "layout": { "column": 11, "row": 1, "width": 2, "height": 3 },
          "visualization": { "id": "viz.billboard" },
          "rawConfiguration": {
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT average(audit.duration_seconds) AS 'avg session s' FROM Log WHERE message = 'Websocket connection closed'"
              }
            ]
          }
        },
        {
          "title": "New Connections",
          "layout": { "column": 1, "row": 4, "width": 6, "height": 3 },
          "visualization": { "id": "viz.line" },
          "rawConfiguration": {
            "facet": { "showOtherSeries": false },
            "legend": { "enabled": true },
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT count(*) AS 'new connections' FROM Log WHERE message = 'New websocket connection' TIMESERIES AUTO"
              }
            ]
          }
        },
        {
          "title": "Session Duration",
          "layout": { "column": 7, "row": 4, "width": 6, "height": 3 },
          "visualization": { "id": "viz.line" },
          "rawConfiguration": {
            "legend": { "enabled": true },
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT average(audit.duration_seconds) AS 'avg s', max(audit.duration_seconds) AS 'max s', min(audit.duration_seconds) AS 'min s' FROM Log WHERE message = 'Websocket connection closed' TIMESERIES AUTO"
              }
            ]
          }
        },
        {
          "title": "Encryption Latency",
          "layout": { "column": 1, "row": 7, "width": 6, "height": 3 },
          "visualization": { "id": "viz.line" },
          "rawConfiguration": {
            "legend": { "enabled": true },
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT average(duration_ms) AS 'avg ms', percentile(duration_ms, 95, 99) FROM Log WHERE message = 'MTE encryption event' TIMESERIES AUTO"
              }
            ]
          }
        },
        {
          "title": "Decryption Latency",
          "layout": { "column": 7, "row": 7, "width": 6, "height": 3 },
          "visualization": { "id": "viz.line" },
          "rawConfiguration": {
            "legend": { "enabled": true },
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT average(duration_ms) AS 'avg ms', percentile(duration_ms, 95, 99) FROM Log WHERE message = 'MTE decryption event' TIMESERIES AUTO"
              }
            ]
          }
        },
        {
          "title": "MTE Operations Over Time",
          "layout": { "column": 1, "row": 10, "width": 6, "height": 3 },
          "visualization": { "id": "viz.line" },
          "rawConfiguration": {
            "facet": { "showOtherSeries": false },
            "legend": { "enabled": true },
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT count(*) FROM Log WHERE message IN ('MTE encryption event', 'MTE decryption event') FACET event_type TIMESERIES AUTO"
              }
            ]
          }
        },
        {
          "title": "Bytes Processed Over Time",
          "layout": { "column": 7, "row": 10, "width": 6, "height": 3 },
          "visualization": { "id": "viz.line" },
          "rawConfiguration": {
            "facet": { "showOtherSeries": false },
            "legend": { "enabled": true },
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT sum(payload_size_bytes) FROM Log WHERE message IN ('MTE encryption event', 'MTE decryption event') FACET event_type TIMESERIES AUTO"
              }
            ]
          }
        },
        {
          "title": "Payload Size Statistics",
          "layout": { "column": 1, "row": 13, "width": 6, "height": 3 },
          "visualization": { "id": "viz.line" },
          "rawConfiguration": {
            "legend": { "enabled": true },
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT average(payload_size_bytes) AS 'avg bytes', max(payload_size_bytes) AS 'max bytes', min(payload_size_bytes) AS 'min bytes' FROM Log WHERE message IN ('MTE encryption event', 'MTE decryption event') TIMESERIES AUTO"
              }
            ]
          }
        },
        {
          "title": "Messages by Direction",
          "layout": { "column": 7, "row": 13, "width": 6, "height": 3 },
          "visualization": { "id": "viz.line" },
          "rawConfiguration": {
            "legend": { "enabled": true },
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT sum(audit.messages_to_client) AS 'to client', sum(audit.messages_to_upstream) AS 'to upstream' FROM Log WHERE message = 'Websocket connection closed' TIMESERIES AUTO"
              }
            ]
          }
        },
        {
          "title": "Bytes by Direction",
          "layout": { "column": 1, "row": 16, "width": 6, "height": 3 },
          "visualization": { "id": "viz.line" },
          "rawConfiguration": {
            "legend": { "enabled": true },
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT sum(audit.bytes_to_client) AS 'to client bytes', sum(audit.bytes_to_upstream) AS 'to upstream bytes' FROM Log WHERE message = 'Websocket connection closed' TIMESERIES AUTO"
              }
            ]
          }
        },
        {
          "title": "Recovery Events",
          "layout": { "column": 7, "row": 16, "width": 6, "height": 3 },
          "visualization": { "id": "viz.line" },
          "rawConfiguration": {
            "facet": { "showOtherSeries": false },
            "legend": { "enabled": true },
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT count(*) FROM Log WHERE event_type = 'socketx_recovery' FACET recovery_action TIMESERIES AUTO"
              }
            ]
          }
        },
        {
          "title": "Recent Session Audits",
          "layout": { "column": 1, "row": 19, "width": 12, "height": 4 },
          "visualization": { "id": "viz.table" },
          "rawConfiguration": {
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT timestamp, connection_id, audit.client_addr, audit.duration_seconds, audit.outcome, audit.recovery_trigger, audit.recovery_action, audit.recovery_retryable, audit.mte_status, audit.messages_to_client, audit.messages_to_upstream FROM Log WHERE message = 'Websocket connection closed' LIMIT 50"
              }
            ]
          }
        },
        {
          "title": "Recent MTE and Recovery Events",
          "layout": { "column": 1, "row": 23, "width": 12, "height": 4 },
          "visualization": { "id": "viz.table" },
          "rawConfiguration": {
            "nrqlQueries": [
              {
                "accountIds": [0],
                "query": "SELECT timestamp, connection_id, event_type, phase, direction, trigger, failure_kind, recovery_action, retryable, mte_status, duration_ms, payload_size_bytes, upstream_server, origin FROM Log WHERE message IN ('MTE encryption event', 'MTE decryption event') OR event_type = 'socketx_recovery' LIMIT 100"
              }
            ]
          }
        }
      ]
    }
  ]
}
