Compare commits
40 Commits
5f46d26037
...
feat/mevno
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71b00f80bb | ||
|
|
01f6543ae9 | ||
|
|
8a474242df | ||
|
|
db4e45dc55 | ||
|
|
3572382c90 | ||
|
|
bb6f633d19 | ||
|
|
108bf22968 | ||
|
|
59c3f3ee06 | ||
|
|
9c4c3096d7 | ||
|
|
b02bd6b66c | ||
|
|
890ac4c86e | ||
| 9c6e974d3a | |||
| d1dc32d3bb | |||
| a6a0accd6a | |||
| 3b8b1f5492 | |||
| 0c80a08732 | |||
| 8b72e62621 | |||
| ff7a4b69cd | |||
| e7f9594381 | |||
| 0c0f219d02 | |||
| 9cf0ed84d9 | |||
| 2702edce22 | |||
| c33533fcd6 | |||
| 32eb047551 | |||
| d27d64e407 | |||
| fa6893aa98 | |||
| 77a8265b40 | |||
| c692f8d653 | |||
| 47096c9877 | |||
| 0104532e73 | |||
| 19e7e48190 | |||
| 7ef3ffe62c | |||
| 1853ef6452 | |||
| 34ef9490a4 | |||
| f3bc3da9bb | |||
| f797234abd | |||
| c95a4286fb | |||
| b72f281651 | |||
| 98912c5b03 | |||
| 28876fa1d2 |
20
bootstrap/argocd/application-monitoring-extras.yaml
Normal file
20
bootstrap/argocd/application-monitoring-extras.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: monitoring-extras
|
||||||
|
namespace: argocd
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
source:
|
||||||
|
repoURL: https://gitea.mpabi.pl/trade/trade-deploy.git
|
||||||
|
targetRevision: main
|
||||||
|
path: kustomize/infra/monitoring-extras
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: monitoring
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
50
bootstrap/argocd/application-monitoring-stack.yaml
Normal file
50
bootstrap/argocd/application-monitoring-stack.yaml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: monitoring-stack
|
||||||
|
namespace: argocd
|
||||||
|
spec:
|
||||||
|
project: default
|
||||||
|
source:
|
||||||
|
repoURL: https://prometheus-community.github.io/helm-charts
|
||||||
|
chart: kube-prometheus-stack
|
||||||
|
targetRevision: 81.6.9
|
||||||
|
helm:
|
||||||
|
skipCrds: true
|
||||||
|
values: |
|
||||||
|
grafana:
|
||||||
|
enabled: true
|
||||||
|
prometheus:
|
||||||
|
prometheusSpec:
|
||||||
|
scrapeInterval: 15s
|
||||||
|
evaluationInterval: 15s
|
||||||
|
additionalScrapeConfigs:
|
||||||
|
- job_name: mpabi-yellowstone-geyser
|
||||||
|
metrics_path: /metrics
|
||||||
|
scrape_interval: 10s
|
||||||
|
fallback_scrape_protocol: PrometheusText0.0.4
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
- 10.66.66.1:8999
|
||||||
|
- job_name: mpabi-node-exporter
|
||||||
|
metrics_path: /metrics
|
||||||
|
scrape_interval: 15s
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
- 10.66.66.1:9100
|
||||||
|
prometheusOperator:
|
||||||
|
admissionWebhooks:
|
||||||
|
enabled: false
|
||||||
|
patch:
|
||||||
|
enabled: false
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: monitoring
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
|
- Replace=true
|
||||||
|
- ServerSideApply=true
|
||||||
@@ -29,7 +29,7 @@ spec:
|
|||||||
- name: DLOB_SOURCE
|
- name: DLOB_SOURCE
|
||||||
value: drift
|
value: drift
|
||||||
- name: DLOB_MARKETS
|
- name: DLOB_MARKETS
|
||||||
value: PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP
|
value: SOL-PERP,DOGE-PERP,JUP-PERP
|
||||||
- name: DLOB_POLL_MS
|
- name: DLOB_POLL_MS
|
||||||
value: "1000"
|
value: "1000"
|
||||||
- name: DLOB_DEPTH_BPS_BANDS
|
- name: DLOB_DEPTH_BPS_BANDS
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ spec:
|
|||||||
- name: DLOB_SOURCE
|
- name: DLOB_SOURCE
|
||||||
value: mevnode
|
value: mevnode
|
||||||
- name: DLOB_MARKETS
|
- name: DLOB_MARKETS
|
||||||
value: PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP
|
value: SOL-PERP,DOGE-PERP,JUP-PERP
|
||||||
- name: DLOB_POLL_MS
|
- name: DLOB_POLL_MS
|
||||||
value: "1000"
|
value: "1000"
|
||||||
- name: DLOB_DEPTH_BPS_BANDS
|
- name: DLOB_DEPTH_BPS_BANDS
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ function resolveConfig() {
|
|||||||
const hasuraAuthToken = process.env.HASURA_AUTH_TOKEN || process.env.HASURA_JWT || undefined;
|
const hasuraAuthToken = process.env.HASURA_AUTH_TOKEN || process.env.HASURA_JWT || undefined;
|
||||||
|
|
||||||
const dlobSource = String(process.env.DLOB_SOURCE || 'mevnode').trim() || 'mevnode';
|
const dlobSource = String(process.env.DLOB_SOURCE || 'mevnode').trim() || 'mevnode';
|
||||||
const markets = envList('DLOB_MARKETS', 'PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP');
|
const markets = envList('DLOB_MARKETS', 'SOL-PERP,DOGE-PERP,JUP-PERP');
|
||||||
const pollMs = clampInt(process.env.DLOB_POLL_MS, 250, 60_000, 1000);
|
const pollMs = clampInt(process.env.DLOB_POLL_MS, 250, 60_000, 1000);
|
||||||
const bandsBps = envIntList('DLOB_DEPTH_BPS_BANDS', '5,10,20,50,100,200');
|
const bandsBps = envIntList('DLOB_DEPTH_BPS_BANDS', '5,10,20,50,100,200');
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ spec:
|
|||||||
- name: DLOB_SOURCE
|
- name: DLOB_SOURCE
|
||||||
value: drift
|
value: drift
|
||||||
- name: DLOB_MARKETS
|
- name: DLOB_MARKETS
|
||||||
value: PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP
|
value: SOL-PERP,DOGE-PERP,JUP-PERP
|
||||||
- name: DLOB_POLL_MS
|
- name: DLOB_POLL_MS
|
||||||
value: "1000"
|
value: "1000"
|
||||||
- name: DLOB_SLIPPAGE_SIZES_USD
|
- name: DLOB_SLIPPAGE_SIZES_USD
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ spec:
|
|||||||
- name: DLOB_SOURCE
|
- name: DLOB_SOURCE
|
||||||
value: mevnode
|
value: mevnode
|
||||||
- name: DLOB_MARKETS
|
- name: DLOB_MARKETS
|
||||||
value: PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP
|
value: SOL-PERP,DOGE-PERP,JUP-PERP
|
||||||
- name: DLOB_POLL_MS
|
- name: DLOB_POLL_MS
|
||||||
value: "1000"
|
value: "1000"
|
||||||
- name: DLOB_SLIPPAGE_SIZES_USD
|
- name: DLOB_SLIPPAGE_SIZES_USD
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ function resolveConfig() {
|
|||||||
const hasuraAuthToken = process.env.HASURA_AUTH_TOKEN || process.env.HASURA_JWT || undefined;
|
const hasuraAuthToken = process.env.HASURA_AUTH_TOKEN || process.env.HASURA_JWT || undefined;
|
||||||
|
|
||||||
const dlobSource = String(process.env.DLOB_SOURCE || 'mevnode').trim() || 'mevnode';
|
const dlobSource = String(process.env.DLOB_SOURCE || 'mevnode').trim() || 'mevnode';
|
||||||
const markets = envList('DLOB_MARKETS', 'PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP');
|
const markets = envList('DLOB_MARKETS', 'SOL-PERP,DOGE-PERP,JUP-PERP');
|
||||||
const pollMs = clampInt(process.env.DLOB_POLL_MS, 250, 60_000, 1000);
|
const pollMs = clampInt(process.env.DLOB_POLL_MS, 250, 60_000, 1000);
|
||||||
|
|
||||||
const sizesUsd = envList('DLOB_SLIPPAGE_SIZES_USD', '10,25,50,100,250,500,1000')
|
const sizesUsd = envList('DLOB_SLIPPAGE_SIZES_USD', '10,25,50,100,250,500,1000')
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ spec:
|
|||||||
- name: DLOB_SOURCE
|
- name: DLOB_SOURCE
|
||||||
value: drift
|
value: drift
|
||||||
- name: DLOB_MARKETS
|
- name: DLOB_MARKETS
|
||||||
value: PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP
|
value: SOL-PERP,DOGE-PERP,JUP-PERP
|
||||||
- name: DLOB_TS_POLL_MS
|
- name: DLOB_TS_POLL_MS
|
||||||
value: "1000"
|
value: "1000"
|
||||||
command: ["node", "/app/worker.mjs"]
|
command: ["node", "/app/worker.mjs"]
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ spec:
|
|||||||
- name: DLOB_SOURCE
|
- name: DLOB_SOURCE
|
||||||
value: mevnode
|
value: mevnode
|
||||||
- name: DLOB_MARKETS
|
- name: DLOB_MARKETS
|
||||||
value: PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP
|
value: SOL-PERP,DOGE-PERP,JUP-PERP
|
||||||
- name: DLOB_TS_POLL_MS
|
- name: DLOB_TS_POLL_MS
|
||||||
value: "1000"
|
value: "1000"
|
||||||
command: ["node", "/app/worker.mjs"]
|
command: ["node", "/app/worker.mjs"]
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function resolveConfig() {
|
|||||||
const hasuraAuthToken = process.env.HASURA_AUTH_TOKEN || process.env.HASURA_JWT || undefined;
|
const hasuraAuthToken = process.env.HASURA_AUTH_TOKEN || process.env.HASURA_JWT || undefined;
|
||||||
|
|
||||||
const dlobSource = String(process.env.DLOB_SOURCE || 'mevnode').trim() || 'mevnode';
|
const dlobSource = String(process.env.DLOB_SOURCE || 'mevnode').trim() || 'mevnode';
|
||||||
const markets = envList('DLOB_MARKETS', 'PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP');
|
const markets = envList('DLOB_MARKETS', 'SOL-PERP,DOGE-PERP,JUP-PERP');
|
||||||
const pollMs = clampInt(process.env.DLOB_TS_POLL_MS, 500, 60_000, 1000);
|
const pollMs = clampInt(process.env.DLOB_TS_POLL_MS, 500, 60_000, 1000);
|
||||||
|
|
||||||
return { hasuraUrl, hasuraAdminSecret, hasuraAuthToken, dlobSource, markets, pollMs };
|
return { hasuraUrl, hasuraAdminSecret, hasuraAuthToken, dlobSource, markets, pollMs };
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ spec:
|
|||||||
- name: DLOB_FORCE_IPV6
|
- name: DLOB_FORCE_IPV6
|
||||||
value: "true"
|
value: "true"
|
||||||
- name: DLOB_MARKETS
|
- name: DLOB_MARKETS
|
||||||
value: PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP
|
value: SOL-PERP,DOGE-PERP,JUP-PERP
|
||||||
- name: DLOB_POLL_MS
|
- name: DLOB_POLL_MS
|
||||||
value: "500"
|
value: "500"
|
||||||
- name: DLOB_DEPTH
|
- name: DLOB_DEPTH
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ spec:
|
|||||||
- name: DLOB_HTTP_URL
|
- name: DLOB_HTTP_URL
|
||||||
value: http://dlob-server:6969
|
value: http://dlob-server:6969
|
||||||
- name: DLOB_MARKETS
|
- name: DLOB_MARKETS
|
||||||
value: PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP
|
value: SOL-PERP,DOGE-PERP,JUP-PERP
|
||||||
- name: DLOB_POLL_MS
|
- name: DLOB_POLL_MS
|
||||||
value: "500"
|
value: "500"
|
||||||
- name: DLOB_DEPTH
|
- name: DLOB_DEPTH
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ function resolveConfig() {
|
|||||||
const dlobForceIpv6 = envBool('DLOB_FORCE_IPV6', false);
|
const dlobForceIpv6 = envBool('DLOB_FORCE_IPV6', false);
|
||||||
const dlobSource = String(process.env.DLOB_SOURCE || 'mevnode').trim() || 'mevnode';
|
const dlobSource = String(process.env.DLOB_SOURCE || 'mevnode').trim() || 'mevnode';
|
||||||
|
|
||||||
const markets = envList('DLOB_MARKETS', 'PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP');
|
const markets = envList('DLOB_MARKETS', 'SOL-PERP,DOGE-PERP,JUP-PERP');
|
||||||
const depth = clampInt(process.env.DLOB_DEPTH, 1, 50, 10);
|
const depth = clampInt(process.env.DLOB_DEPTH, 1, 50, 10);
|
||||||
const pollMs = clampInt(process.env.DLOB_POLL_MS, 100, 10_000, 500);
|
const pollMs = clampInt(process.env.DLOB_POLL_MS, 100, 10_000, 500);
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ spec:
|
|||||||
- name: gitea-registry
|
- name: gitea-registry
|
||||||
containers:
|
containers:
|
||||||
- name: publisher
|
- name: publisher
|
||||||
image: gitea.mpabi.pl/trade/trade-dlob-server:sha-8a378b7-lite-l2
|
image: gitea.mpabi.pl/trade/trade-dlob-server:sha-5d55631-canonical
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
@@ -43,7 +43,7 @@ spec:
|
|||||||
- name: REDIS_CLIENT
|
- name: REDIS_CLIENT
|
||||||
value: DLOB
|
value: DLOB
|
||||||
- name: PERP_MARKETS_TO_LOAD
|
- name: PERP_MARKETS_TO_LOAD
|
||||||
value: "0,1,2,4,75"
|
value: "0,7,24"
|
||||||
- name: ENDPOINT
|
- name: ENDPOINT
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
@@ -59,11 +59,15 @@ spec:
|
|||||||
httpGet:
|
httpGet:
|
||||||
path: /startup
|
path: /startup
|
||||||
port: http
|
port: http
|
||||||
initialDelaySeconds: 10
|
initialDelaySeconds: 120
|
||||||
periodSeconds: 10
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 3
|
||||||
|
failureThreshold: 30
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /health
|
path: /health
|
||||||
port: http
|
port: http
|
||||||
initialDelaySeconds: 30
|
initialDelaySeconds: 240
|
||||||
periodSeconds: 20
|
periodSeconds: 20
|
||||||
|
timeoutSeconds: 3
|
||||||
|
failureThreshold: 10
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ spec:
|
|||||||
- name: gitea-registry
|
- name: gitea-registry
|
||||||
containers:
|
containers:
|
||||||
- name: server
|
- name: server
|
||||||
image: gitea.mpabi.pl/trade/trade-dlob-server:sha-8a378b7-lite-l2
|
image: gitea.mpabi.pl/trade/trade-dlob-server:sha-5d55631-canonical
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
- name: http
|
- name: http
|
||||||
|
|||||||
@@ -96,7 +96,11 @@ async function main() {
|
|||||||
|
|
||||||
const baseTicks = { schema: 'public', name: 'drift_ticks' };
|
const baseTicks = { schema: 'public', name: 'drift_ticks' };
|
||||||
const dlobL2LatestTable = { schema: 'public', name: 'dlob_l2_latest' };
|
const dlobL2LatestTable = { schema: 'public', name: 'dlob_l2_latest' };
|
||||||
|
const dlobL2LatestProjectionView = { schema: 'public', name: 'dlob_l2_latest_projection' };
|
||||||
|
const dlobL3LatestProjectionView = { schema: 'public', name: 'dlob_l3_latest_projection' };
|
||||||
|
const dlobBestMakersLatestProjectionView = { schema: 'public', name: 'dlob_best_makers_latest_projection' };
|
||||||
const dlobStatsLatestTable = { schema: 'public', name: 'dlob_stats_latest' };
|
const dlobStatsLatestTable = { schema: 'public', name: 'dlob_stats_latest' };
|
||||||
|
const dlobStatsLatestProjectionView = { schema: 'public', name: 'dlob_stats_latest_projection' };
|
||||||
const dlobDepthBpsLatestTable = { schema: 'public', name: 'dlob_depth_bps_latest' };
|
const dlobDepthBpsLatestTable = { schema: 'public', name: 'dlob_depth_bps_latest' };
|
||||||
const dlobSlippageLatestTable = { schema: 'public', name: 'dlob_slippage_latest' };
|
const dlobSlippageLatestTable = { schema: 'public', name: 'dlob_slippage_latest' };
|
||||||
const dlobSlippageLatestV2Table = { schema: 'public', name: 'dlob_slippage_latest_v2' };
|
const dlobSlippageLatestV2Table = { schema: 'public', name: 'dlob_slippage_latest_v2' };
|
||||||
@@ -261,9 +265,36 @@ async function main() {
|
|||||||
await metadataIgnore({ type: 'pg_drop_update_permission', args: { source, table, role: 'ingestor' } });
|
await metadataIgnore({ type: 'pg_drop_update_permission', args: { source, table, role: 'ingestor' } });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function ensureProjectedPublicSelectTable(table, columns, { publicFilter, customName } = {}) {
|
||||||
|
await metadataIgnore({ type: 'pg_untrack_table', args: { source, table, cascade: true } });
|
||||||
|
const args = { source, table };
|
||||||
|
if (customName) {
|
||||||
|
args.configuration = { custom_name: customName };
|
||||||
|
}
|
||||||
|
await metadata({ type: 'pg_track_table', args });
|
||||||
|
|
||||||
|
await metadataIgnore({ type: 'pg_drop_select_permission', args: { source, table, role: 'public' } });
|
||||||
|
await metadata({
|
||||||
|
type: 'pg_create_select_permission',
|
||||||
|
args: {
|
||||||
|
source,
|
||||||
|
table,
|
||||||
|
role: 'public',
|
||||||
|
permission: {
|
||||||
|
columns,
|
||||||
|
filter: publicFilter || {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await metadataIgnore({ type: 'pg_drop_insert_permission', args: { source, table, role: 'ingestor' } });
|
||||||
|
await metadataIgnore({ type: 'pg_drop_update_permission', args: { source, table, role: 'ingestor' } });
|
||||||
|
}
|
||||||
|
|
||||||
const dlobPublicFilter = { source: { _eq: PUBLIC_DLOB_SOURCE_HEADER } };
|
const dlobPublicFilter = { source: { _eq: PUBLIC_DLOB_SOURCE_HEADER } };
|
||||||
|
|
||||||
await ensureDlobTable(dlobL2LatestTable, [
|
await metadataIgnore({ type: 'pg_untrack_table', args: { source, table: dlobL2LatestTable, cascade: true } });
|
||||||
|
await ensureProjectedPublicSelectTable(dlobL2LatestProjectionView, [
|
||||||
'source',
|
'source',
|
||||||
'market_name',
|
'market_name',
|
||||||
'market_type',
|
'market_type',
|
||||||
@@ -278,9 +309,10 @@ async function main() {
|
|||||||
'asks',
|
'asks',
|
||||||
'raw',
|
'raw',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
], { publicFilter: dlobPublicFilter });
|
], { publicFilter: dlobPublicFilter, customName: 'dlob_l2_latest' });
|
||||||
|
|
||||||
await ensureDlobTable(dlobStatsLatestTable, [
|
await metadataIgnore({ type: 'pg_untrack_table', args: { source, table: dlobStatsLatestTable, cascade: true } });
|
||||||
|
await ensureProjectedPublicSelectTable(dlobStatsLatestProjectionView, [
|
||||||
'source',
|
'source',
|
||||||
'market_name',
|
'market_name',
|
||||||
'market_type',
|
'market_type',
|
||||||
@@ -302,6 +334,31 @@ async function main() {
|
|||||||
'imbalance',
|
'imbalance',
|
||||||
'raw',
|
'raw',
|
||||||
'updated_at',
|
'updated_at',
|
||||||
|
], { publicFilter: dlobPublicFilter, customName: 'dlob_stats_latest' });
|
||||||
|
|
||||||
|
await ensureProjectedPublicSelectTable(dlobL3LatestProjectionView, [
|
||||||
|
'source',
|
||||||
|
'market_name',
|
||||||
|
'market_type',
|
||||||
|
'market_index',
|
||||||
|
'ts',
|
||||||
|
'slot',
|
||||||
|
'bids',
|
||||||
|
'asks',
|
||||||
|
'raw',
|
||||||
|
'updated_at',
|
||||||
|
], { publicFilter: dlobPublicFilter });
|
||||||
|
|
||||||
|
await ensureProjectedPublicSelectTable(dlobBestMakersLatestProjectionView, [
|
||||||
|
'source',
|
||||||
|
'market_name',
|
||||||
|
'market_type',
|
||||||
|
'market_index',
|
||||||
|
'slot',
|
||||||
|
'bids',
|
||||||
|
'asks',
|
||||||
|
'raw',
|
||||||
|
'updated_at',
|
||||||
], { publicFilter: dlobPublicFilter });
|
], { publicFilter: dlobPublicFilter });
|
||||||
|
|
||||||
await ensurePublicSelectTable(dlobDepthBpsLatestTable, [
|
await ensurePublicSelectTable(dlobDepthBpsLatestTable, [
|
||||||
|
|||||||
@@ -814,3 +814,246 @@ BEGIN
|
|||||||
PERFORM add_retention_policy('dlob_slippage_ts_v2', INTERVAL '7 days');
|
PERFORM add_retention_policy('dlob_slippage_ts_v2', INTERVAL '7 days');
|
||||||
EXCEPTION WHEN OTHERS THEN
|
EXCEPTION WHEN OTHERS THEN
|
||||||
END $$;
|
END $$;
|
||||||
|
|
||||||
|
-- Canonical DLOB storage and projection layer.
|
||||||
|
CREATE TABLE IF NOT EXISTS public.dlob_orderbook_l2_latest (
|
||||||
|
source TEXT NOT NULL,
|
||||||
|
market_name TEXT NOT NULL,
|
||||||
|
market_type TEXT NOT NULL,
|
||||||
|
market_index INTEGER,
|
||||||
|
is_indicative BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
ts BIGINT,
|
||||||
|
slot BIGINT,
|
||||||
|
mark_price_raw TEXT,
|
||||||
|
oracle_price_raw TEXT,
|
||||||
|
best_bid_price_raw TEXT,
|
||||||
|
best_ask_price_raw TEXT,
|
||||||
|
spread_pct_raw TEXT,
|
||||||
|
spread_quote_raw TEXT,
|
||||||
|
oracle_data JSONB,
|
||||||
|
bids JSONB,
|
||||||
|
asks JSONB,
|
||||||
|
payload JSONB NOT NULL,
|
||||||
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||||
|
PRIMARY KEY (source, market_name, is_indicative)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public.dlob_orderbook_l3_latest (
|
||||||
|
source TEXT NOT NULL,
|
||||||
|
market_name TEXT NOT NULL,
|
||||||
|
market_type TEXT NOT NULL,
|
||||||
|
market_index INTEGER,
|
||||||
|
is_indicative BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
ts BIGINT,
|
||||||
|
slot BIGINT,
|
||||||
|
oracle_data JSONB,
|
||||||
|
bids JSONB,
|
||||||
|
asks JSONB,
|
||||||
|
payload JSONB NOT NULL,
|
||||||
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||||
|
PRIMARY KEY (source, market_name, is_indicative)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS public.dlob_best_makers_latest (
|
||||||
|
source TEXT NOT NULL,
|
||||||
|
market_name TEXT NOT NULL,
|
||||||
|
market_type TEXT NOT NULL,
|
||||||
|
market_index INTEGER,
|
||||||
|
slot BIGINT,
|
||||||
|
bids JSONB,
|
||||||
|
asks JSONB,
|
||||||
|
payload JSONB NOT NULL,
|
||||||
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||||
|
PRIMARY KEY (source, market_name)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS dlob_orderbook_l2_latest_updated_at_idx
|
||||||
|
ON public.dlob_orderbook_l2_latest (updated_at DESC);
|
||||||
|
CREATE INDEX IF NOT EXISTS dlob_orderbook_l3_latest_updated_at_idx
|
||||||
|
ON public.dlob_orderbook_l3_latest (updated_at DESC);
|
||||||
|
CREATE INDEX IF NOT EXISTS dlob_best_makers_latest_updated_at_idx
|
||||||
|
ON public.dlob_best_makers_latest (updated_at DESC);
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW public.dlob_l2_latest_projection AS
|
||||||
|
SELECT
|
||||||
|
source,
|
||||||
|
market_name,
|
||||||
|
market_type,
|
||||||
|
market_index,
|
||||||
|
ts,
|
||||||
|
slot,
|
||||||
|
CASE
|
||||||
|
WHEN NULLIF(mark_price_raw, '') IS NULL THEN NULL
|
||||||
|
ELSE NULLIF(mark_price_raw, '')::numeric / 1000000::numeric
|
||||||
|
END AS mark_price,
|
||||||
|
CASE
|
||||||
|
WHEN NULLIF(oracle_price_raw, '') IS NULL THEN NULL
|
||||||
|
ELSE NULLIF(oracle_price_raw, '')::numeric / 1000000::numeric
|
||||||
|
END AS oracle_price,
|
||||||
|
CASE
|
||||||
|
WHEN NULLIF(best_bid_price_raw, '') IS NULL THEN NULL
|
||||||
|
ELSE NULLIF(best_bid_price_raw, '')::numeric / 1000000::numeric
|
||||||
|
END AS best_bid_price,
|
||||||
|
CASE
|
||||||
|
WHEN NULLIF(best_ask_price_raw, '') IS NULL THEN NULL
|
||||||
|
ELSE NULLIF(best_ask_price_raw, '')::numeric / 1000000::numeric
|
||||||
|
END AS best_ask_price,
|
||||||
|
bids,
|
||||||
|
asks,
|
||||||
|
payload AS raw,
|
||||||
|
updated_at
|
||||||
|
FROM public.dlob_orderbook_l2_latest
|
||||||
|
WHERE is_indicative = FALSE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW public.dlob_l3_latest_projection AS
|
||||||
|
SELECT
|
||||||
|
source,
|
||||||
|
market_name,
|
||||||
|
market_type,
|
||||||
|
market_index,
|
||||||
|
ts,
|
||||||
|
slot,
|
||||||
|
bids,
|
||||||
|
asks,
|
||||||
|
payload AS raw,
|
||||||
|
updated_at
|
||||||
|
FROM public.dlob_orderbook_l3_latest
|
||||||
|
WHERE is_indicative = FALSE;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW public.dlob_best_makers_latest_projection AS
|
||||||
|
SELECT
|
||||||
|
source,
|
||||||
|
market_name,
|
||||||
|
market_type,
|
||||||
|
market_index,
|
||||||
|
slot,
|
||||||
|
bids,
|
||||||
|
asks,
|
||||||
|
payload AS raw,
|
||||||
|
updated_at
|
||||||
|
FROM public.dlob_best_makers_latest;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW public.dlob_stats_latest_projection AS
|
||||||
|
WITH base AS (
|
||||||
|
SELECT
|
||||||
|
source,
|
||||||
|
market_name,
|
||||||
|
market_type,
|
||||||
|
market_index,
|
||||||
|
ts,
|
||||||
|
slot,
|
||||||
|
CASE
|
||||||
|
WHEN NULLIF(mark_price_raw, '') IS NULL THEN NULL
|
||||||
|
ELSE NULLIF(mark_price_raw, '')::numeric / 1000000::numeric
|
||||||
|
END AS mark_price,
|
||||||
|
CASE
|
||||||
|
WHEN NULLIF(oracle_price_raw, '') IS NULL THEN NULL
|
||||||
|
ELSE NULLIF(oracle_price_raw, '')::numeric / 1000000::numeric
|
||||||
|
END AS oracle_price,
|
||||||
|
CASE
|
||||||
|
WHEN NULLIF(best_bid_price_raw, '') IS NULL THEN NULL
|
||||||
|
ELSE NULLIF(best_bid_price_raw, '')::numeric / 1000000::numeric
|
||||||
|
END AS best_bid_price,
|
||||||
|
CASE
|
||||||
|
WHEN NULLIF(best_ask_price_raw, '') IS NULL THEN NULL
|
||||||
|
ELSE NULLIF(best_ask_price_raw, '')::numeric / 1000000::numeric
|
||||||
|
END AS best_ask_price,
|
||||||
|
bids,
|
||||||
|
asks,
|
||||||
|
payload,
|
||||||
|
updated_at
|
||||||
|
FROM public.dlob_orderbook_l2_latest
|
||||||
|
WHERE is_indicative = FALSE
|
||||||
|
),
|
||||||
|
bid_levels AS (
|
||||||
|
SELECT
|
||||||
|
b.source,
|
||||||
|
b.market_name,
|
||||||
|
COALESCE(
|
||||||
|
SUM((NULLIF(level->>'size', '')::numeric) / 1000000000::numeric),
|
||||||
|
0::numeric
|
||||||
|
) AS depth_bid_base,
|
||||||
|
COALESCE(
|
||||||
|
SUM(
|
||||||
|
((NULLIF(level->>'size', '')::numeric) / 1000000000::numeric) *
|
||||||
|
((NULLIF(level->>'price', '')::numeric) / 1000000::numeric)
|
||||||
|
),
|
||||||
|
0::numeric
|
||||||
|
) AS depth_bid_usd
|
||||||
|
FROM base b
|
||||||
|
LEFT JOIN LATERAL (
|
||||||
|
SELECT level
|
||||||
|
FROM jsonb_array_elements(COALESCE(b.bids, '[]'::jsonb)) WITH ORDINALITY AS e(level, ord)
|
||||||
|
WHERE ord <= 10
|
||||||
|
) levels ON TRUE
|
||||||
|
GROUP BY b.source, b.market_name
|
||||||
|
),
|
||||||
|
ask_levels AS (
|
||||||
|
SELECT
|
||||||
|
b.source,
|
||||||
|
b.market_name,
|
||||||
|
COALESCE(
|
||||||
|
SUM((NULLIF(level->>'size', '')::numeric) / 1000000000::numeric),
|
||||||
|
0::numeric
|
||||||
|
) AS depth_ask_base,
|
||||||
|
COALESCE(
|
||||||
|
SUM(
|
||||||
|
((NULLIF(level->>'size', '')::numeric) / 1000000000::numeric) *
|
||||||
|
((NULLIF(level->>'price', '')::numeric) / 1000000::numeric)
|
||||||
|
),
|
||||||
|
0::numeric
|
||||||
|
) AS depth_ask_usd
|
||||||
|
FROM base b
|
||||||
|
LEFT JOIN LATERAL (
|
||||||
|
SELECT level
|
||||||
|
FROM jsonb_array_elements(COALESCE(b.asks, '[]'::jsonb)) WITH ORDINALITY AS e(level, ord)
|
||||||
|
WHERE ord <= 10
|
||||||
|
) levels ON TRUE
|
||||||
|
GROUP BY b.source, b.market_name
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
b.source,
|
||||||
|
b.market_name,
|
||||||
|
b.market_type,
|
||||||
|
b.market_index,
|
||||||
|
b.ts,
|
||||||
|
b.slot,
|
||||||
|
b.mark_price,
|
||||||
|
b.oracle_price,
|
||||||
|
b.best_bid_price,
|
||||||
|
b.best_ask_price,
|
||||||
|
CASE
|
||||||
|
WHEN b.best_bid_price IS NOT NULL AND b.best_ask_price IS NOT NULL
|
||||||
|
THEN (b.best_bid_price + b.best_ask_price) / 2
|
||||||
|
ELSE NULL
|
||||||
|
END AS mid_price,
|
||||||
|
CASE
|
||||||
|
WHEN b.best_bid_price IS NOT NULL AND b.best_ask_price IS NOT NULL
|
||||||
|
THEN b.best_ask_price - b.best_bid_price
|
||||||
|
ELSE NULL
|
||||||
|
END AS spread_abs,
|
||||||
|
CASE
|
||||||
|
WHEN b.best_bid_price IS NOT NULL
|
||||||
|
AND b.best_ask_price IS NOT NULL
|
||||||
|
AND (b.best_bid_price + b.best_ask_price) > 0
|
||||||
|
THEN ((b.best_ask_price - b.best_bid_price) / ((b.best_bid_price + b.best_ask_price) / 2)) * 10000
|
||||||
|
ELSE NULL
|
||||||
|
END AS spread_bps,
|
||||||
|
10::integer AS depth_levels,
|
||||||
|
bids.depth_bid_base,
|
||||||
|
asks.depth_ask_base,
|
||||||
|
bids.depth_bid_usd,
|
||||||
|
asks.depth_ask_usd,
|
||||||
|
CASE
|
||||||
|
WHEN (bids.depth_bid_usd + asks.depth_ask_usd) > 0
|
||||||
|
THEN (bids.depth_bid_usd - asks.depth_ask_usd) / (bids.depth_bid_usd + asks.depth_ask_usd)
|
||||||
|
ELSE NULL
|
||||||
|
END AS imbalance,
|
||||||
|
jsonb_build_object(
|
||||||
|
'canonical_table', 'dlob_orderbook_l2_latest',
|
||||||
|
'projection', 'dlob_stats_latest_projection'
|
||||||
|
) AS raw,
|
||||||
|
b.updated_at
|
||||||
|
FROM base b
|
||||||
|
LEFT JOIN bid_levels bids USING (source, market_name)
|
||||||
|
LEFT JOIN ask_levels asks USING (source, market_name);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
apiVersion: cert-manager.io/v1
|
||||||
|
kind: Certificate
|
||||||
|
metadata:
|
||||||
|
name: monitoring-mpabi-pl
|
||||||
|
namespace: monitoring
|
||||||
|
spec:
|
||||||
|
secretName: monitoring-mpabi-pl-tls
|
||||||
|
issuerRef:
|
||||||
|
kind: ClusterIssuer
|
||||||
|
name: letsencrypt-prod
|
||||||
|
dnsNames:
|
||||||
|
- grafana.mpabi.pl
|
||||||
|
- prometheus.mpabi.pl
|
||||||
238
kustomize/infra/monitoring-extras/dashboard-agave-status.yaml
Normal file
238
kustomize/infra/monitoring-extras/dashboard-agave-status.yaml
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: grafana-dashboard-agave-status
|
||||||
|
namespace: monitoring
|
||||||
|
labels:
|
||||||
|
grafana_dashboard: "1"
|
||||||
|
data:
|
||||||
|
agave-status.json: |-
|
||||||
|
{
|
||||||
|
"uid": "agave-status-mpabi",
|
||||||
|
"title": "Agave @ mpabi",
|
||||||
|
"timezone": "browser",
|
||||||
|
"schemaVersion": 39,
|
||||||
|
"version": 2,
|
||||||
|
"time": { "from": "now-6h", "to": "now" },
|
||||||
|
"timepicker": {
|
||||||
|
"refresh_intervals": ["5s", "10s", "30s", "1m", "5m"],
|
||||||
|
"time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d"]
|
||||||
|
},
|
||||||
|
"refresh": "10s",
|
||||||
|
"tags": ["agave", "solana", "mpabi"],
|
||||||
|
"templating": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"name": "instance",
|
||||||
|
"type": "query",
|
||||||
|
"label": "Node Exporter Instance",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"query": { "query": "label_values(up{job=\"mpabi-node-exporter\"}, instance)", "refId": "PromVarInstance" },
|
||||||
|
"current": { "selected": false, "text": "10.66.66.1:9100", "value": "10.66.66.1:9100" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"type": "stat",
|
||||||
|
"title": "Geyser Metrics Target (Prometheus up)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "A", "expr": "up{job=\"mpabi-yellowstone-geyser\"}" }],
|
||||||
|
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "orientation": "horizontal", "textMode": "value" },
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": { "thresholds": { "mode": "absolute", "steps": [{ "color": "red", "value": null }, { "color": "green", "value": 1 }] } },
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 0 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"type": "stat",
|
||||||
|
"title": "agave-validator.service (systemd active)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "B", "expr": "node_systemd_unit_state{job=\"mpabi-node-exporter\",instance=\"$instance\",name=\"agave-validator.service\",state=\"active\"}" }],
|
||||||
|
"options": { "reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false }, "orientation": "horizontal", "textMode": "value" },
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": { "thresholds": { "mode": "absolute", "steps": [{ "color": "red", "value": null }, { "color": "green", "value": 1 }] } },
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 0 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "CPU Used (%)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "C", "expr": "100 - (avg by (instance) (rate(node_cpu_seconds_total{job=\"mpabi-node-exporter\",instance=\"$instance\",mode=\"idle\"}[5m])) * 100)" }],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "percent", "min": 0, "max": 100 }, "overrides": [] },
|
||||||
|
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 6 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Load (1m)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "D", "expr": "node_load1{job=\"mpabi-node-exporter\",instance=\"$instance\"}" }],
|
||||||
|
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 6 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 5,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Memory Used (%)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "E", "expr": "100 - (node_memory_MemAvailable_bytes{job=\"mpabi-node-exporter\",instance=\"$instance\"} / node_memory_MemTotal_bytes{job=\"mpabi-node-exporter\",instance=\"$instance\"} * 100)" }],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "percent", "min": 0, "max": 100 }, "overrides": [] },
|
||||||
|
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 6 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 6,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Swap Used (GiB)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "F", "expr": "(node_memory_SwapTotal_bytes{job=\"mpabi-node-exporter\",instance=\"$instance\"} - node_memory_SwapFree_bytes{job=\"mpabi-node-exporter\",instance=\"$instance\"}) / 1024 / 1024 / 1024" }],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "gbytes" }, "overrides": [] },
|
||||||
|
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 14 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 7,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Disk Free Accounts (%)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "G", "expr": "100 * node_filesystem_avail_bytes{job=\"mpabi-node-exporter\",instance=\"$instance\",mountpoint=\"/var/lib/solana/accounts\"} / node_filesystem_size_bytes{job=\"mpabi-node-exporter\",instance=\"$instance\",mountpoint=\"/var/lib/solana/accounts\"}" }],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "percent", "min": 0, "max": 100 }, "overrides": [] },
|
||||||
|
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 14 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 8,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Disk Free Ledger (%)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "H", "expr": "100 * node_filesystem_avail_bytes{job=\"mpabi-node-exporter\",instance=\"$instance\",mountpoint=\"/var/lib/solana/ledger\"} / node_filesystem_size_bytes{job=\"mpabi-node-exporter\",instance=\"$instance\",mountpoint=\"/var/lib/solana/ledger\"}" }],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "percent", "min": 0, "max": 100 }, "overrides": [] },
|
||||||
|
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 14 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 9,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Disk IO (NVMe) Read/Write (MiB/s)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [
|
||||||
|
{ "refId": "I", "expr": "sum by (device) (rate(node_disk_read_bytes_total{job=\"mpabi-node-exporter\",instance=\"$instance\",device=~\"nvme.*\"}[5m])) / 1024 / 1024", "legendFormat": "read {{device}}" },
|
||||||
|
{ "refId": "J", "expr": "sum by (device) (rate(node_disk_written_bytes_total{job=\"mpabi-node-exporter\",instance=\"$instance\",device=~\"nvme.*\"}[5m])) / 1024 / 1024", "legendFormat": "write {{device}}" }
|
||||||
|
],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "mbytes" }, "overrides": [] },
|
||||||
|
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 22 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 10,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Network wg0 RX/TX (MiB/s)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [
|
||||||
|
{ "refId": "K", "expr": "rate(node_network_receive_bytes_total{job=\"mpabi-node-exporter\",instance=\"$instance\",device=\"wg0\"}[5m]) / 1024 / 1024", "legendFormat": "rx" },
|
||||||
|
{ "refId": "L", "expr": "rate(node_network_transmit_bytes_total{job=\"mpabi-node-exporter\",instance=\"$instance\",device=\"wg0\"}[5m]) / 1024 / 1024", "legendFormat": "tx" }
|
||||||
|
],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "mbytes" }, "overrides": [] },
|
||||||
|
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 22 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 11,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Geyser: Subscriber Queue Size",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "M", "expr": "grpc_subscriber_queue_size{job=\"mpabi-yellowstone-geyser\"}", "legendFormat": "{{subscriber_id}}" }],
|
||||||
|
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 30 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 12,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Geyser: Connections Total",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "N", "expr": "connections_total{job=\"mpabi-yellowstone-geyser\"}" }],
|
||||||
|
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 30 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 13,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Geyser: Bytes Sent (MiB/s)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "O", "expr": "rate(grpc_bytes_sent{job=\"mpabi-yellowstone-geyser\"}[5m]) / 1024 / 1024", "legendFormat": "{{subscriber_id}}" }],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "mbytes" }, "overrides": [] },
|
||||||
|
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 38 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 14,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Geyser: Messages Sent (/s)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "P", "expr": "rate(grpc_message_sent_count{job=\"mpabi-yellowstone-geyser\"}[5m])", "legendFormat": "{{subscriber_id}}" }],
|
||||||
|
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 38 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 15,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "Geyser: Disconnects (increase 15m)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "Q", "expr": "sum by (reason) (increase(grpc_client_disconnects_total{job=\"mpabi-yellowstone-geyser\"}[15m]))", "legendFormat": "{{reason}}" }],
|
||||||
|
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 46 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 16,
|
||||||
|
"type": "stat",
|
||||||
|
"title": "RPC Slot Lag (slots)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "R", "expr": "solana_rpc_slot_lag{job=\"mpabi-node-exporter\",instance=\"$instance\"}" }],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "short",
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{ "color": "green", "value": null },
|
||||||
|
{ "color": "yellow", "value": 20 },
|
||||||
|
{ "color": "red", "value": 50 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 54 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 17,
|
||||||
|
"type": "stat",
|
||||||
|
"title": "RPC Slot Lag (szac. minuty)",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [{ "refId": "S", "expr": "solana_rpc_slot_lag{job=\"mpabi-node-exporter\",instance=\"$instance\"} * 0.4 / 60" }],
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"unit": "min",
|
||||||
|
"decimals": 2,
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{ "color": "green", "value": null },
|
||||||
|
{ "color": "yellow", "value": 1 },
|
||||||
|
{ "color": "red", "value": 2 }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"overrides": []
|
||||||
|
},
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 54 }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 18,
|
||||||
|
"type": "timeseries",
|
||||||
|
"title": "RPC Slot & Reference Slot",
|
||||||
|
"datasource": { "type": "prometheus", "uid": "prometheus" },
|
||||||
|
"targets": [
|
||||||
|
{ "refId": "T", "expr": "solana_rpc_slot{job=\"mpabi-node-exporter\",instance=\"$instance\"}" },
|
||||||
|
{ "refId": "U", "expr": "solana_rpc_slot_reference{job=\"mpabi-node-exporter\",instance=\"$instance\"}" },
|
||||||
|
{ "refId": "V", "expr": "solana_rpc_block_height{job=\"mpabi-node-exporter\",instance=\"$instance\"}" }
|
||||||
|
],
|
||||||
|
"gridPos": { "h": 8, "w": 24, "x": 0, "y": 60 }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: IngressRoute
|
||||||
|
metadata:
|
||||||
|
name: grafana-http
|
||||||
|
namespace: monitoring
|
||||||
|
spec:
|
||||||
|
entryPoints:
|
||||||
|
- web
|
||||||
|
routes:
|
||||||
|
- match: Host(`grafana.mpabi.pl`)
|
||||||
|
kind: Rule
|
||||||
|
middlewares:
|
||||||
|
- name: redirect-to-https
|
||||||
|
services:
|
||||||
|
- name: monitoring-stack-grafana
|
||||||
|
port: 80
|
||||||
16
kustomize/infra/monitoring-extras/ingressroute-grafana.yaml
Normal file
16
kustomize/infra/monitoring-extras/ingressroute-grafana.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: IngressRoute
|
||||||
|
metadata:
|
||||||
|
name: grafana
|
||||||
|
namespace: monitoring
|
||||||
|
spec:
|
||||||
|
entryPoints:
|
||||||
|
- websecure
|
||||||
|
routes:
|
||||||
|
- match: Host(`grafana.mpabi.pl`)
|
||||||
|
kind: Rule
|
||||||
|
services:
|
||||||
|
- name: monitoring-stack-grafana
|
||||||
|
port: 80
|
||||||
|
tls:
|
||||||
|
secretName: monitoring-mpabi-pl-tls
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: IngressRoute
|
||||||
|
metadata:
|
||||||
|
name: prometheus-http
|
||||||
|
namespace: monitoring
|
||||||
|
spec:
|
||||||
|
entryPoints:
|
||||||
|
- web
|
||||||
|
routes:
|
||||||
|
- match: Host(`prometheus.mpabi.pl`)
|
||||||
|
kind: Rule
|
||||||
|
middlewares:
|
||||||
|
- name: redirect-to-https
|
||||||
|
services:
|
||||||
|
- name: monitoring-stack-kube-prom-prometheus
|
||||||
|
port: 9090
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: IngressRoute
|
||||||
|
metadata:
|
||||||
|
name: prometheus
|
||||||
|
namespace: monitoring
|
||||||
|
spec:
|
||||||
|
entryPoints:
|
||||||
|
- websecure
|
||||||
|
routes:
|
||||||
|
- match: Host(`prometheus.mpabi.pl`)
|
||||||
|
kind: Rule
|
||||||
|
services:
|
||||||
|
- name: monitoring-stack-kube-prom-prometheus
|
||||||
|
port: 9090
|
||||||
|
tls:
|
||||||
|
secretName: monitoring-mpabi-pl-tls
|
||||||
11
kustomize/infra/monitoring-extras/kustomization.yaml
Normal file
11
kustomize/infra/monitoring-extras/kustomization.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- middleware-redirect-to-https.yaml
|
||||||
|
- certificate-monitoring-mpabi-pl.yaml
|
||||||
|
- ingressroute-grafana.yaml
|
||||||
|
- ingressroute-grafana-http.yaml
|
||||||
|
- ingressroute-prometheus.yaml
|
||||||
|
- ingressroute-prometheus-http.yaml
|
||||||
|
- dashboard-agave-status.yaml
|
||||||
|
- prometheus-rules-agave.yaml
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
apiVersion: traefik.io/v1alpha1
|
||||||
|
kind: Middleware
|
||||||
|
metadata:
|
||||||
|
name: redirect-to-https
|
||||||
|
namespace: monitoring
|
||||||
|
spec:
|
||||||
|
redirectScheme:
|
||||||
|
scheme: https
|
||||||
|
permanent: true
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
apiVersion: monitoring.coreos.com/v1
|
||||||
|
kind: PrometheusRule
|
||||||
|
metadata:
|
||||||
|
name: agave-rpc-alerts
|
||||||
|
namespace: monitoring
|
||||||
|
labels:
|
||||||
|
app: kube-prometheus-stack
|
||||||
|
release: monitoring-stack
|
||||||
|
spec:
|
||||||
|
groups:
|
||||||
|
- name: agave-rpc-health
|
||||||
|
rules:
|
||||||
|
- alert: AgaveRPCDown
|
||||||
|
expr: "max by (instance) (solana_rpc_up{job=\"mpabi-node-exporter\"}) == 0"
|
||||||
|
for: 30s
|
||||||
|
labels:
|
||||||
|
severity: critical
|
||||||
|
team: mpabi
|
||||||
|
annotations:
|
||||||
|
summary: "Agave RPC is unreachable"
|
||||||
|
description: "RPC probe from node exporter reports solana_rpc_up == 0 for instance {{ $labels.instance }}."
|
||||||
|
- alert: AgaveRPCSlotLagHigh
|
||||||
|
expr: "sum by (instance) (solana_rpc_slot_lag{job=\"mpabi-node-exporter\"}) > 50"
|
||||||
|
for: 2m
|
||||||
|
labels:
|
||||||
|
severity: warning
|
||||||
|
team: mpabi
|
||||||
|
annotations:
|
||||||
|
summary: "Agave RPC is lagging behind cluster"
|
||||||
|
description: "Current slot lag is {{ $value }} for instance {{ $labels.instance }}. Reference endpoint in probe config may be misconfigured or validator is behind."
|
||||||
|
- alert: AgaveRPCSlotLagCritical
|
||||||
|
expr: "sum by (instance) (solana_rpc_slot_lag{job=\"mpabi-node-exporter\"}) > 500"
|
||||||
|
for: 2m
|
||||||
|
labels:
|
||||||
|
severity: critical
|
||||||
|
team: mpabi
|
||||||
|
annotations:
|
||||||
|
summary: "Agave RPC severe lag"
|
||||||
|
description: "Slot lag is critically high ({{ $value }} slots) on instance {{ $labels.instance }}."
|
||||||
|
- alert: AgaveIOHigh
|
||||||
|
expr: |
|
||||||
|
sum by (instance) (
|
||||||
|
(rate(node_disk_read_bytes_total{job="mpabi-node-exporter",device=~"nvme.*"}[5m]) +
|
||||||
|
rate(node_disk_written_bytes_total{job="mpabi-node-exporter",device=~"nvme.*"}[5m])) / 1024 / 1024
|
||||||
|
) > 300
|
||||||
|
for: 5m
|
||||||
|
labels:
|
||||||
|
severity: warning
|
||||||
|
team: mpabi
|
||||||
|
annotations:
|
||||||
|
summary: "High storage I/O on Agave node"
|
||||||
|
description: "Combined NVMe read+write throughput >300 MiB/s for 5m on {{ $labels.instance }}. Check disk pressure and Geyser/ledger workload."
|
||||||
|
- alert: AgaveIOWaitHigh
|
||||||
|
expr: "avg by (instance) (rate(node_cpu_seconds_total{job=\"mpabi-node-exporter\",mode=\"iowait\"}[5m])) > 0.2"
|
||||||
|
for: 5m
|
||||||
|
labels:
|
||||||
|
severity: warning
|
||||||
|
team: mpabi
|
||||||
|
annotations:
|
||||||
|
summary: "High iowait on Agave node"
|
||||||
|
description: "Iowait over 20% on average for 5m on {{ $labels.instance }}. Storage latency is likely impacting slot progress."
|
||||||
49
kustomize/overlays/mevnode-bot/README.md
Normal file
49
kustomize/overlays/mevnode-bot/README.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# mevnode-bot overlay
|
||||||
|
|
||||||
|
To jest docelowy overlay dla runtime `mevnode_bot`.
|
||||||
|
|
||||||
|
Zakres:
|
||||||
|
|
||||||
|
- `postgres`
|
||||||
|
- `hasura`
|
||||||
|
- `trade-api`
|
||||||
|
- `trade-frontend` (`NodePort 30081`)
|
||||||
|
- `trade-ingestor`
|
||||||
|
- `dlob-redis`
|
||||||
|
- `dlob-publisher`
|
||||||
|
- `dlob-server`
|
||||||
|
- `dlob-worker`
|
||||||
|
- `dlob-depth-worker`
|
||||||
|
- `dlob-slippage-worker`
|
||||||
|
|
||||||
|
Założenia runtime:
|
||||||
|
|
||||||
|
- `mevnode_sol` wystawia po `wg0`:
|
||||||
|
- `RPC`: `http://10.91.0.1:8899`
|
||||||
|
- `WS`: `ws://10.91.0.1:8900`
|
||||||
|
- `Yellowstone`: `http://10.91.0.1:10000`
|
||||||
|
- `mevnode_bot` uruchamia tylko warstwę aplikacyjną.
|
||||||
|
- `trade-frontend` jest wystawiany przez `NodePort 30081`.
|
||||||
|
- Namespace pozostaje `trade-staging`.
|
||||||
|
|
||||||
|
Wymagane sekrety:
|
||||||
|
|
||||||
|
- `trade-postgres`
|
||||||
|
- `trade-hasura`
|
||||||
|
- `trade-api`
|
||||||
|
- `trade-frontend-tokens`
|
||||||
|
- `trade-dlob-rpc`
|
||||||
|
|
||||||
|
Opcjonalne:
|
||||||
|
|
||||||
|
- `gitea-registry` nie jest tu wymagane, bo overlay czyści `imagePullSecrets`.
|
||||||
|
|
||||||
|
Uwagi:
|
||||||
|
|
||||||
|
- Overlay zastępuje lokalny `_tmp/bot-rx-stack`.
|
||||||
|
- `trade-deploy/kustomize/overlays/mevnode-bot` jest teraz źródłem prawdy dla runtime `mevnode_bot`.
|
||||||
|
- Ten overlay nadal korzysta z plików z `../../base` w `configMapGenerator`, więc przy lokalnym `kustomize` może być potrzebne:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo k3s kubectl kustomize trade-deploy/kustomize/overlays/mevnode-bot --load-restrictor LoadRestrictionsNone | sudo k3s kubectl apply -f -
|
||||||
|
```
|
||||||
219
kustomize/overlays/mevnode-bot/dlob-ingestor.mjs
Normal file
219
kustomize/overlays/mevnode-bot/dlob-ingestor.mjs
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
import process from 'node:process';
|
||||||
|
import { setTimeout as sleep } from 'node:timers/promises';
|
||||||
|
|
||||||
|
function getIsoNow() {
|
||||||
|
return new Date().toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function envString(name, fallback) {
|
||||||
|
const v = process.env[name];
|
||||||
|
if (v == null) return fallback;
|
||||||
|
const s = String(v).trim();
|
||||||
|
return s ? s : fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
function envInt(name, fallback, { min, max } = {}) {
|
||||||
|
const v = process.env[name];
|
||||||
|
if (v == null) return fallback;
|
||||||
|
const n = Number.parseInt(String(v), 10);
|
||||||
|
if (!Number.isFinite(n)) return fallback;
|
||||||
|
const low = typeof min === 'number' ? min : n;
|
||||||
|
const high = typeof max === 'number' ? max : n;
|
||||||
|
return Math.max(low, Math.min(high, n));
|
||||||
|
}
|
||||||
|
|
||||||
|
function envList(name, fallbackCsv) {
|
||||||
|
const raw = process.env[name] ?? fallbackCsv;
|
||||||
|
return String(raw)
|
||||||
|
.split(',')
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
function toIntOrNull(v) {
|
||||||
|
if (v == null) return null;
|
||||||
|
if (typeof v === 'number') return Number.isFinite(v) ? Math.trunc(v) : null;
|
||||||
|
if (typeof v === 'string') {
|
||||||
|
const s = v.trim();
|
||||||
|
if (!s) return null;
|
||||||
|
const n = Number.parseInt(s, 10);
|
||||||
|
return Number.isFinite(n) ? n : null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function numStr(v) {
|
||||||
|
if (v == null) return null;
|
||||||
|
if (typeof v === 'number') return Number.isFinite(v) ? String(v) : null;
|
||||||
|
if (typeof v === 'string') {
|
||||||
|
const s = v.trim();
|
||||||
|
return s ? s : null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isoFromEpochMs(v) {
|
||||||
|
const n = typeof v === 'number' ? v : typeof v === 'string' ? Number(v.trim()) : NaN;
|
||||||
|
if (!Number.isFinite(n) || n <= 0) return null;
|
||||||
|
const d = new Date(n);
|
||||||
|
const ms = d.getTime();
|
||||||
|
if (!Number.isFinite(ms)) return null;
|
||||||
|
return d.toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveConfig() {
|
||||||
|
const hasuraUrl = envString('HASURA_GRAPHQL_URL', 'http://hasura:8080/v1/graphql');
|
||||||
|
const hasuraAdminSecret = envString('HASURA_ADMIN_SECRET', '');
|
||||||
|
if (!hasuraAdminSecret) throw new Error('Missing HASURA_ADMIN_SECRET');
|
||||||
|
|
||||||
|
const markets = envList('DLOB_MARKETS', 'SOL-PERP,PUMP-PERP');
|
||||||
|
const pollMs = envInt('TICKS_POLL_MS', 1000, { min: 250, max: 60000 });
|
||||||
|
const source = envString('TICKS_SOURCE', 'dlob_stats');
|
||||||
|
|
||||||
|
return { hasuraUrl, hasuraAdminSecret, markets, pollMs, source };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function graphqlRequest(cfg, query, variables) {
|
||||||
|
const res = await fetch(cfg.hasuraUrl, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'content-type': 'application/json',
|
||||||
|
'x-hasura-admin-secret': cfg.hasuraAdminSecret,
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ query, variables }),
|
||||||
|
signal: AbortSignal.timeout(10000),
|
||||||
|
});
|
||||||
|
|
||||||
|
const text = await res.text();
|
||||||
|
if (!res.ok) throw new Error(`Hasura HTTP ${res.status}: ${text}`);
|
||||||
|
|
||||||
|
let json;
|
||||||
|
try {
|
||||||
|
json = JSON.parse(text);
|
||||||
|
} catch {
|
||||||
|
throw new Error(`Hasura: invalid json: ${text}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json.errors?.length) throw new Error(json.errors.map((e) => e.message).join(' | '));
|
||||||
|
return json.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchStats(cfg) {
|
||||||
|
const query = `
|
||||||
|
query DlobStatsLatest($markets: [String!]!) {
|
||||||
|
dlob_stats_latest(where: { market_name: { _in: $markets } }) {
|
||||||
|
market_name
|
||||||
|
market_index
|
||||||
|
ts
|
||||||
|
slot
|
||||||
|
oracle_price
|
||||||
|
mark_price
|
||||||
|
mid_price
|
||||||
|
best_bid_price
|
||||||
|
best_ask_price
|
||||||
|
updated_at
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const data = await graphqlRequest(cfg, query, { markets: cfg.markets });
|
||||||
|
const rows = Array.isArray(data?.dlob_stats_latest) ? data.dlob_stats_latest : [];
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function insertTicks(cfg, objects) {
|
||||||
|
if (!objects.length) return 0;
|
||||||
|
|
||||||
|
const mutation = `
|
||||||
|
mutation InsertTicks($objects: [drift_ticks_insert_input!]!) {
|
||||||
|
insert_drift_ticks(objects: $objects) { affected_rows }
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const data = await graphqlRequest(cfg, mutation, { objects });
|
||||||
|
return Number(data?.insert_drift_ticks?.affected_rows || 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const cfg = resolveConfig();
|
||||||
|
const lastUpdatedAtByMarket = new Map();
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
JSON.stringify(
|
||||||
|
{
|
||||||
|
service: 'trade-ingestor',
|
||||||
|
mode: 'dlob_stats_ticks',
|
||||||
|
startedAt: getIsoNow(),
|
||||||
|
hasuraUrl: cfg.hasuraUrl,
|
||||||
|
markets: cfg.markets,
|
||||||
|
pollMs: cfg.pollMs,
|
||||||
|
source: cfg.source,
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
const rows = await fetchStats(cfg);
|
||||||
|
const nowIso = getIsoNow();
|
||||||
|
|
||||||
|
const objects = [];
|
||||||
|
for (const r of rows) {
|
||||||
|
const marketName = String(r?.market_name || '').trim();
|
||||||
|
if (!marketName) continue;
|
||||||
|
|
||||||
|
const updatedAt = r?.updated_at ? String(r.updated_at) : '';
|
||||||
|
if (updatedAt && lastUpdatedAtByMarket.get(marketName) === updatedAt) continue;
|
||||||
|
if (updatedAt) lastUpdatedAtByMarket.set(marketName, updatedAt);
|
||||||
|
|
||||||
|
const marketIndex = toIntOrNull(r?.market_index) ?? 0;
|
||||||
|
const dlobIso = isoFromEpochMs(r?.ts);
|
||||||
|
const tsIso = dlobIso || nowIso;
|
||||||
|
|
||||||
|
const oraclePrice = numStr(r?.oracle_price) || numStr(r?.mark_price) || numStr(r?.mid_price);
|
||||||
|
const markPrice = numStr(r?.mark_price) || numStr(r?.mid_price) || oraclePrice;
|
||||||
|
if (!oraclePrice) continue;
|
||||||
|
|
||||||
|
objects.push({
|
||||||
|
ts: tsIso,
|
||||||
|
market_index: marketIndex,
|
||||||
|
symbol: marketName,
|
||||||
|
oracle_price: oraclePrice,
|
||||||
|
mark_price: markPrice,
|
||||||
|
oracle_slot: r?.slot == null ? null : String(r.slot),
|
||||||
|
source: cfg.source,
|
||||||
|
raw: {
|
||||||
|
from: 'dlob_stats_latest',
|
||||||
|
market_name: marketName,
|
||||||
|
market_index: marketIndex,
|
||||||
|
dlob: {
|
||||||
|
ts: r?.ts ?? null,
|
||||||
|
slot: r?.slot ?? null,
|
||||||
|
best_bid_price: r?.best_bid_price ?? null,
|
||||||
|
best_ask_price: r?.best_ask_price ?? null,
|
||||||
|
mid_price: r?.mid_price ?? null,
|
||||||
|
updated_at: updatedAt || null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const inserted = await insertTicks(cfg, objects);
|
||||||
|
if (inserted) {
|
||||||
|
console.log(`[dlob-ticks] inserted=${inserted} ts=${nowIso}`);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`[dlob-ticks] error: ${String(err?.message || err)}`);
|
||||||
|
await sleep(2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
await sleep(cfg.pollMs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error(String(err?.stack || err));
|
||||||
|
process.exitCode = 1;
|
||||||
|
});
|
||||||
67
kustomize/overlays/mevnode-bot/kustomization.yaml
Normal file
67
kustomize/overlays/mevnode-bot/kustomization.yaml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
namespace: trade-staging
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- ../../base/cm-trade-deploy.yaml
|
||||||
|
- ../../base/postgres/service.yaml
|
||||||
|
- ../../base/postgres/statefulset.yaml
|
||||||
|
- ../../base/postgres/job-migrate.yaml
|
||||||
|
- ../../base/hasura/service.yaml
|
||||||
|
- ../../base/hasura/deployment.yaml
|
||||||
|
- ../../base/hasura/job-bootstrap.yaml
|
||||||
|
- ../../base/api/service.yaml
|
||||||
|
- ../../base/api/deployment.yaml
|
||||||
|
- ../../base/ingestor/deployment.yaml
|
||||||
|
- ../../base/frontend/service.yaml
|
||||||
|
- ../../base/frontend/deployment.yaml
|
||||||
|
- ../../base/dlob/redis.yaml
|
||||||
|
- ../../base/dlob/publisher-deployment.yaml
|
||||||
|
- ../../base/dlob/server-service.yaml
|
||||||
|
- ../../base/dlob/server-deployment.yaml
|
||||||
|
- ../../base/dlob-worker/deployment.yaml
|
||||||
|
- ../../base/dlob-depth-worker/deployment.yaml
|
||||||
|
- ../../base/dlob-slippage-worker/deployment.yaml
|
||||||
|
|
||||||
|
patchesStrategicMerge:
|
||||||
|
- patch-api.yaml
|
||||||
|
- patch-frontend.yaml
|
||||||
|
- patch-frontend-service.yaml
|
||||||
|
- patch-ingestor.yaml
|
||||||
|
- patch-dlob-publisher.yaml
|
||||||
|
- patch-dlob-publisher-storage.yaml
|
||||||
|
- patch-dlob-server.yaml
|
||||||
|
- patch-dlob-worker.yaml
|
||||||
|
- patch-dlob-depth-worker.yaml
|
||||||
|
- patch-dlob-slippage-worker.yaml
|
||||||
|
|
||||||
|
configMapGenerator:
|
||||||
|
- name: postgres-initdb
|
||||||
|
files:
|
||||||
|
- ../../base/initdb/001_init.sql
|
||||||
|
- name: hasura-bootstrap-script
|
||||||
|
files:
|
||||||
|
- ../../base/hasura/hasura-bootstrap.mjs
|
||||||
|
- name: trade-api-wrapper
|
||||||
|
files:
|
||||||
|
- ../../base/api/wrapper.mjs
|
||||||
|
- name: trade-api-upstream
|
||||||
|
files:
|
||||||
|
- ../../base/api/server.mjs
|
||||||
|
- name: dlob-worker-script
|
||||||
|
files:
|
||||||
|
- ../../base/dlob-worker/worker.mjs
|
||||||
|
- name: dlob-depth-worker-script
|
||||||
|
files:
|
||||||
|
- ../../base/dlob-depth-worker/worker.mjs
|
||||||
|
- name: dlob-slippage-worker-script
|
||||||
|
files:
|
||||||
|
- ../../base/dlob-slippage-worker/worker.mjs
|
||||||
|
- name: trade-dlob-ingestor-script
|
||||||
|
files:
|
||||||
|
- dlob-ingestor.mjs
|
||||||
|
|
||||||
|
generatorOptions:
|
||||||
|
disableNameSuffixHash: true
|
||||||
4
kustomize/overlays/mevnode-bot/namespace.yaml
Normal file
4
kustomize/overlays/mevnode-bot/namespace.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: trade-staging
|
||||||
8
kustomize/overlays/mevnode-bot/patch-api.yaml
Normal file
8
kustomize/overlays/mevnode-bot/patch-api.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: trade-api
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
imagePullSecrets: []
|
||||||
12
kustomize/overlays/mevnode-bot/patch-dlob-depth-worker.yaml
Normal file
12
kustomize/overlays/mevnode-bot/patch-dlob-depth-worker.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: dlob-depth-worker
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: worker
|
||||||
|
env:
|
||||||
|
- name: DLOB_MARKETS
|
||||||
|
value: SOL-PERP,PUMP-PERP
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: dlob-publisher
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: publisher
|
||||||
|
env:
|
||||||
|
- name: ENABLE_PERSISTENT_STORE
|
||||||
|
value: "true"
|
||||||
|
- name: DLOB_SOURCE
|
||||||
|
value: "mevnode_bot"
|
||||||
|
- name: PRICE_PRECISION
|
||||||
|
value: "1000000"
|
||||||
|
- name: BASE_PRECISION
|
||||||
|
value: "1000000000"
|
||||||
|
- name: PERSISTENT_STATS_DEPTH
|
||||||
|
value: "10"
|
||||||
|
- name: PGHOST
|
||||||
|
value: postgres
|
||||||
|
- name: PGPORT
|
||||||
|
value: "5432"
|
||||||
|
- name: PGUSER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: trade-postgres
|
||||||
|
key: POSTGRES_USER
|
||||||
|
- name: PGPASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: trade-postgres
|
||||||
|
key: POSTGRES_PASSWORD
|
||||||
|
- name: PGDATABASE
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: trade-postgres
|
||||||
|
key: POSTGRES_DB
|
||||||
31
kustomize/overlays/mevnode-bot/patch-dlob-publisher.yaml
Normal file
31
kustomize/overlays/mevnode-bot/patch-dlob-publisher.yaml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: dlob-publisher
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
imagePullSecrets: []
|
||||||
|
containers:
|
||||||
|
- name: publisher
|
||||||
|
env:
|
||||||
|
- name: PERP_MARKETS_TO_LOAD
|
||||||
|
value: "0,75"
|
||||||
|
- name: USE_GRPC
|
||||||
|
value: "true"
|
||||||
|
- name: USE_WEBSOCKET
|
||||||
|
value: "true"
|
||||||
|
- name: DISABLE_GPA_REFRESH
|
||||||
|
value: "true"
|
||||||
|
- name: GRPC_CLIENT
|
||||||
|
value: "yellowstone"
|
||||||
|
- name: GRPC_ENDPOINT
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: trade-dlob-rpc
|
||||||
|
key: GRPC_ENDPOINT
|
||||||
|
- name: TOKEN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: trade-dlob-rpc
|
||||||
|
key: TOKEN
|
||||||
8
kustomize/overlays/mevnode-bot/patch-dlob-server.yaml
Normal file
8
kustomize/overlays/mevnode-bot/patch-dlob-server.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: dlob-server
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
imagePullSecrets: []
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: dlob-slippage-worker
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: worker
|
||||||
|
env:
|
||||||
|
- name: DLOB_MARKETS
|
||||||
|
value: SOL-PERP,PUMP-PERP
|
||||||
12
kustomize/overlays/mevnode-bot/patch-dlob-worker.yaml
Normal file
12
kustomize/overlays/mevnode-bot/patch-dlob-worker.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: dlob-worker
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: worker
|
||||||
|
env:
|
||||||
|
- name: DLOB_MARKETS
|
||||||
|
value: SOL-PERP,PUMP-PERP
|
||||||
11
kustomize/overlays/mevnode-bot/patch-frontend-service.yaml
Normal file
11
kustomize/overlays/mevnode-bot/patch-frontend-service.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: trade-frontend
|
||||||
|
spec:
|
||||||
|
type: NodePort
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 8081
|
||||||
|
targetPort: http
|
||||||
|
nodePort: 30081
|
||||||
8
kustomize/overlays/mevnode-bot/patch-frontend.yaml
Normal file
8
kustomize/overlays/mevnode-bot/patch-frontend.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: trade-frontend
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
imagePullSecrets: []
|
||||||
39
kustomize/overlays/mevnode-bot/patch-ingestor.yaml
Normal file
39
kustomize/overlays/mevnode-bot/patch-ingestor.yaml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: trade-ingestor
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
imagePullSecrets: []
|
||||||
|
containers:
|
||||||
|
- name: ingestor
|
||||||
|
image: node:20-slim
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: HASURA_GRAPHQL_URL
|
||||||
|
value: http://hasura:8080/v1/graphql
|
||||||
|
- name: HASURA_ADMIN_SECRET
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: trade-hasura
|
||||||
|
key: HASURA_GRAPHQL_ADMIN_SECRET
|
||||||
|
- name: DLOB_MARKETS
|
||||||
|
value: SOL-PERP,PUMP-PERP
|
||||||
|
- name: TICKS_POLL_MS
|
||||||
|
value: "1000"
|
||||||
|
- name: TICKS_SOURCE
|
||||||
|
value: "dlob_stats"
|
||||||
|
command:
|
||||||
|
- node
|
||||||
|
args:
|
||||||
|
- /opt/dlob/dlob-ingestor.mjs
|
||||||
|
volumeMounts:
|
||||||
|
- name: dlob-script
|
||||||
|
mountPath: /opt/dlob/dlob-ingestor.mjs
|
||||||
|
subPath: dlob-ingestor.mjs
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: dlob-script
|
||||||
|
configMap:
|
||||||
|
name: trade-dlob-ingestor-script
|
||||||
@@ -66,7 +66,7 @@ function resolveConfig() {
|
|||||||
const hasuraAdminSecret = envString('HASURA_ADMIN_SECRET', '');
|
const hasuraAdminSecret = envString('HASURA_ADMIN_SECRET', '');
|
||||||
if (!hasuraAdminSecret) throw new Error('Missing HASURA_ADMIN_SECRET');
|
if (!hasuraAdminSecret) throw new Error('Missing HASURA_ADMIN_SECRET');
|
||||||
|
|
||||||
const markets = envList('DLOB_MARKETS', 'PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP');
|
const markets = envList('DLOB_MARKETS', 'SOL-PERP,DOGE-PERP,JUP-PERP');
|
||||||
const pollMs = envInt('TICKS_POLL_MS', 1000, { min: 250, max: 60_000 });
|
const pollMs = envInt('TICKS_POLL_MS', 1000, { min: 250, max: 60_000 });
|
||||||
const source = envString('TICKS_SOURCE', 'dlob_stats');
|
const source = envString('TICKS_SOURCE', 'dlob_stats');
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ spec:
|
|||||||
name: trade-hasura
|
name: trade-hasura
|
||||||
key: HASURA_GRAPHQL_ADMIN_SECRET
|
key: HASURA_GRAPHQL_ADMIN_SECRET
|
||||||
- name: DLOB_MARKETS
|
- name: DLOB_MARKETS
|
||||||
value: PUMP-PERP,SOL-PERP,1MBONK-PERP,BTC-PERP,ETH-PERP
|
value: SOL-PERP,DOGE-PERP,JUP-PERP
|
||||||
- name: TICKS_POLL_MS
|
- name: TICKS_POLL_MS
|
||||||
value: "1000"
|
value: "1000"
|
||||||
- name: TICKS_SOURCE
|
- name: TICKS_SOURCE
|
||||||
|
|||||||
Reference in New Issue
Block a user