diff --git a/package-lock.json b/package-lock.json index 804a974..8dcd223 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "monaco-editor": "^0.50.0", "pinia": "^2.1.7", "pinia-plugin-persistedstate": "^3.2.1", + "pretty-bytes": "^6.1.1", "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#v1", "tauri-plugin-system-info-api": "^1.0.2", "ulidx": "^2.3.0", @@ -6894,6 +6895,17 @@ "node": ">=6.0.0" } }, + "node_modules/pretty-bytes": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-6.1.1.tgz", + "integrity": "sha512-mQUvGU6aUFQ+rNvTIAcZuWGRT9a6f6Yrg9bHs4ImKF+HZCEK+plBvnAZYSIQztknZF2qnzNtr6F8s0+IuptdlQ==", + "engines": { + "node": "^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", diff --git a/package.json b/package.json index 5628e63..4607ce3 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "monaco-editor": "^0.50.0", "pinia": "^2.1.7", "pinia-plugin-persistedstate": "^3.2.1", + "pretty-bytes": "^6.1.1", "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store#v1", "tauri-plugin-system-info-api": "^1.0.2", "ulidx": "^2.3.0", diff --git a/src/store/connectionStore.ts b/src/store/connectionStore.ts index 2159fcc..a090836 100644 --- a/src/store/connectionStore.ts +++ b/src/store/connectionStore.ts @@ -2,211 +2,30 @@ import { defineStore } from 'pinia'; import { pureObject } from '../common'; import { loadHttpClient, storeApi } from '../datasources'; -export type RawClusterState = { +export type RawClusterStats = { cluster_name: string; cluster_uuid: string; - version: number; - state_uuid: string; - master_node: string; + status: string; nodes: { - [nodeId: string]: { - name: string; - ephemeral_id: string; - transport_address: string; - external_id: string; - attributes: { - zone_id: string; - 'ml.allocated_processors_double': string; - 'ml.allocated_processors': string; - zone: string; - 'ml.machine_memory': string; - 'xpack.installed': string; - 'ml.max_jvm_size': string; - }; - roles: Array; - version: string; - }; - }; - transport_versions: Array<{ node_id: string; transport_version: string }>; - metadata: { - cluster_uuid: string; - cluster_uuid_committed: boolean; - cluster_coordination: { - term: number; - last_committed_config: Array; - last_accepted_config: Array; - voting_config_exclusions: Array; - }; - templates: { - [key: string]: unknown; - }; - indices: { - [key: string]: unknown; - }; - ingest: { - [key: string]: unknown; - }; - data_stream: { - [key: string]: unknown; - }; - component_template: { - [key: string]: unknown; - }; - index_template: { - [key: string]: unknown; - }; - repositories: { - [key: string]: unknown; - }; - 'index-graveyard': { - [key: string]: unknown; - }; - persistent_tasks: { - [key: string]: unknown; - }; - index_lifecycle: { - [key: string]: unknown; - }; - reserved_state: { - [key: string]: unknown; - }; - }; - routing_table: { - indices: { - [key: string]: { - shards: { - [key: string]: Array<{ - state: string; - primary: boolean; - node: string; - relocating_node: string; - shard: number; - index: string; - allocation_id: { - id: string; - }; - recovery_source: { - type: string; - index: { - uuid: string; - name: string; - }; - node: { - id: string; - }; - restore_source: { - repository: string; - snapshot: string; - }; - }; - unassigned_info: { - reason: string; - }; - allocation: { - id: { - id: string; - }; - }; - }>; - }; - }; + count: { + total: number; + master: number; + data: number; }; }; - routing_nodes: { - unassigned: Array<{ - state: string; - primary: boolean; - node: string; - relocating_node: string; - shard: number; - index: string; - allocation_id: { - id: string; - }; - recovery_source: { - type: string; - index: { - uuid: string; - name: string; - }; - node: { - id: string; - }; - restore_source: { - repository: string; - snapshot: string; - }; - }; - unassigned_info: { - reason: string; - }; - allocation: { - id: { - id: string; - }; - }; - }>; - nodes: { - [key: string]: { - node: string; - shards: { - [key: string]: Array<{ - state: string; - primary: boolean; - node: string; - relocating_node: string; - shard: number; - index: string; - allocation_id: { - id: string; - }; - recovery_source: { - type: string; - index: { - uuid: string; - name: string; - }; - node: { - id: string; - }; - restore_source: { - repository: string; - snapshot: string; - }; - }; - unassigned_info: { - reason: string; - }; - allocation: { - id: { - id: string; - }; - }; - }>; - }; - }; + indices: { + count: number; + shards: { + total: number; + primaries: number; }; - }; - snapshots: { - [key: string]: unknown; - }; - health: { - disk: { - high_watermark: string; - high_max_headroom: string; - flood_stage_watermark: string; - flood_stage_max_headroom: string; - frozen_flood_stage_watermark: string; - frozen_flood_stage_max_headroom: string; + docs: { + count: number; }; - shard_limits: { - max_shards_per_node: number; - max_shards_per_node_frozen: number; + store: { + size_in_bytes: number; }; }; - snapshot_deletions: { - snapshot_deletions: Array; - }; }; export type Connection = { @@ -218,7 +37,7 @@ export type Connection = { sslCertVerification: boolean; password?: string; queryParameters?: string; - rawClusterState?: RawClusterState; + rawClusterState?: RawClusterStats; }; export type ConnectionIndex = { health: string; @@ -276,9 +95,9 @@ export const useConnectionStore = defineStore('connectionStore', { if (!this.established) return; const client = loadHttpClient(this.established as Connection); this.established.rawClusterState = (await client.get( - '/_cluster/state', + '/_cluster/stats', 'format=json', - )) as RawClusterState; + )) as RawClusterStats; }, async testConnection(con: Connection) { const client = loadHttpClient(con); diff --git a/src/views/manage/components/cluster-state.vue b/src/views/manage/components/cluster-state.vue index f26f317..674c655 100644 --- a/src/views/manage/components/cluster-state.vue +++ b/src/views/manage/components/cluster-state.vue @@ -9,55 +9,35 @@

id: {{ props.cluster?.cluster_uuid }}

-

{{ $t('manage.nodes') }}: {{ clusterState.cluster.count }}

-

master: {{ clusterState.cluster.masterNode }}

-

data: {{ clusterState.cluster.dataNode }}

+

{{ $t('manage.nodes') }}: {{ props.cluster?.nodes.count.total }}

+

master: {{ props.cluster?.nodes.count.master }}

+

data: {{ props.cluster?.nodes.count.data }}

-

{{ $t('manage.shards') }}: {{ clusterState.shards.count }}

- xxxx +

{{ $t('manage.shards') }}: {{ props.cluster?.indices.shards.total }}

+

primaries: {{ props.cluster?.indices.shards.primaries }}

+

+ replicas: + {{ + (props.cluster?.indices?.shards?.total || 0) - + (props.cluster?.indices.shards?.primaries || 0) + }} +

-

{{ $t('manage.indices') }}: {{ clusterState.indices.count }}

- xxxx +

{{ $t('manage.indices') }}: {{ props.cluster?.indices.count }}

+

docs: {{ props.cluster?.indices.docs.count }}

+

size: {{ prettyBytes(props.cluster?.indices.store.size_in_bytes || 0) }}