Skip to content

Commit 921f9c3

Browse files
committed
Switch from string to enum for metrics
1 parent 0f1657e commit 921f9c3

File tree

7 files changed

+97
-18
lines changed

7 files changed

+97
-18
lines changed

specification/_types/common.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ export type ProjectRouting = string
6767

6868
export type Routing = string
6969
export type LongId = string
70-
//TODO encode metrics as API specific enums
71-
export type IndexMetrics = string
72-
export type Metrics = string | string[]
7370

7471
export type ClusterAlias = string
7572

@@ -391,3 +388,31 @@ export enum ClusterInfoTarget {
391388
}
392389

393390
export type ClusterInfoTargets = ClusterInfoTarget | ClusterInfoTarget[]
391+
392+
393+
export enum CommonStatsFlag {
394+
_all,
395+
store,
396+
indexing,
397+
get,
398+
search,
399+
merge,
400+
flush,
401+
refresh,
402+
query_cache,
403+
fielddata,
404+
docs,
405+
warmer,
406+
completion,
407+
segments,
408+
translog,
409+
request_cache,
410+
recovery,
411+
bulk,
412+
shard_stats,
413+
mappings,
414+
dense_vector,
415+
sparse_vector
416+
}
417+
418+
export type CommonStatsFlags = CommonStatsFlag | CommonStatsFlag[]

specification/cluster/reroute/ClusterRerouteRequest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919

2020
import { RequestBase } from '@_types/Base'
21-
import { Metrics } from '@_types/common'
2221
import { Duration } from '@_types/Time'
2322
import { Command } from './types'
2423

@@ -63,9 +62,10 @@ export interface Request extends RequestBase {
6362
explain?: boolean
6463
/**
6564
* Limits the information returned to the specified metrics.
65+
* @deprecated 8.6.0 This parameter has no effect; its use will be forbidden in a future version.
6666
* @server_default all
6767
*/
68-
metric?: Metrics
68+
metric?: string | string[]
6969
/**
7070
* If true, then retries allocation of shards that are blocked due to too many subsequent allocation failures.
7171
* @server_default false

specification/cluster/state/ClusterStateRequest.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { RequestBase } from '@_types/Base'
2121
import {
2222
ExpandWildcards,
2323
Indices,
24-
Metrics,
2524
VersionNumber
2625
} from '@_types/common'
2726
import { Duration } from '@_types/Time'
@@ -68,7 +67,7 @@ export interface Request extends RequestBase {
6867
}
6968
]
7069
path_parts: {
71-
metric?: Metrics
70+
metric?: ClusterStateMetric | ClusterStateMetric[]
7271
index?: Indices
7372
}
7473
query_parameters: {
@@ -91,3 +90,14 @@ export interface Request extends RequestBase {
9190
wait_for_timeout?: Duration
9291
}
9392
}
93+
94+
export enum ClusterStateMetric {
95+
version,
96+
master_node,
97+
blocks,
98+
nodes,
99+
metadata,
100+
routing_table,
101+
routing_nodes,
102+
customs
103+
}

specification/indices/stats/IndicesStatsRequest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
import { RequestBase } from '@_types/Base'
2121
import {
22+
CommonStatsFlags,
2223
ExpandWildcards,
2324
Fields,
2425
Indices,
25-
Level,
26-
Metrics
26+
Level
2727
} from '@_types/common'
2828

2929
/**
@@ -64,7 +64,7 @@ export interface Request extends RequestBase {
6464
}
6565
]
6666
path_parts: {
67-
metric?: Metrics
67+
metric?: CommonStatsFlags
6868
index?: Indices
6969
}
7070
query_parameters: {

specification/nodes/info/NodesInfoRequest.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import { RequestBase } from '@_types/Base'
21-
import { Metrics, NodeIds } from '@_types/common'
21+
import { NodeIds } from '@_types/common'
2222
import { Duration } from '@_types/Time'
2323

2424
/**
@@ -54,7 +54,7 @@ export interface Request extends RequestBase {
5454
/** Comma-separated list of node IDs or names used to limit returned information. */
5555
node_id?: NodeIds
5656
/** Limits the information returned to the specific metrics. Supports a comma-separated list, such as http,ingest. */
57-
metric?: Metrics
57+
metric?: NodesInfoMetrics | NodesInfoMetrics[]
5858
}
5959
query_parameters: {
6060
/**
@@ -69,3 +69,20 @@ export interface Request extends RequestBase {
6969
timeout?: Duration
7070
}
7171
}
72+
73+
export enum NodesInfoMetrics {
74+
_all,
75+
_none,
76+
settings,
77+
os,
78+
process,
79+
jvm,
80+
thread_pool,
81+
transport,
82+
http,
83+
remote_cluster_server,
84+
plugins,
85+
ingest,
86+
aggregations,
87+
indices
88+
}

specification/nodes/stats/NodesStatsRequest.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import { RequestBase } from '@_types/Base'
21-
import { Fields, Metrics, NodeIds, NodeStatsLevel } from '@_types/common'
21+
import { Fields, CommonStatsFlags, NodeIds, NodeStatsLevel } from '@_types/common'
2222
import { Duration } from '@_types/Time'
2323

2424
/**
@@ -63,9 +63,9 @@ export interface Request extends RequestBase {
6363
/** Comma-separated list of node IDs or names used to limit returned information. */
6464
node_id?: NodeIds
6565
/*+ Limits the information returned to the specific metrics. */
66-
metric?: Metrics
66+
metric?: NodeStatsMetrics | NodeStatsMetrics[]
6767
/** Limit the information returned for indices metric to the specific index metrics. It can be used only if indices (or all) metric is specified.*/
68-
index_metric?: Metrics
68+
index_metric?: CommonStatsFlags
6969
}
7070
query_parameters: {
7171
/** Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics. */
@@ -100,3 +100,24 @@ export interface Request extends RequestBase {
100100
include_unloaded_segments?: boolean
101101
}
102102
}
103+
104+
export enum NodeStatsMetrics {
105+
_all,
106+
_none,
107+
os,
108+
process,
109+
jvm,
110+
thread_pool,
111+
fs,
112+
transport,
113+
http,
114+
breaker,
115+
script,
116+
discovery,
117+
ingest,
118+
adaptive_selection,
119+
script_cache,
120+
indexing_pressure,
121+
repositories,
122+
allocations
123+
}

specification/nodes/usage/NodesUsageRequest.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
import { RequestBase } from '@_types/Base'
21-
import { Metrics, NodeIds } from '@_types/common'
21+
import { NodeIds } from '@_types/common'
2222
import { Duration } from '@_types/Time'
2323

2424
/**
@@ -53,9 +53,9 @@ export interface Request extends RequestBase {
5353
node_id?: NodeIds
5454
/**
5555
* Limits the information returned to the specific metrics.
56-
* A comma-separated list of the following options: `_all`, `rest_actions`.
56+
* A comma-separated list of the following options: `_all`, `rest_actions`, `aggregations`.
5757
*/
58-
metric?: Metrics
58+
metric?: NodesUsageMetric | NodesUsageMetric[]
5959
}
6060
query_parameters: {
6161
/**
@@ -66,3 +66,9 @@ export interface Request extends RequestBase {
6666
timeout?: Duration
6767
}
6868
}
69+
70+
export enum NodesUsageMetric {
71+
_all,
72+
rest_actions,
73+
aggregations
74+
}

0 commit comments

Comments
 (0)