forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindices.js
189 lines (185 loc) · 5.56 KB
/
indices.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { capitalize } from 'lodash';
import { LARGE_FLOAT, LARGE_BYTES, LARGE_ABBREVIATED } from '../../../../common/formatting';
import { formatMetric } from '../../../lib/format_number';
import { getSafeForExternalLink } from '../../../lib/get_safe_for_external_link';
import { ElasticsearchStatusIcon } from '../status_icon';
import { ClusterStatus } from '../cluster_status';
import { EuiMonitoringTable } from '../../table';
import {
EuiLink,
EuiPage,
EuiPageContent,
EuiPageBody,
EuiPanel,
EuiSwitch,
EuiSpacer,
EuiScreenReaderOnly,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
const columns = [
{
name: i18n.translate('xpack.monitoring.elasticsearch.indices.nameTitle', {
defaultMessage: 'Name',
}),
field: 'name',
width: '350px',
sortable: true,
render: value => (
<div data-test-subj="name">
<EuiLink
href={getSafeForExternalLink(`#/elasticsearch/indices/${value}`)}
data-test-subj={`indexLink-${value}`}
>
{value}
</EuiLink>
</div>
),
},
{
name: i18n.translate('xpack.monitoring.elasticsearch.indices.statusTitle', {
defaultMessage: 'Status',
}),
field: 'status',
sortable: true,
render: value => (
<div className="monElasticsearchIndicesTable__status" title={`Index status: ${value}`}>
<ElasticsearchStatusIcon status={value} />
{capitalize(value)}
</div>
),
},
{
name: i18n.translate('xpack.monitoring.elasticsearch.indices.documentCountTitle', {
defaultMessage: 'Document Count',
}),
field: 'doc_count',
sortable: true,
render: value => (
<div data-test-subj="documentCount">{formatMetric(value, LARGE_ABBREVIATED)}</div>
),
},
{
name: i18n.translate('xpack.monitoring.elasticsearch.indices.dataTitle', {
defaultMessage: 'Data',
}),
field: 'data_size',
sortable: true,
render: value => <div data-test-subj="dataSize">{formatMetric(value, LARGE_BYTES)}</div>,
},
{
name: i18n.translate('xpack.monitoring.elasticsearch.indices.indexRateTitle', {
defaultMessage: 'Index Rate',
}),
field: 'index_rate',
sortable: true,
render: value => <div data-test-subj="indexRate">{formatMetric(value, LARGE_FLOAT, '/s')}</div>,
},
{
name: i18n.translate('xpack.monitoring.elasticsearch.indices.searchRateTitle', {
defaultMessage: 'Search Rate',
}),
field: 'search_rate',
sortable: true,
render: value => (
<div data-test-subj="searchRate">{formatMetric(value, LARGE_FLOAT, '/s')}</div>
),
},
{
name: i18n.translate('xpack.monitoring.elasticsearch.indices.unassignedShardsTitle', {
defaultMessage: 'Unassigned Shards',
}),
field: 'unassigned_shards',
sortable: true,
render: value => <div data-test-subj="unassignedShards">{formatMetric(value, '0')}</div>,
},
];
const getNoDataMessage = () => {
return (
<div>
<p>
<FormattedMessage
id="xpack.monitoring.elasticsearch.indices.noIndicesMatchYourSelectionDescription"
defaultMessage="There are no indices that match your selections. Try changing the time range selection."
/>
</p>
<p>
<FormattedMessage
id="xpack.monitoring.elasticsearch.indices.howToShowSystemIndicesDescription"
defaultMessage="If you are looking for system indices (e.g., .kibana), try checking ‘Show system indices’."
/>
</p>
</div>
);
};
export const ElasticsearchIndices = ({
clusterStatus,
indices,
sorting,
pagination,
onTableChange,
toggleShowSystemIndices,
showSystemIndices,
}) => {
return (
<EuiPage>
<EuiPageBody>
<EuiScreenReaderOnly>
<h1>
<FormattedMessage
id="xpack.monitoring.elasticsearch.indices.heading"
defaultMessage="Elasticsearch indices"
/>
</h1>
</EuiScreenReaderOnly>
<EuiPanel>
<ClusterStatus stats={clusterStatus} />
</EuiPanel>
<EuiSpacer size="m" />
<EuiPageContent>
<EuiSwitch
label={
<FormattedMessage
id="xpack.monitoring.elasticsearch.indices.systemIndicesLabel"
defaultMessage="System indices"
/>
}
checked={showSystemIndices}
onChange={e => toggleShowSystemIndices(e.target.checked)}
/>
<EuiSpacer size="m" />
<EuiMonitoringTable
className="elasticsearchIndicesTable"
rows={indices}
columns={columns}
sorting={sorting}
pagination={pagination}
message={getNoDataMessage()}
search={{
box: {
incremental: true,
placeholder: i18n.translate(
'xpack.monitoring.elasticsearch.indices.monitoringTablePlaceholder',
{
defaultMessage: 'Filter Indices…',
}
),
},
}}
onTableChange={onTableChange}
executeQueryOptions={{
defaultFields: ['name'],
}}
/>
</EuiPageContent>
</EuiPageBody>
</EuiPage>
);
};