diff --git a/apps/indexer-coordinator/package.json b/apps/indexer-coordinator/package.json index 23e81ccf..de30521b 100644 --- a/apps/indexer-coordinator/package.json +++ b/apps/indexer-coordinator/package.json @@ -1,6 +1,6 @@ { "name": "@subql/indexer-coordinator", - "version": "2.8.2-1", + "version": "2.8.2", "description": "", "author": "SubQuery", "license": "Apache-2.0", diff --git a/apps/indexer-coordinator/src/project/project.rpc.service.ts b/apps/indexer-coordinator/src/project/project.rpc.service.ts index d8e5ea51..970a6e86 100644 --- a/apps/indexer-coordinator/src/project/project.rpc.service.ts +++ b/apps/indexer-coordinator/src/project/project.rpc.service.ts @@ -267,7 +267,7 @@ export class ProjectRpcService implements OnModuleInit { .validate(endpoint, endpointKey as RpcEndpointType); return this.formatResponse(true); } catch (e) { - logger.debug(e); + logger.debug(`${e}`); return this.formatResponse(false, e.message, e.level || ErrorLevel.error); } } diff --git a/apps/indexer-coordinator/src/project/rpc.factory.ts b/apps/indexer-coordinator/src/project/rpc.factory.ts index 20c147b1..8c742130 100644 --- a/apps/indexer-coordinator/src/project/rpc.factory.ts +++ b/apps/indexer-coordinator/src/project/rpc.factory.ts @@ -264,8 +264,15 @@ export class RpcFamilyEvm extends RpcFamily { throw new ValidateRpcEndpointError(`Request metrics failed: ${result.error}`, errorLevel); } if (typeof result.data === 'object') { - const info = safeJSONParse(result.data['chain/info']); - chainIdFromRpc = info?.chain_id; + // eth + if ('chain/info' in result.data) { + const info = safeJSONParse(result.data['chain/info']); + chainIdFromRpc = info?.chain_id; + } + // autonity + if ('p2p/acn/peers' in result.data) { + chainIdFromRpc = chainId; + } } else { const metricsObj = parseMetrics(result.data); if (metricsObj.mType === MetricsType.GETH_PROMETHEUS) { @@ -392,6 +399,7 @@ export class RpcFamilyEvm extends RpcFamily { const metricsObj = parseMetrics(result.data); switch (metricsObj.mType) { case MetricsType.GETH_PROMETHEUS: + case MetricsType.AUTONITY_PROMETHEUS: headBlock = metricsObj.chain_head_block; errorMsg = 'incorrect head block'; break; diff --git a/apps/indexer-coordinator/src/utils/metrics.ts b/apps/indexer-coordinator/src/utils/metrics.ts index a877c1f5..003364a1 100644 --- a/apps/indexer-coordinator/src/utils/metrics.ts +++ b/apps/indexer-coordinator/src/utils/metrics.ts @@ -8,6 +8,7 @@ export enum MetricsType { NETHERMIND_PROMETHEUS = 'nethermind_prom', RETH_PROMETHEUS = 'reth_prom', BESU_PROMETHEUS = 'besu_prom', + AUTONITY_PROMETHEUS = 'auto_prom', } function extractFromBrace(content: string) { @@ -37,6 +38,8 @@ export type MetricsData = { // geth chain_id?: string; + + // geth & autonity chain_head_block?: string; // erigon @@ -52,6 +55,9 @@ export type MetricsData = { // besu & nethermind ethereum_blockchain_height?: string; + + // autonity + p2p_acn_peers?: string; }; // eslint-disable-next-line complexity @@ -168,6 +174,20 @@ export function parseMetrics(metrics: string): MetricsData { Object.assign(parsedData, blocksInfo); } } + + // autonity + if (lines[i].startsWith('# TYPE p2p_acn_peers gauge')) { + mType = MetricsType.AUTONITY_PROMETHEUS; + /** + # TYPE p2p_acn_peers gauge + p2p_acn_peers 0 + */ + const next = lines[i + 1] || ''; + if (next.startsWith('p2p_acn_peers')) { + const peerInfo = extractFromGauge(next); + Object.assign(parsedData, peerInfo); + } + } } parsedData.mType = mType;